Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying an alternate name for junit.jar for the ant junit task

Tags:

junit

ant

By default JUnit jars have the version number in the file name, eg junit-4.8.2.jar. The JUnit Ant Task only looks for junit.jar. Is it possible to specify a name based on the standard naming convention. I'd like to do so because I want to reference libs in my local maven repository.

like image 501
Justin Dearing Avatar asked Jan 26 '26 06:01

Justin Dearing


1 Answers

Actually, JUnit task documentation gives you a few alternatives:

Note: You must have junit.jar available. You can do one of:

    Put both junit.jar and ant-junit.jar in ANT_HOME/lib.
    Do not put either in ANT_HOME/lib, and instead include their locations in your CLASSPATH environment variable.
    Add both JARs to your classpath using -lib.
    Specify the locations of both JARs using a <classpath> element in a <taskdef> in the build file.
    Leave ant-junit.jar in its default location in ANT_HOME/lib but include junit.jar in the <classpath> passed to <junit>. (since Ant 1.7)

EDIT

This is what you need.

<junit
   ...
>
  <classpath>
    <pathelement location="/path/to/your/custom/junit-4.8.2.jar""/>
    <path refid="your.other.classpath.dependencies" />
  </classpath>
  ...
</junit>
like image 64
Alexander Pogrebnyak Avatar answered Jan 28 '26 23:01

Alexander Pogrebnyak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!