user147373
user147373

Reputation:

java ant buildfile for project with dependencies

I am new to ant, but am trying to create an ant script that builds my current proeject with another project as a dependency. I have the ant script building my current project, but am unsure how to add the other project to the classpath. Neither project get put into jar files at the moment.

My current portion of the build.xml file is

<target name="run" depends="compile">
<java classname="com.mypackage.Main">
        <classpath>
            <pathelement location="../project1/out"/>
            <pathelement location="${bin}"/>
        </classpath>
    </java>
</target>

Thanks for your help!

Upvotes: 1

Views: 1781

Answers (1)

user147373
user147373

Reputation:

I was able to do it using

<target name="run" depends="compile">
    <java classname="com.mypackage.Main" fork="true">
        <classpath>
            <dirset dir="${other.dir}">
                <include name="out/**"/>
            </dirset>
            <pathelement location="${bin}" />
        </classpath>
    </java>
</target>

Where ${other.dir} is the relative path to the root of the other project.

Upvotes: 2

Related Questions