为ant junit任务指定junit.jar的备用名称
默认情况下,jar在文件名中有版本号,例如junit-4.8.2.jar。只查找junit.jar。是否可以根据标准命名约定指定名称。我之所以这样做是因为我想引用本地存储库中的lib。实际上,JUnit任务文档为您提供了一些备选方案:为ant junit任务指定junit.jar的备用名称,ant,junit,Ant,Junit,默认情况下,jar在文件名中有版本号,例如junit-4.8.2.jar。只查找junit.jar。是否可以根据标准命名约定指定名称。我之所以这样做是因为我想引用本地存储库中的lib。实际上,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 pu
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.jar可用。您可以执行以下操作之一:
将junit.jar和ant-junit.jar放在ant_HOME/lib中。
不要将它们放在ANT_HOME/lib中,而是将它们的位置包含在CLASSPATH环境变量中。
使用-lib将这两个JAR添加到类路径中。
使用生成文件中a中的元素指定两个JAR的位置。
将ant-junit.jar保留在ant_HOME/lib中的默认位置,但将junit.jar包含在传递给的文件中。(自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.Oh。我说的有点密集,但是文档可以更明确一点,junit jar可以被称为junit.jar以外的东西。