I need to do some tasks via shell scripts. Among those tasks are also ant scripts. Sometimes I need to pass some arguments to ant script from shell scripts. I've found that this can be done through java system properties. Those properties are easily accessed from ant build file - just like properties declared in build file itself: ${property.name}
Here is a brief example. The build file cool-build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="FunProject" default="work" basedir=".">
<target name="work">
<echo message="my.cool.property=${my.cool.property}">
</target>
</project>
We, run it with passed system property my.cool.property:
ant -f cool-build.xml -Dmy.cool.property=1
And the result is:
[echo] my.cool.property=1
Just as expected :)
Read full article from Java Hamster: Accessing system properties from Ant build file
No comments:
Post a Comment