<target name="init">
<property
name="scala-library.jar"
value="${scala.home}/lib/scala-library.jar"
/>
<path id="build.classpath">
<pathelement location="${scala-library.jar}" />
<!--<pathelement location="${your.path}" />-->
<pathelement location="${build.dir}" />
</path>
<taskdef resource="${scala.home}/tools/ant/antlib.xml">
<classpath>
<pathelement location="${scala.home}/lib/scala-compiler.jar"/>
<pathelement location="${scala.home}/lib/scala-reflect.jar"/>
<pathelement location="${scala-library.jar}"/>
</classpath>
</taskdef>
</target>
<target name="build" depends="init">
<mkdir dir="${build.dir}" />
<scalac srcdir="/home/vf-root/workspaces/partnerspace/ipp-partner"
destdir="${build.dir}"
classpathref="build.classpath">
<include name="compile/**/*.scala" />
<exclude name="forget/**/*.scala" />
</scalac>
</target>
and Following is the output:
init:
[taskdef] Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found.
build:
BUILD FAILED
/home/vf-root/workspaces/partnerspace/ipp-partner/build.xml:89: Problem: failed to create task or type scalac
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
Total time: 0 seconds
Please help of with some soln so that I can get rid of that issue. Thank you.
Related
I have a problem with using Ant to compile a GWT project which is split into two parts. First project which is GWT project- client side of a web app and the second project included in build path which is a data model for hibernate. When I'm runing a build.xml I'm geting errors that I forget to inherit some modules. Where should I include my second project? in javac? project.classpath? libs?
I'm using standard build.xml example from GWT showcase:
<?xml version="1.0" encoding="utf-8" ?>
<project name="Showcase" default="build" basedir=".">
<!-- Arguments to gwtc and devmode targets -->
<property name="gwt.args" value="" />
<!-- Configure path to GWT SDK -->
<property name="gwt.sdk" location="../.." />
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
<!-- Add any additional non-server libs (such as JUnit) -->
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
</path>
<target name="libs" description="Copy libs to WEB-INF/lib">
<mkdir dir="war/WEB-INF/lib" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
<!-- Add any additional server libs that need to be copied -->
</target>
<target name="javac" depends="libs" description="Compile java source to bytecode">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.5" target="1.5" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
<copy todir="war/WEB-INF/classes">
<fileset dir="src" excludes="**/*.java"/>
</copy>
</target>
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
</java>
</target>
<target name="devmode" depends="javac" description="Run development mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="../../validation-api-1.0.0.GA.jar" />
<pathelement location="../../validation-api-1.0.0.GA-sources.jar" />
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="-startupUrl"/>
<arg value="Showcase.html"/>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="com.google.gwt.sample.showcase.Showcase"/>
</java>
</target>
<target name="superdevmode" depends="javac" description="Run Super Dev Mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.codeserver.CodeServer">
<classpath>
<pathelement location="src"/>
<pathelement location="../../gwt-codeserver.jar" />
<path refid="project.class.path"/>
<pathelement location="../../validation-api-1.0.0.GA.jar" />
<pathelement location="../../validation-api-1.0.0.GA-sources.jar" />
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="com.google.gwt.sample.showcase.Showcase"/>
</java>
</target>
<target name="eclipse.generate" depends="libs" description="Generate eclipse project">
<java failonerror="true" fork="true" classname="com.google.gwt.user.tools.WebAppCreator">
<classpath>
<path refid="project.class.path"/>
</classpath>
<arg value="-XonlyEclipse"/>
<arg value="-ignore"/>
<arg value="com.google.gwt.sample.showcase.Showcase"/>
</java>
</target>
<target name="hosted" depends="devmode" description="Run development mode (NOTE: the 'hosted' target is deprecated)" />
<target name="build" depends="gwtc" description="Build this project" />
<target name="war" depends="build" description="Create a war file">
<zip destfile="Showcase.war" basedir="war"/>
</target>
<target name="clean" description="Cleans this project">
<delete dir="war/WEB-INF/classes" failonerror="false" />
<delete dir="war/showcase" failonerror="false" />
</target>
</project>
Please help me to fix this error and warnings:
41: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
79: Errors while applying transformations: javax.xml.transform.TransformerException: java.lang.RuntimeException: Use of the extension element 'redirect' is not allowed when the secure processing feature is set to true.
Total time: 31 seconds
This is my build.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project basedir="." default="build" name="Login">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../../opt/eclipse"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<path id="Login.classpath">
<pathelement location="bin"/>
<pathelement location="../../Downloads/JAR/junit-4.10.jar"/>
<pathelement location="../../Downloads/JAR/poi-3.2-FINAL.jar"/>
<pathelement location="../../Downloads/JAR/selenium-java-2.21.0.jar"/>
<pathelement location="../../Downloads/JAR/selenium-java-2.21.0.zip"/>
<pathelement location="../../Downloads/JAR/selenium-java-2.21.0-srcs.jar"/>
<pathelement location="../../Downloads/JAR/selenium-server-standalone-2.21.0.jar"/>
<pathelement location="../../Downloads/JAR/testng-6.5.1.zip"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="Login.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="login.testLogin">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="login" todir="${junit.output.dir}"/>
<classpath refid="Login.classpath"/>
</junit>
</target>
<target name="login">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="login" todir="${junit.output.dir}"/>
<classpath refid="Login.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false">
<classpath>
<path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
<path id="junit" location="${lib.dir}/junit-4.9b2.jar"/>
</classpath>
</javac>
</target>
</project>
For the warning, please add includeantruntime to javac target.
Please follow below link for more information.
ant warning: "'includeantruntime' was not set"
What is your version of Ant?
This links talk about a fix in 1.8.3
I wanna prepare jcoverage report for my unit tests by using ANT and eclipse. I'm using
Apache Ant(TM) version 1.8.3 compiled on February 26 2012
selenium-server-standalone-2.20.0
junit-4.8.1.jar
eclipse sdk 3.6.1
i tried as mentioned in this link here.
but i'm not able to succeed.please provide if any documents are available or make me clear how to prepare report.
my ant file:
<?xml version="1.0"?>
<!DOCTYPE project [
<!ENTITY start_stop_selenium SYSTEM "start_stop_selenium.xml">
<!ENTITY properties_build_clean_compile_report SYSTEM "properties_build_clean_compile_report.xml">
]>
<project name="Run Selenium Tests" default="all_selenium_tests" basedir=".">
<property name="libs" location="lib" />
<property name="build.dir" value="${basedir}/build/"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="build.test-classes.dir" value="${build.dir}/test-classes"/>
<property name="build.instrumented-classes.dir" value="${build.dir}/instrumented-classes"/>
<property name="build.coverage.dir" value="${build.dir}/coverage"/>
<property name="build.reports.dir" value="${build.dir}/reports"/>
<property name="lib.dir" value="lib"/>
<property name="src" value="src"/>
<property name="src.dir" value="${basedir}/src/java"/>
<property name="test.dir" value="${basedir}/src/test"/>
<!-- Corresponding Jar file for the Jcoverage.-->
<path id="jcoverage.path">
<fileset dir="${lib.dir}">
<include name="jcoverage-1.0.5.jar"/>
<include name="log4j-1.2.9.jar"/>
<include name="bcel-5.1.jar"/>
<include name="jakarta-oro-2.0.7.jar"/>
<include name="java-getopt-1.0.9.jar"/>
</fileset>
</path>
<path id="junit.class.path">
<fileset dir="${lib.dir}">
<include name="ant-junit.jar"/>
<include name="jcoverage-1.0.5.jar"/>
<include name="log4j-1.2.9.jar"/>
<include name="bcel-5.1.jar"/>
<include name="jakarta-oro-2.0.7.jar"/>
<include name="java-getopt-1.0.9.jar"/>
<include name="junit-4.8.1.jar"/>
<include name="selenium-server-standalone-2.20.0.jar"/>
<include name="jetty-repacked-7.6.1.jar"/>
<include name="org.mortbay.jetty-6.0.0alpha2.jar"/>
<include name="httpclient-4.1.2.jar"/>
<include name="httpcore-4.1.3.jar"/>
<include name="httpmime-4.1.2.jar"/>
<include name="selenium-java-2.20.0.jar"/>
<include name="selenium-java-2.20.0-srcs.jar"/>
<include name="logging-selenium-1.2.jar"/>
<include name="poi-3.7-20101029.jar"/>
<include name="robotframework-2.5.4.1.jar"/>
<include name="saxon-8.7.jar"/>
<include name="jxl.jar"/>
</fileset>
</path>
<target name="init">
<!-- <delete dir="${build.dir}"/>
<delete dir="${build.classes.dir}"/>
<delete dir="{build.test-classes.dir}"/>
<delete dir="${build.coverage.dir}"/>
<delete dir="${build.instrumented-classes.dir}"/>
<delete dir="${build.reports.dir}"/> -->
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${build.test-classes.dir}"/>
<mkdir dir="${build.coverage.dir}"/>
<mkdir dir="${build.instrumented-classes.dir}"/>
<mkdir dir="${build.reports.dir}"/>
</target>
<target name="compile" description="compile all classes">
<javac srcdir="${src.dir}" destdir="${build.classes.dir}" failonerror="yes" debug="yes">
</javac>
</target>
<target name="instrument" description="Add jcoverage instrumentation">
<instrument todir = "${build.instrumented-classes.dir}">
<ignore regex="org.apache.log4j.*"/>
<fileset dir="${build.classes.dir}">
<include name="**/*.class"/>
</fileset>
</instrument>
</target>
<target name="test" description="Unit test the application">
<javac srcdir="${test.dir}" destdir="${build.test-classes.dir}" failonerror="yes" debug="yes">
<classpath refid="junit.class.path"/>
<classpath location="${build.classes.dir}"/>
</javac>
<junit fork="yes" dir="${basedir}" errorProperty="test.failed" failureProperty="test.failed">
<!-- note the classpath order, instrumented classes are before the original (uninstrumented) classes. -->
<classpath refid="junit.class.path"/>
<classpath location="${build.instrumented-classes.dir}"/>
<classpath location="${build.classes.dir}"/>
<classpath location="${build.test-classes.dir}"/>
<!-- the instrumented classes reference classes used by the jcoverage runtime. -->
<classpath refid="jcoverage.path"/>
<formatter type="xml"/>
<batchtest todir="${build.reports.dir}" >
<fileset dir="${build.test-classes.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</target>
<taskdef classpathref="jcoverage.path" resource="tasks.properties"/>
<target name="coverage" description="HTML and XML coverage reports can be found in build/coverage">
<report srcdir="${src.dir}" destdir="${build.coverage.dir}"/>
<report srcdir="${src.dir}" destdir="${build.coverage.dir}" format="xml"/>
<echo> jcoverage reports have been generated. The HTML report is ${build.coverage.dir}/index.html The XML report is ${build.coverage.dir}/coverage.xml </echo>
</target>
<target name="all_selenium_tests" description="The Main Target for running all tests">
<antcall target="init"/>
<antcall target="compile"/>
<antcall target="instrument"/>
<antcall target="test"/>
<antcall target="coverage"/>
</target>
</project>
my junit class:
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import com.thoughtworks.selenium.Selenium;
public class sample extends SeleneseTestCase {
static Selenium selenium;
#Before
public void setUp() throws Exception {
SeleniumServer seleniumserver=new SeleniumServer();
seleniumserver.boot();
seleniumserver.start();
selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com");
selenium.start();
}
#Test
public void testjcoverage() throws Exception{
selenium.windowMaximize();
selenium.windowFocus();
selenium.setSpeed("1000");
selenium.open("/results-web/results/authentication/public/login?");
selenium.type("id=USER","labcorp" );
selenium.type("id=PASSWORD","Labcorp" );
selenium.click("css=input.loginButton");
selenium.stop();
}
}
console error:
Buildfile: E:\jcoverage\jcoverage\refactored-param-build.xml
[taskdef] Could not load definitions from resource $(lib.dir). It could not be found.
all_selenium_tests:
[taskdef] Could not load definitions from resource $(lib.dir). It could not be found.
init:
[taskdef] Could not load definitions from resource $(lib.dir). It could not be found.
compiling:
[taskdef] Could not load definitions from resource $(lib.dir). It could not be found.
instrument:
BUILD FAILED
E:\jcoverage\jcoverage\refactored-param-build.xml:25: The following error occurred while executing this line:
E:\jcoverage\jcoverage\refactored-param-build.xml:96: Problem: failed to create task or type instrument
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Total time: 125 milliseconds
please provide a solution.
The error informs you that the javac compiler cannot find the junit jars. Although you specify the junit.class.path as the class path in the compiling ant target, that classpath contains references to the ${libs} property that is not defined anywhere in the build.xml
Also, you should move the property definitions (like lib.dir) before you use them (e.g. before the definition of jcoverage.path that references ${lib.dir})
Note: you can see the classpath used by either calling ant with the -verbose option or calling the <echo>${junit.class.path}</echo> task before the <javac> task
I want to use SVNAnt in eclipse.
But when I run my script, I have this message :
Buildfile: X:\XXX\bin\ant\axis_bujava.xml
[typedef] Could not load definitions from resource org/tigris/subversion/svnant/svnantlib.xml. It could not be found.
testSVNAnt:
BUILD FAILED
X:\XXX\bin\ant\axis_bujava.xml:11: Problem: failed to create task or type svn
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Here is the Ant build file :
<?xml version="1.0"?>
<project default="testSVNAnt" basedir=".">
<path id="path.svnant">
<pathelement location="${basedir}/svnant.jar"/>
<pathelement location="${basedir}/svnClientAdapter.jar"/>
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant" />
<target name="testSVNAnt">
<svn username="username" password="pass">
<checkout url="svn://svnurl" destPath="localpath" revision="HEAD"/>
</svn>
<echo message= "Subversion repository url: ${repository.url}" />
</target>
</project>
The JAR files are of course in basedir. I can't find similar problem nor any solutions.
It finaly work using SvnAnt 1.3.1.
The checkout work fine using this code :
<?xml version="1.0"?>
<project default="main" basedir=".">
<path id="path.svnant">
<pathelement location="${basedir}/svnant.jar" />
<pathelement location="${basedir}/svnClientAdapter.jar" />
<pathelement location="${basedir}/svnjavahl.jar" />
</path>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="path.svnant" />
<target name="main">
<svn>
<checkout url="svn://xxx" destPath="X:/XXX" revision="HEAD" />
</svn>
</target>
</project>
Thanks for help.
You have to use
<taskdef />
instead of <typedef/>
Everything else looks fine.
had the same problem.. replacing the value of "resource" from "org/tigris/subversion/svnant/svnantlib.xml" TO "svntask.properties" did it for me.
sample below: (svn_1.0.0; eclipse juno)
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="D:/.../ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<path id="path.svnant">
<pathelement location="D:/.../lib/svnant.jar" />
<pathelement location="D:/.../lib/svnClientAdapter.jar" />
<pathelement location="D:/.../lib/svnjavahl.jar" />
</path>
<typedef **resource="svntask.properties"** classpathref="path.svnant"/>
<target name="ifAvailable">
<available classpathref="path.svnant" **resource="svntask.properties"**
property="temp"/>
<echo message="SVNAnt is available = ${temp}"></echo>
</target>
OUTPUT>>>>>
Buildfile: D:\...\build.xml
ifAvailable:
[echo] SVNAnt is available = true
BUILD SUCCESSFUL
Total time: 306 milliseconds
Replace
<taskdef resource="org/tigris/subversion/svnant/svnantlib.xml" />
with
<taskdef resource="svntask.properties"/>
The svntask.properties are present in the svnant.jar
I have an Ant script that I would like to execute using a button that I made. The problem now is that I would get an error saying:
BUILD FAILED
X:\eclipseMT\runtime-workspace\testTest\diagram1_Sc2_TestScript.xml:68:
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the
classpath. Perhaps JAVA_HOME does not
point to the JDK. It is currently set
to "C:\Program
Files\Java\jdk1.6.0_12\jre"
I'm pretty sure that my classpath is correct and I can execute the same script using Eclipse internal Ant executor.
This is my ant script:
<property name="src.dir" value="src" />
<property name="test.dir" value="test" />
<property name="test.wstest.dir" value="${test.dir}/wstest" />
<property name="junit.dir" location="X:\eclipseMT\plugins\org.junit_3.8.2.v3_8_2_v20100427-1100"/>
<property name="build.dir" value="build" />
<property name="build.classes.dir" value="${build.dir}/classes" />
<property name="build.test.dir" value="${build.dir}/test"/>
<property name="build.test.classes.dir" value="${build.test.dir}/classes" />
<property name="build.test.data.dir" value="${build.test.dir}/data" />
<property name="build.test.reports.dir" value="${build.test.dir}/reports" />
<property name="dist.dir" value="dist" />
<property name="lib.dir" value="lib" />
<property name="build.debug" value="true" />
<path id="compile.classpath">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
</path>
<path id="test.compile.classpath">
<path refid="compile.classpath" />
<pathelement location="${build.classes.dir}"/>
</path>
<path id="test.classpath">
<path refid="test.compile.classpath" />
<pathelement location="${build.test.classes.dir}"/>
</path>
<target name="init" description="create dir desc">
<mkdir dir="${build.dir}" />
<mkdir dir="${build.classes.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${lib.dir}" />
<copy todir="${lib.dir}">
<fileset dir="${junit.dir}"/>
</copy>
<echo>make init dir done</echo>
</target>
<target name="test-init" depends="init" description="create test dir">
<mkdir dir="${build.test.dir}" />
<mkdir dir="${build.test.classes.dir}" />
<mkdir dir="${build.test.data.dir}"/>
<mkdir dir="${build.test.reports.dir}"/>
<echo>make test init dir done</echo>
</target>
<target name="clean" depends="init, test-init" description="remove previous build">
<delete verbose="true">
<fileset dir="${build.classes.dir}" />
<fileset dir="${build.test.classes.dir}" />
<fileset dir="${build.test.data.dir}" />
<fileset dir="${build.test.reports.dir}" />
<fileset dir="${dist.dir}" />
</delete>
<echo>clean build dir done</echo>
</target>
<target name="compile" depends="clean" description="compile java source">
<javac srcdir="${src.dir}" destdir="${build.classes.dir}" classpath="${build.classes.dir}" debug="on" fork="no" includeAntRuntime="false" />
<echo>compile source done</echo>
</target>
<target name="test-compile" depends="compile, test-init" description="compile test source">
<javac srcdir="${test.wstest.dir}" destdir="${build.test.classes.dir}" debug="true" includeAntRuntime="true">
<classpath refid="test.compile.classpath" />
</javac>
<echo>compile test src done</echo>
</target>
<target name="test-reporting" depends="test-compile" description="report even if fail">
<junit printsummary="false" errorproperty="test.failed" failureproperty="test.failed">
<classpath>
<path refid="test.classpath" />
</classpath>
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest todir="${build.test.data.dir}" unless="testcase">
<fileset dir="${build.test.classes.dir}" />
<!--fileset dir="${build.test.classes.dir}" includes="Sc2TestClient*.class" /-->
</batchtest>
</junit>
<junitreport todir="${build.test.data.dir}">
<fileset dir="${build.test.data.dir}">
<include name="WSTEST-*.xml" />
</fileset>
<report format="frames" todir="${build.test.reports.dir}" />
</junitreport>
<fail if="test.failed">
Test failed. Check ${build.test.reports.dir}
</fail>
</target>
<target name="default" depends="test-reporting" description="test the whole suite">
<echo>all test done</echo>
<tstamp>
<format property="buildTime" pattern="yyyy-MM-dd' 'HH:mm:ss" />
</tstamp>
<echo>build time = ${buildTime}</echo>
</target>
This is my button code:
Project p = new Project();
try {
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.addBuildListener(consoleLogger);
p.fireBuildStarted();
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
p.fireBuildFinished(null);
} catch (Throwable t) {
t.printStackTrace();
p.fireBuildFinished(t);
return false;
}
It's complaining about javac, unable to find javac.. your JAVA_HOME(C:\Program Files\Java\jdk1.6.0_12\jre) is pointing to only "jre" not to java compiler(javac). Set you JAVA_HOME to "C:\Program Files\Java\jdk1.6.0_12\bin"(which has both javac and jre) and it should work. :-)
--Nagesh Palathya
A friend give me a reference to this earlier question: Setting JAVA_HOME when running Ant from Java
The problem basicly is with ant because it has point java.home to 'jre' instead of 'jdk'. It got overwritten everytime ant was call to execute.
The solution is to add:
fork="yes"
to each compilation script and add:
p.setProperty("java.home", "C:\\Program Files\\Java\\jdk1.6.0_26");
to the java execution code.
Hope this help others :D