ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Tayek <rta...@mediaone.net>
Subject Re: simple ant and junit fails
Date Mon, 07 Jan 2002 00:33:05 GMT
At 01:57 PM 1/6/02 -0500, you wrote:
>Two possible classic issues:
>
>- Did you download the "optional" Ant JAR file that contains the <junit>
>task itself?

nope, duh! that's probably the problem. trying now, (i put the optional jar 
where you said) but it still says the same thing:

D:\usr\ray\java\junit>ant
"C:\jdk1.3.1_01\bin\java" -classpath 
"C:\jdk1.3.1_01\lib\tools.jar;D:\ant\lib\JAKART~1.JAR;D:\ant\lib\JAXP.JAR;D:\ant\lib\CRIMSON.JAR;D:\ant\lib\ANT.JAR;d:\classpath"

-Dant.home="D:\ant"  org.apache.tools.ant.Main
Buildfile: build.xml

init:

compile:

test:

BUILD FAILED

D:\usr\ray\java\junit\build.xml:24: Could not create task of type: junit. 
Common solutions are to use taskdef to declare your task, or, if this is an 
optional task, to put the optional.jar in the lib directory of your ant 
installation (ANT_HOME).

Total time: 0 seconds

using this build.xml:

<project name="MyProject" default="dist" basedir=".">

   <!-- set global properties for this build -->
   <property name="src" value="."/>
   <property name="build" value="build"/>
   <property name="dist"  value="dist"/>
   <property name="test"  value="test"/>

   <target name="init">
     <tstamp/>
     <mkdir dir="${build}"/>
   </target>
   <target name="compile" depends="init">
     <javac srcdir="${src}" destdir="${build}" 
classpath=".;d:/classpath/junit.jar"/>
   </target>

   <target name="test" depends="compile">
<!--
         <classpath>
       <pathelement path="${classpath}"/>
       <pathelement location="junit.jar"/>
     </classpath>
-->
     <junit fork="yes">
       <test name="MainTest"/>
     </junit>
   </target>

   <target name="dist" depends="test">
     <mkdir dir="${dist}/lib"/>
     <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
   </target>

   <target name="clean">
     <delete dir="${build}"/>
     <delete dir="${dist}"/>
   </target>
</project>

>- Do you have junit.jar in your Ant classpath?

not sure how to do this. is the commented example correct? i got the 
junit.jar in the classpath on the compile step by using an attribute of 
<javac...>, but anaict, there is no attribute for <junit...>.

sorry to be so confused about this, but is not clear where all these 
different classpaths go :(

thanks

>----- Original Message -----
>From: "Ray Tayek" <rtayek@mediaone.net>
>To: "Ant Users List" <ant-user@jakarta.apache.org>
>Sent: Sunday, January 06, 2002 1:39 PM
>Subject: simple ant and junit fails
>
>
> > hi, new to ant. tried to add a junit to the sample build.xml in the doc.
> > getting the following when using the build.xml below. the junit stuff
>works
> > ok if i run it by hand using java -cp .;d:/classpath/junit.jar;. MainTest
> >
> >
> > BUILD FAILED
> > D:\usr\ray\java\junit\build.xml:22: Could not create task of type: junit.
> > Common solutions are to use taskdef to declare your task, or, if this is
>an
> > optional task, to put the optional.jar in the lib directory of your ant
> > installation (ANT_HOME).
> >
> >
> > D:\usr\ray\java\junit>ant
> > "C:\jdk1.3.1_01\bin\java" -classpath
> >
>"C:\jdk1.3.1_01\lib\tools.jar;D:\ant\lib\JAXP.JAR;D:\ant\lib\CRIMSON.JAR;D:\
>ant\lib\ANT.JAR;d:\classpath"
> >   -Dant.home="D:\ant"  org.apache.tools.ant.Main
> > Buildfile: build.xml
> > init:
> > compile:
> > test:
> > BUILD FAILED
> > D:\usr\ray\java\junit\build.xml:22: Could not create task of type: junit.
> > Common solutions are to use taskdef to declare your task, or, if this is
>an
> > optional task, to put the optional.jar in the lib directory of your ant
> > installation (ANT_HOME).
> >
> > //build.xml:
> > <project name="MyProject" default="dist" basedir=".">
> >
> >    <property name="src" value="."/>
> >    <property name="build" value="build"/>
> >    <property name="dist"  value="dist"/>
> >    <property name="test"  value="test"/>
> >
> >    <target name="init">
> >      <tstamp/>
> >      <mkdir dir="${build}"/>
> >    </target>
> >    <target name="compile" depends="init">
> >      <javac srcdir="${src}" destdir="${build}"
> > classpath=".;d:/classpath/junit.jar"/>
> >    </target>
> >
> >    <target name="dist" depends="test">
> >      <mkdir dir="${dist}/lib"/>
> >      <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar"
>basedir="${build}"/>
> >    </target>
> >
> >    <target name="test" depends="compile">
> >      <junit fork="yes">
> >        <test name="MainTest" />
> >      </junit>
> >    </target>
> >
> >    <target name="clean">
> >      <delete dir="${build}"/>
> >      <delete dir="${dist}"/>
> >    </target>
> > </project>
> >
> > //Main.java:
> > import java.util.*;
> > class Main
> >          {
> >          public void run(String[] argument) {
> > System.out.println(this.getClass().getName()+" started at "+new Date()); }
> >          public void main(String[] argument) { (new
>Main()).run(argument); }
> >          }
> >
> > //MainTest.java:
> > import junit.framework.*;
> > import junit.swingui.*;
> > public class MainTest extends TestCase
> >          {
> >          public MainTest(String name)
> >                  { super(name); }
> >          public void test1()
> >                  { assertNotNull(new Main()); }
> >          public static Test suite()
> >                  { return new TestSuite(MainTest.class); }
> >          private void run_(String[] argument)
> >                  {
> >                  if(true)
> >                          junit.textui.TestRunner.run(suite());
> >                          else
> >                          {
> >                          String[] string={ getClass().getName() };
> >                          junit.swingui.TestRunner.main(string);
> >                          }
> >                  }
> >          public static void main(String[] argument)
> >                  {
> >                  (new MainTest("run_")).run_(argument);
> >                  }
> >          }
> >
> > ---
> > ray tayek http://home.earthlink.net/~rtayek/
> > orange county java users group http://www.ocjug.org/
> > want privacy? http://www.freedom.net/
> > hate spam? http://samspade.org/ssw/
> >
> >
> > --
> > To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
> >
> >
>
>
>--
>To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

---
ray tayek http://home.earthlink.net/~rtayek/
orange county java users group http://www.ocjug.org/
want privacy? http://www.freedom.net/
hate spam? http://samspade.org/ssw/


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message