Idan
Idan

Reputation: 21

Build ANT Project which includes another project

I have 2 Projects:

  1. Project1 - Independent
  2. Project2 - Includes Project1 in the "Projects" tab under "Build Path" (Eclipse Junu)

My Ant build.xml (project2) looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="Project2">
<property name="projectName" value="Project2"/>
<property environment="env"/>
<property name="runnerRoot" value="${env.RUNNER_ROOT}"/>
<property name="dist" value="../FluidFsAuto/lib"/>
<property name="buildFilesDir" value="${runnerRoot}/dev"/>
<import file="${buildFilesDir}/buildHelper.xml"/>
</project>

I am getting undefined errors such as: "cannot find symbol" ... etc...

How, can i use ANT build to compile project2 with the build.xml?

Upvotes: 1

Views: 2588

Answers (1)

Gilberto Torrezan
Gilberto Torrezan

Reputation: 5277

Use the Ant task to run tasks from other build file.

But at this point you should consider using Apache Maven.

--- Edit ---

Here is some example of how to call multiple build.xml files in sequence:

<target name="myTask1">
    <!-- simple call to the build.xml -->
    <ant antfile="../project2/build.xml" target="myTask2"/>

    <!-- to pass a property to the target build.xml, use this -->
    <ant antfile="../project3/build.xml" target="myTask3">
        <property name="myProperty1" value="myValue1"/>
    </ant>

    <!-- to pass all properties to the target build.xml, use inheritAll -->
    <property name="myProperty2" value="myValue2"/>
    <ant antfile="../project4/build.xml" target="myTask4" inheritAll="true"/>
</target>

More examples here.

Upvotes: 1

Related Questions