3
默认情况下JUnit jars在文件名中具有版本号,例如junit-4.8.2.jar。 The JUnit Ant Task只能查找junit.jar。是否可以根据标准命名约定来指定名称?我想这样做,因为我想在我的本地maven存储库中引用库。为ant junit任务指定junit.jar的替代名称
默认情况下JUnit jars在文件名中具有版本号,例如junit-4.8.2.jar。 The JUnit Ant Task只能查找junit.jar。是否可以根据标准命名约定来指定名称?我想这样做,因为我想在我的本地maven存储库中引用库。为ant junit任务指定junit.jar的替代名称
事实上,JUnit的任务文件给你几个选择:
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)
编辑
这是你所需要的。
<junit
...
>
<classpath>
<pathelement location="/path/to/your/custom/junit-4.8.2.jar""/>
<path refid="your.other.classpath.dependencies" />
</classpath>
...
</junit>
我知道我可以指定junit.jar的路径,但这些选项都不允许我将文件重命名为junit-4.8.2.jar。 – 2011-05-23 20:35:12
' /path/to/junit-4.8.2.jar ' –
2011-05-23 20:46:29
哦,我现在看到了。我有点紧张,但文档可能更明确一点,junit jar可以被称为除junit.jar之外的东西。 – 2011-05-24 13:27:13