Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to parameterize a path in ANT?
    text
    copied!<p>I have the following defined in a file called <em>build-dependencies.xml</em></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project name="build-dependencies"&gt; ... &lt;path id="common-jars"&gt; &lt;fileset file="artifacts/project-1/jar/some*.jar" /&gt; &lt;fileset file="artifacts/project-2/jar/someother*.jar" /&gt; &lt;/path&gt; ... &lt;/project&gt; </code></pre> <p>I include it at the top of my <em>build.xml</em> file. Now I need to make the artifacts folder a parameter so it can be changed during execution of different targets. Having this...</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;project name="build-dependencies"&gt; ... &lt;path id="common-jars"&gt; &lt;fileset file="${artifacts}/project-1/jar/some*.jar" /&gt; &lt;fileset file="${artifacts}/project-2/jar/someother*.jar" /&gt; &lt;/path&gt; ... &lt;/project&gt; </code></pre> <p>...and defining an "artifacts" property (and changing it) in the target does not work because it seems that the property substitution happens when the path is defined in <em>build-dependencies.xml</em></p> <p>How can I solve this? One way I was thinking was to have a parameterized macro and call that before the path is actually used, but that seems not elegant. Something like this:</p> <pre><code>&lt;macrodef name="create-common-jars"&gt; &lt;attribute name="artifacts"/&gt; &lt;sequential&gt; &lt;path id="common-jars"&gt; &lt;fileset file="@{artifacts}/project-1/jar/some*.jar" /&gt; &lt;fileset file="@{artifacts}/project-2/jar/someother*.jar" /&gt; &lt;/path&gt; &lt;/sequential&gt; &lt;/macrodef&gt; </code></pre> <p>EDIT: Ivy and command line parameters are not an option.</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