[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] More than one execution of <iajc> task in same Ant session resulting in "Unable to find aspectjtools to fork"
|
Title: More than one execution of <iajc> task in same Ant session resulting in "Unable to find aspectjtools to fork"
Newbie to AspectJ - but spent a good amount of time looking through the AspectJ <iajc> ant task documentation and the aspectj-users mail list archives. Here is my issue. I'm using the <iajc> Ant task (AspectJ 1.5.2). Everything works fine when/if the <iajc> task is only executed once per Ant session (i.e. when a single target is specified on ant commandline, say 'ant build', resulting in one invocation of <iajc> task. However I'm getting "unable to find aspectjtools to fork - tried ../lib/aspectjtools.jar" when the <iajc> task is executed more than once per Ant session (i.e. when multiple targets are specified on ant commandline, say 'ant build test', resulting in more than one invocation of the <iajc> task. I'm certain the solution lies in the forkclasspath attribute of the <iajc> task based on what I've read, but so far I have been unable to get it working as prescribed. I tried copying aspectjtools.jar into Ant's lib but did not help. I've included relevant sections of my Ant build script (note that the 'test' target depends on 'build-test' which depends on 'build'). For now, I've added an up-to-date/check target to determine if the [2nd] build is necessary which avoids the issue but I wouldn't consider this a fix (more a workaround). Any tips or pointers would be much appreciated.
Relevant sections/snippets of Ant build script:
<target name="set-path">
<path id="aspectj.classpath">
<pathelement location="../lib/aspectjtools.jar"/>
</path>
<path id="project.classpath">
<pathelement location="."/>
<pathelement location="${classes}"/>
<pathelement path="${depends.jdk.libs}"/>
<pathelement location="../lib/aspectjrt.jar"/>
</path>
</target>
<!-- build -->
<target name="build" depends="set-paths" description="Compile source files">
<taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"
classpathref="aspectj.classpath"/>
<iajc fork="true"
deprecation="off"
debug="true"
X="noInline"
destdir="${classes}"
classpathref="project.classpath"
forkclasspathref="aspectj.classpath"
<sourceroots>
<pathelement location="${sources}"/>
<pathelement location="${resources}"/>
</sourceroots>
</iajc>
</target>
<!-- dist -->
<target name="dist" depends="build" description="Create distribution files">
<jar jarfile="${distdir}/${jarfile}" manifest="${tmp.manifest.file}">
<fileset dir="${classes}">
<include name="**/*"/>
</fileset>
<fileset dir="${src.config.dir}">
<include name="**/*.*"/>
</fileset>
</jar>
</target>
<!-- build-test -->
<target name="build-test" depends="build">
<javac destdir="${test.classes}"
deprecation="off"
debug="${debugmode}"
classpathref="project.class.path"
fork="yes"
executable="${javac.location}"
compiler="${javac.version}">
<src path="${test.src.dir}" />
</javac>
</target>
<!-- test -->
<target name="test" depends="build-test" description="Run unit tests">
... (emma)
<junit fork="yes" haltonfailure="no" printsummary="on">
<formatter type="xml"/>
<formatter type="brief" usefile="false"/>
<test name="${test.entry}" todir="${test.results.dir}"/>
<classpath>
<pathelement location="${out.instr.dir}"/>
<path refid="emma.lib"/>
</classpath>
<classpath refid="project.class.path"/>
<classpath refid="runtime.class.path"/>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.ec"/>
<jvmarg value="-Demma.coverage.out.merge=false"/>
<jvmarg value="-Dlog.dir=${log.dir}"/>
</junit>
... (junitreports)
... (emma reports)
</target>
For now, I added a 'check' to determine if the build is necessary which avoids the problem.
<target name="is.build.necessary">
<uptodate property="build.unnecessary" targetfile="${distdir}/${jarfile}">
<srcfiles dir="${sources}" includes="**/*.java **/*.aj" />
<srcfiles dir="${resources}" includes="**/*.java **/*.aj" />
</uptodate>
</target>
<!-- build -->
<target name="build" depends="post-process, is.build.necessary" unless="build.unnecessary"
...
Thank you,
Tim Mulligan