<p>I have a build script and as part of that script it copies a jar file to a directory, for ease lets call it the utils jar.  the utils jar is built by another build script sitting in another directory.  What im trying to do have my build script run the utils build script so that I can ensure the utils jar is up to date.</p>

<p>So I know I need to import the utils build file.</p>

<pre><code>&lt;import file="../utils/build/build.xml" /&gt;
</code></pre>

<p>Which doesn't work because the import task, unlike almost every other ant taks, doesn't run from basedir, it runs from the pwd.  So to get around that I have this little ditty, which does successfully import the build file</p>

<pre><code>  &lt;property name="baseDirUpOne" location=".." /&gt;
  &lt;import file="${baseDirUpOne}/utils/build/build.xml" /&gt;
</code></pre>

<p>So now that ive solved my import problem I need to call the task, well that should be easy right:</p>

<pre><code>&lt;antcall target="utils.package" /&gt;
</code></pre>

<p><em>note that in the above, utils is the project name of ../utils/build/build.xml</em></p>

<p>the problem I'm now running into is that ant call doesn't execute in ../utils/build so what I need, and cant find, is a runat property or something similar, essentially:</p>

<pre><code>&lt;antcall target="utils.package" runat="../utils/build" /&gt;
</code></pre>

<p>The reason I need this is that in my utils build file the step to select which code to copy to the jar is based on relative paths so as to avoid hardcoding paths in my ant file. Any ideas? </p>

[{'answer_id': 8805, 'author': 'Theo', 'author_id': 1109, 'author_profile': 'https://Stackoverflow.com/users/1109', 'pm_score': 6, 'selected': True, 'text': '<p>I\'ve got something similar set up: I have a main Ant build.xml which calls a separate build.xml that takes care of building my tests. This is how I do it:</p>\n\n<pre><code>&lt;target name="build-tests"&gt;\n    &lt;subant target="build"&gt;\n      &lt;fileset dir="${test.home}" includes="build.xml"/&gt;\n    &lt;/subant&gt;\n&lt;/target&gt;\n</code></pre>\n\n<p>The trick is to use <a href="http://ant.apache.org/manual/Tasks/subant.html" rel="noreferrer"><code>subant</code></a> instead of <code>antcall</code>. You don\'t have to import the other build file.</p>\n'}, {'answer_id': 8810, 'author': 'James Sulak', 'author_id': 207, 'author_profile': 'https://Stackoverflow.com/users/207', 'pm_score': 3, 'selected': False, 'text': '<p>Try using the <a href="http://ant.apache.org/manual/Tasks/ant.html" rel="noreferrer">"ant" task</a> instead of the "antcall" task, which runs the imported build directly instead of importing it into the current build file. It has a "dir" parameter:</p>\n\n<blockquote>\n  <p>the directory to use as a basedir\n  for the new Ant project. Defaults to\n  the current project\'s basedir, unless\n  inheritall has been set to false, in\n  which case it doesn\'t have a default\n  value. This will override the basedir\n  setting of the called project.</p>\n</blockquote>\n\n<p>So you could do:</p>\n\n<pre><code>&lt;ant antfile="${baseDirUpOne}/utils/build/build.xml" dir="../utils/build" /&gt;\n</code></pre>\n\n<p>or something like that.</p>\n'}, {'answer_id': 142461, 'author': 'Peter Kahn', 'author_id': 9950, 'author_profile': 'https://Stackoverflow.com/users/9950', 'pm_score': 0, 'selected': False, 'text': '<p>You can pass params down to antcall using  nested in the antcall block.   So, you can pass the properties down that way (probably even basedir since properties are immutable).   </p>\n'}]
['https://Stackoverflow.com/questions/8790', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/292/']