58

I need to invoke a ant script via shell script. Let us consider the parameters for ant script are a,b,c. how can i pass the parameter for those variables? I must provide the parameters for ant vis invoke the shell script. can anyone help me on this?

trilawney
  • 1,766
  • 6
  • 26
  • 34

1 Answers1

125

Do you mean assigning value to a property from command line? If so, try

-DpropertyName=itsValue

For example,

<project>
    <target name="hi">
        <property name="person" value="world"/>
        <echo message="Hello ${person}"/>
    </target>
</project>

and then

ant -Dperson="MerryPrankster" hi

yields

 [echo] Hello MerryPrankster
merryprankster
  • 3,249
  • 2
  • 21
  • 26
  • 1
    I revised the answer, hope it explains – merryprankster Jul 21 '11 at 13:10
  • 1
    what happens if you just say `ant` in command line? your error is not related to defining property values in command line, it is simply matter of ant binary not being found. If you get this when trying to invoke ant from a shell script, try referring to ant binary via it's full path. – merryprankster Jul 21 '11 at 17:07