如何传递Ant脚本的参数,这是通过shell脚本调用的?

tri*_*ney 52 ant shell scripting shellexecute

我需要通过shell脚本调用ant脚本.让我们考虑一下ant脚本的参数是a,b,c.我怎样才能传递这些变量的参数?我必须提供ant vis的参数来调用shell脚本.谁可以帮我这个事?

mer*_*ter 115

你的意思是从命令行为属性赋值?如果是这样,试试吧

-DpropertyName=itsValue
Run Code Online (Sandbox Code Playgroud)

例如,

<project>
    <target name="hi">
        <property name="person" value="world"/>
        <echo message="Hello ${person}"/>
    </target>
</project>
Run Code Online (Sandbox Code Playgroud)

然后

ant -Dperson="MerryPrankster" hi
Run Code Online (Sandbox Code Playgroud)

产量

 [echo] Hello MerryPrankster
Run Code Online (Sandbox Code Playgroud)