Note that there are some explanatory texts on larger screens.

plurals
  1. POActually invoke maven-resources-plugin (and use variables in code) during development?
    text
    copied!<p>I would like to define properties in .properties files using info from maven; e.g. app.name=project.build.artifactId.</p> <p>If I invoke resources:resources at build time, it makes a file named *.properties in my TARGET folder (in eclipse) containing app.name with (hopefully) my artifactId.</p> <p>However, when I run a java application through eclipse, does it use the file found in /target, or does it use the version from /src/main/resources (which contains the variable placeholder and not the value itself)?</p> <p>Edits:</p> <p>Here is he code I wish to use a "filtered" value for:</p> <pre><code>// Get project version from maven resource filtering static { Properties prop = new Properties(); try { // load a properties file prop.load(new FileInputStream("src/main/resources/project.properties")); // get the property value and print it out System.out.println(prop.getProperty("app.version")); } catch (IOException ex) { logger.error("Error (1): Failed to get application version from configuration file"); System.out.println("Unexpected error (1). Aborting..."); } } </code></pre> <p>Relevant info from project's POM.xml:</p> <pre><code>&lt;build&gt; &lt;!-- Resource filtering --&gt; &lt;resources&gt; &lt;resource&gt; &lt;directory&gt;src/main/resources&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;includes&gt; &lt;include&gt;**/*.properties&lt;/include&gt; &lt;/includes&gt; &lt;/resource&gt; &lt;/resources&gt; &lt;/build&gt; </code></pre> <p>project.properties contents:</p> <pre><code>app.version=${project.build.version} </code></pre> <p>When I run the project through eclipse (not executing the JAR), the output of the first segment (in the static block) returns "${project.build.version}" literally. It doesn't actually return the value of the project's tags.</p> <p>I have even tried running resources:resources first to see if that did anything, but it didn't. How exactly does resource filtering work - or better yet, when are you actually supposed to use it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload