Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude JUnit from Eclipse exported JAR

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?

like image 624
Simon Morgan Avatar asked Jul 25 '12 01:07

Simon Morgan


2 Answers

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.

like image 71
Tyson Avatar answered Nov 12 '22 00:11

Tyson


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>
like image 41
Simon Morgan Avatar answered Nov 12 '22 02:11

Simon Morgan