In an ant build script, can I reference a path in a different build file?
I have a path with an id in one build file. I have another build file which requires a path containing the same jars that are defined in the first build file. Instead of duplicating the jars in the second build file, can I simply reference the path defined in the first build file from my second build file? I ca开发者_高级运维n't import the first build file using an import tag for various reasons. Are there any other options?
You could set the path to the JARS as an environment variable, and look up those environment variables in your second build file.
I am not sure how you export environment variables from ant, but here's how you import them:
<property environment="ENV" />
<condition property="HOSTNAME" value="${ENV.TARGETHOSTNAME}">
<isset property="ENV.TARGETHOSTNAME" />
</condition>
(TARGETHOSTNAME being the environment variable that was set previously)
Option #1: put jar paths in a separated file, say, jars.config
and load it to build files using:
<property file="jars.config"/>
Option #2, if are calling the second build file from the first one, you can define appropriate properties in the second build file, and specify them when you call it:
...
<ant ...>
<property name="jar1.path" value="${jar1.path}"/>
...
</ant>
精彩评论