shikarishambu
shikarishambu

Reputation: 115

Ant: how do I pass values to properties from top level build.xml to build.xml in sub folders

I have a set of folders with build.xml and sql scripts (one folder per database schema). I have a build.xml at the root level. I want to set the values of server, port, userid, password etc... in the root level build.xml and pass it to the build.xml in each of the folders. How can I do that?

Upvotes: 6

Views: 6693

Answers (3)

skaffman
skaffman

Reputation: 403441

The <ant> task does what you need:

Runs Ant on a supplied buildfile. This can be used to build subprojects.

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

So you just need to invoke <ant antfile="dir/build.xml"/>. No need to set the inheritAll attribute, it defaults to true.

Upvotes: 3

Alexander Pogrebnyak
Alexander Pogrebnyak

Reputation: 45576

If you want a more fine-grained control you can set inheritall to false and pass individual properties as nested elements of <ant> task.

E.g.

<ant antfile="sub/build.xml" inheritall="false">
  <property name="server" value="server.foo.bar"/>
  <property name="port" value="1234"/>
  ...
</ant>

Also, <ant> task accepts <propertyset> nested element, so you can bundle several properties together and just pass a single property set.

Upvotes: 4

rodrigoap
rodrigoap

Reputation: 7480

This way:

<ant antfile="sub/build.xml" inheritall="true"/>

Upvotes: 7

Related Questions