java - ANT - How to append compiled classes to classpath dynamically -
setup:
project - pure java project no dependencies.
project b - pure java project depends on project a.
process:
i have build project script in each of project root directory , master script run them both, in correct order, first project , project b. script output relative each project's path.
the script works fine project a, when comes project b misses classes output of project a.
using ant, there way add "dynamically" compile classpath output of compile project?
or, there action can take except explicitly provide project b classes output path of project a?
ok, took bunch of hacking.
first use add ant-contrib ant can download here.
then declared var instead of property in main ant script. in compile macro i've passed javac classpath. after compile done, i've appended new classes output folder classpath var , called next compile.
good luck.
the compile script:
<?xml version="1.0"?> <project name="pdf test client" default="main" basedir="."> <taskdef resource="net/sf/antcontrib/antlib.xml" /> <macrodef name="compile"> <attribute name="projectname" default=" -- set aname 'projectname' property --" /> <attribute name="projectrootdir" default="." /> <attribute name="sourcedir" default="@{projectrootdir}/src" /> <attribute name="outputdir" default="@{projectrootdir}/output" /> <attribute name="builddir" default="@{outputdir}/bin" /> <attribute name="classesdir" default="@{builddir}/classes" /> <sequential> <echo message="compiling... @{projectname}" /> <mkdir dir="@{classesdir}" /> <javac srcdir="@{sourcedir}" destdir="@{classesdir}" classpath="${classpathfolders}" includeantruntime="true" /> <var name="classpathfolders" value="${classpathfolders}; @{classesdir}" /> <echo message="-" /> </sequential> </macrodef> <target name="main"> </target> </project>
Comments
Post a Comment