Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Ant newbie
Ant newbie [message #28587] Sun, 20 February 2005 12:06 Go to next message
Eclipse UserFriend
Originally posted by: grape94.hotmail.com

Hi

I want to start using Ant and JUnit with eclipse.

I found a general article about using Ant and JUnit
( http://www-106.ibm.com/developerworks/java/library/j-ant/ind ex.html),
which has an example build.xml, but when I open it in Eclipse, the editor
findes following 2 errors:
The default target runtests does not exist in this project. (line 1)
The markup in the document following the root element must be wellformed.
(line 2)

Unfortunately I don't know enough about Ant to make any sense of these
mesages, except that maybe the xml formate is incompatible...?? And if so
how do I fix it...:)

The ant build file is as follows:
<project name="Sample.Project" default="runtests" basedir="."/>
<property name="app.name" value="sample" />
<property name="build.dir" value="build/classes" />

<target name="JUNIT">
<available property="junit.present"
classname="junit.framework.TestCase" />
</target>

<target name="compile" depends="JUNIT">
<mkdir dir="${build.dir}"/>
<javac srcdir="src/main/" destdir="${build.dir}" >
<include name="**/*.java"/>
</javac>
</target>

<target name="jar" depends="compile">
<mkdir dir="build/lib"/>
<jar jarfile="build/lib/${app.name}.jar"
basedir="${build.dir}" includes="com/**"/>
</target>

<target name="compiletests" depends="jar">
<mkdir dir="build/testcases"/>
<javac srcdir="src/test" destdir="build/testcases">
<classpath>
<pathelement location="build/lib/${app.name}.jar" />
<pathelement path="" />
</classpath>
<include name="**/*.java"/>
</javac>
</target>

<target name="runtests" depends="compiletests" if="junit.present">
<java fork="yes" classname="junit.textui.TestRunner"
taskname="junit" failonerror="true">
<arg value="test.com.company.AllJUnitTests"/>
<classpath>
<pathelement location="build/lib/${app.name}.jar" />
<pathelement location="build/testcases" />
<pathelement path="" />
<pathelement path="${java.class.path}" />
</classpath>
</java>
</target>
</project>
Re: Ant newbie [message #28591 is a reply to message #28587] Sun, 20 February 2005 14:31 Go to previous message
Eclipse UserFriend
Originally posted by: grape94.hotmail.com

Juliet wrote:

> Hi

> I want to start using Ant and JUnit with eclipse.

> I found a general article about using Ant and JUnit
> ( http://www-106.ibm.com/developerworks/java/library/j-ant/ind ex.html),
> which has an example build.xml, but when I open it in Eclipse, the editor
> findes following 2 errors:
> The default target runtests does not exist in this project. (line 1)
> The markup in the document following the root element must be wellformed.
> (line 2)

> Unfortunately I don't know enough about Ant to make any sense of these
> mesages, except that maybe the xml formate is incompatible...?? And if so
> how do I fix it...:)

> The ant build file is as follows:
> <project name="Sample.Project" default="runtests" basedir="."/>
> <property name="app.name" value="sample" />
> <property name="build.dir" value="build/classes" />

> <target name="JUNIT">
> <available property="junit.present"
> classname="junit.framework.TestCase" />
> </target>

> <target name="compile" depends="JUNIT">
> <mkdir dir="${build.dir}"/>
> <javac srcdir="src/main/" destdir="${build.dir}" >
> <include name="**/*.java"/>
> </javac>
> </target>

> <target name="jar" depends="compile">
> <mkdir dir="build/lib"/>
> <jar jarfile="build/lib/${app.name}.jar"
> basedir="${build.dir}" includes="com/**"/>
> </target>

> <target name="compiletests" depends="jar">
> <mkdir dir="build/testcases"/>
> <javac srcdir="src/test" destdir="build/testcases">
> <classpath>
> <pathelement location="build/lib/${app.name}.jar" />
> <pathelement path="" />
> </classpath>
> <include name="**/*.java"/>
> </javac>
> </target>

> <target name="runtests" depends="compiletests" if="junit.present">
> <java fork="yes" classname="junit.textui.TestRunner"
> taskname="junit" failonerror="true">
> <arg value="test.com.company.AllJUnitTests"/>
> <classpath>
> <pathelement location="build/lib/${app.name}.jar" />
> <pathelement location="build/testcases" />
> <pathelement path="" />
> <pathelement path="${java.class.path}" />
> </classpath>
> </java>
> </target>
> </project>


Problem solved :) /> on line 1 should have been >
Previous Topic:Configuring user library with relative paths
Next Topic:jdbc with CDC
Goto Forum:
  


Current Time: Wed Jul 03 23:27:49 GMT 2024

Powered by FUDForum. Page generated in 0.04652 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top