开发者

Ant, set environmental variable for <ant> task?

I want to run another ant build file from ant, and the <ant> task looks perfect for this.

The other build file uses environmental vari开发者_运维问答ables for a couple things. Is there a way to set environmental variables for the child ant process?

I see that the <exec> task seems to support nested <env>s, but nothing similar for <ant>.


From the documentation of ant task,

By default, all of the properties of the current project will be available in the new project.

You can also set properties in the new project from the old project by using nested property tags.

<ant antfile="subproject/property_based_subbuild.xml">
  <property environment="env"/>
</ant>


by default the inner ant call inherits the parent properties

<ant inheritAll="true" antfile="subproject/subbuild.xml">
  <!--inheritAll="true" is default value, this is unecessary -->

  <property name="myprop" value="foo"/>

  <antcall target="myTarget"></antcall> 
  <ant antfile="myAntFile"></ant>

</ant>

In this case, "myTarget" and all targets on "myAntFile" can get "foo" as "myprop" value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜