Sunday, 15 May 2011

Creating Ant classpath out of project names -



Creating Ant classpath out of project names -

in ant build script have list of projects depending on. need create classpath compilation.

i have:

included.projects=projecta, projectb

and need:

included.project.classpath=../projecta/bin, ../projectb/bin

current code:

<echo message="${included.projects}" /> <pathconvert property="included.projects.classpath" dirsep="," > <map from="" to="../"/> <path location="${included.projects}"/> </pathconvert> <echo message="${included.projects.classpath}" /> <javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6"> <classpath> <pathelement path="${classpath}" /> <dirset includes="${included.projects.classpath}" /> </classpath> </javac>

i've tried explicit declaration too, didn't work:

<path id="modules.classpath"> <fileset dir="../modulea/bin" /> <fileset dir="../moduleb/bin"/> </path> <path id="libraries.classpath"> <fileset dir="lib" includes="*.jar"/> </path> <javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6"> <classpath refid="libraries.classpath" /> <classpath refid="modules.classpath" /> </javac>

i'm curious, problem explicit declaration code, , possible solve comma-separated-string classpath solution.

i think simpler explicity declare classpath @ top of build follows:

<path id="compile.path"> <fileset dir="../projecta/bin" includes="*.jar"/> <fileset dir="../projectb/bin" includes="*.jar"/> </path>

used follows:

<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6"> <classpath> <path refid="compile.path"/> <pathelement path="${classpath}" /> </classpath> </javac>

note:

i read question 1 time again , realised you're not using jar files built other projects, you? .... not great idea....

ant classpath

No comments:

Post a Comment