Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Damn, you're right, this property doesn't get replaced during the filtering of resources. That's weird and it sounds like a bug in the <a href="https://issues.apache.org/jira/browse/MRESOURCES" rel="nofollow noreferrer">Maven Resources Plugin</a> because this property is correctly interpolated during the <code>process-resources</code> phase as I'll demonstrate in the workaround I'm suggesting below (based on the maven-antrun-plugin and the <a href="http://ant.apache.org/manual/Tasks/replace.html" rel="nofollow noreferrer"><code>replace</code></a> task). </p> <p>First, add the following to your POM:</p> <pre><code> &lt;plugin&gt; &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;configuration&gt; &lt;tasks&gt; &lt;echo&gt;${project.dependencies[0].artifactId}&lt;/echo&gt;&lt;!-- I'm a test --&gt; &lt;replace file="${project.build.outputDirectory}/myxmlfile.xml" token="@@@" value="${project.dependencies[0].artifactId}"/&gt; &lt;/tasks&gt; &lt;/configuration&gt; &lt;goals&gt; &lt;goal&gt;run&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>Then, update your XML file into:</p> <pre><code>&lt;somenode&gt; &lt;fileName&gt;@@@&lt;/fileName&gt; &lt;/somenode&gt; </code></pre> <p>With these changes, running <code>mvn process-resources</code> would produce the following result:</p> <pre><code>$ cat target/classes/myxmlfile.xml &lt;somenode&gt; &lt;fileName&gt;OtherLibrary&lt;/fileName&gt; &lt;/somenode&gt; </code></pre> <p>Which proves the property is interpolated (but not set during maven filtering of resources)<sup>1</sup>. And if you need to filter more than one file, the <a href="http://ant.apache.org/manual/Tasks/replace.html" rel="nofollow noreferrer"><code>replace</code></a> task can take a fileset. Adapt it to suit your needs. </p> <p><sub><sup>1</sup> <strike>Actually, it would be nice to create a new Jira for this bug in the <a href="https://issues.apache.org/jira/browse/MRESOURCES" rel="nofollow noreferrer">Maven 2.x Resources Plugin</a>.</strike> I've created <a href="https://issues.apache.org/jira/browse/MRESOURCES-118" rel="nofollow noreferrer">MRESOURCES-118</a>.</sub></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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