排除 Ant 中存档的测试类目录
我创建了一个java库项目。二进制文件位于
。测试类位于
。我需要排除我的测试类的存档。所以,我编写了以下代码:
<target depends="build-all" name="build-dist">
<jar destfile="app.jar" basedir="bin" excludes="com/myproject/test/*.class" />
</target>
这工作正常。但在存档中,目录 test
仍然可用。如何删除这个?
谢谢。
I have created a java library project. The binaries are available at <project-dir>/bin
. The test classes are available at <project-dir>/bin/com/myproject/test
. I need to exclude archiving of my test classes. So, I wrote the following code:
<target depends="build-all" name="build-dist">
<jar destfile="app.jar" basedir="bin" excludes="com/myproject/test/*.class" />
</target>
This works fine. But in the archive the directory test
is still available. How to remove this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的解决方案是将测试 Java 和类文件保存在不同的目录中。因此,不要将它们编译到
bin
中,而是在第二步中将它们编译到bin-test
中。这也确保非测试代码看不到测试类(如果您不小心在生产类中导入测试,编译将会失败)。The best solution is to keep test Java and class files in different directories. So instead of compiling them into
bin
, compile them in a second step intobin-test
. This also makes sure that the non-test code can't see test classes (compilation will fail if you accidentally import a test in a production class).