Reputation: 2248
I'm using Eclipse JUnit integration which includes the JUnit library automatically into my project. The problem is that when I export my project using the Runnable JAR file destination, it includes JUnit.
Is there any way to exclude JUnit (and ideally the tests too) from the exported JAR?
Upvotes: 9
Views: 4105
Reputation: 2248
I've found a solution to the problem by using Ant within Eclipse and the following build.xml:
<project>
<target name="jar">
<jar destfile="out.jar" basedir="bin">
<zipgroupfileset dir="lib" includes="*.jar" />
<manifest>
<attribute name="Main-Class" value="com.example.Main" />
</manifest>
</jar>
</target>
</project>
Upvotes: 1
Reputation: 1715
If you're creating your JAR by right clicking on your project and selecting export and then picking JAR File, you can remove your tests from the export by unchecking your test folder. See this related discussion and this example.
Upvotes: 2
Reputation: 47
You can remove the JUnit package from '.classpath' file.Then export the jar file again
Upvotes: 0