Reputation: 22983
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.
Upvotes: 5
Views: 2106
Reputation: 33946
<jar destfile="app.jar" basedir="bin" excludes="com/myproject/test/" />
Upvotes: 5
Reputation: 328614
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 into bin-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).
Upvotes: 5