Hi Guys,
I'm invoking ANT programmatically in Java, and I'm having a hard time with
running some targets. The code is that classical one:
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
ProjectHelper.configureProject( p, buildFile);
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget("_scanProject");
p.fireBuildFinished(null);
so my build file is not a build.xml it is called javalanche.xml : File
buildFile = new File(javalancheDestination,"javalanche.xml");
The code is working fine, but the problem is that I'm not sure if I'm
calling the targets right.
So my build file (javalanche.xml) imports another XML file
(mutation-include.xml).
so the target I'm calling (_scanProject) is in mutation-include.xml:
<target name="_scanProject">
<property name="scan.project.mutation.javaagent"
value="-javaagent:${javalanche.mutation.javaagent}"/>
<property name="scan.project.memory"
value="-Xmx${javalanche.maxmemory}"/>
<property name="scan.project.mutation.run.mode"
value="-Dmutation.run.mode=scan-project"/>
<property name="scan.project.javalanche.package.prefix"
value="-Dmutation.package.prefix=${project.prefix}"/>
<property name="scan.project.javalanche.project.test.suite"
value="-Dmutation.test.suite=${project.test.suite}"/>
<property name="scan.project.verbose" value="-verbose"/>
<path id="scan.project.classpath.add">
<path refid="mutation.classpath"/>
</path>
<antcall target="test-javalanche">
<!--${scan.project.verbose}-->
<param name="javalanche.arg.line" value="
${scan.project.mutation.javaagent} ${scan.project.memory}
${scan.project.mutation.run.mode} ${scan.project.javalanche.package.prefix}
${scan.project.javalanche.project.test.suite} " />
<reference refid="scan.project.classpath.add"
torefid="javalanche.classpath.add"/>
</antcall>
</target>
The "test-javalanche" target is in the javalanche.xml file:
<target name="test-javalanche">
<mkdir dir="mutation-files/junit-reports"></mkdir>
<junit dir="." printSummary="yes" fork="true" forkmode="once"
showoutput="true">
<classpath>
<path refid="javalanche.classpath.add" />
<pathelement path="${cp}"></pathelement>
</classpath>
<jvmarg line="${javalanche.arg.line}" />
<formatter type="xml"/>
<formatter usefile="true" type="plain"/>
<test todir="mutation-files/junit-reports" name="${testsuite}"
/>
</junit>
</target>
So when I call p.executeTarget("_scanProject"); it doesn't run right because
it doensn't run the target test-javalanche properly. It just creates the
directory.
The XML files are all fine. Because when I run it in the command line: "ant
-f javalanche.xml _scanProject" it runs perfectly. I'm not sure if
javalanche.arg.line is passed to test-javalanche.
Any thoughts on how to call the target right??
Cheers,
--
David Nemer
Sent from Frankfurt Am Main, HE, Germany