ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <>
Subject Re: Ant + JUnit problems
Date Tue, 12 Oct 2004 20:52:25 GMT
Hi Greg,
to be honest, I hardly see any reason of *not* placing
junit.jar in $ANT_HOME/lib as it saves a lot of fuss.
Anyway, here are some more ways, that prevents from
moving files in and out distribution:

1) You can place junit.jar (and all third party jars
required by ant optional task) in user's home
directory and Ant will pick them correctly. No need to
move anything in $ANT_HOME/lib.
2) You can place junit.jar in any directory, say
C:/thirdpartyJars and then pass that directory as a
parameter of -lib option to ant starting script:

ant -lib C:/thirdpartyJars test

Again no need to move anything in $ANT_HOME/lib.

3) (Requires moving a file out of ant distribution) 
> - The documentation says, "You must have junit.jar
> and the class files for
>   the <junit> task in the same classpath." 

IMHO "in the same classpath" means "loaded by same
classloader". So you can do this: place junit.jar in
any directory say C:\thirdpartyJars and then move
ant-junit jar from $ANT_HOME/lib to C:\thirdpartyJars
and then redefine junit task in this way:
<path id="junit.cp">
   <fileset dir="C:\thirdpartyJars">
      <include name="junit.jar"/>
      <include name="ant-junit.jar"/>			
<taskdef name="junit" 	

Here the jars are loaded by one and the same
classloader and so it works. but in most cases <junit>
is used with <junitreport> task that is defined in
ant-junit.jar, so I should taskdef it too and I am too
lazy to do it. Anyway, it is a good exercise in
classpaths and classloading; you can even ask your
students to extend the corresponding entry in Ant's
FAQ and explain it thoroughly :)).

HTH Ivan

P.S. I started my career as a teaching assistant in
Computer Science courses, and I have also wonder a lot
how to explain and resolve classpath issues in my
lessons, so I wish you great luck with your

> '' includes both
>   'junit.jar' and my generated class files, but not
> ant-junit.jar.  So,
>   re-set CLASSPATH to
>   Doesn't make a difference.
> - Try copying ant-junit.jar to my 'lib' folder, so
> that it will be
>   included in my ''.  No good; remove it.
> - As I said above, I do *not* want to recommend to
> students that they
>   start moving files around in third-party
> installations, since it
>   quickly leads to maintenance nightmares.  However,
> let's see if copying
>   'junit.jar' into '$ANT_HOME/lib' makes a
> difference: yup, that makes my
>   tests run.  Delete it again and keep going.
> - What about removing 'ant-junit.jar' from
> '$ANT_HOME/lib' as the FAQ
>   entry at:
>   seems to suggest?  (Right at the bottom, under the
> heading "Using The
>   Second Option with Ant 1.6 and later").  This
> leaves me with 'junit.jar'
>   and 'ant-junit.jar' in my 'lib' directory, and
> neither in '$ANT_HOME/lib'.
>   Nope, doesn't work.
> As I said in the intro, my goal isn't just to get
> this to work, but to get
> it to work in a way I feel comfortable showing to
> undergraduate students.
> Advice would be welcome.
> Thanks,
> Greg
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
Declare Yourself - Register online to vote today!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message