Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse removing a test folder from the build path

Tags:

java

eclipse

I have two folders, src and test (for junit). When I export, the test folder gets packaged into the jar with JUnit which I don't want. I went to Build Path for the project an tried to deselect the 'test' folder in 'order of export' but it does not allow me to deselect it.

I then tried exclude the folder in the 'soruces' tab using * (everything), but then I got an error when I tried to export.

How do I exclude my test folder from the export?

like image 342
jax Avatar asked Dec 07 '10 06:12

jax


People also ask

How do I delete a referenced library in Eclipse?

Right click on project, goto Build Path -> Configure Build Path, then goto the Libraries Tab, select the Referenced library and click remove.

How do I remove a classpath library?

On the Propertis dialog, select the Java Build Path from the list of properties. On the Java Build Path part of the dialog, select the Libraries tab. Find the entry in the list of libraries called Shared Library [<library-name>], and then select it. Click Remove.


2 Answers

I have just did it and it worked fine for me. Here is what I did.

  1. right click on my project; choose Export
  2. Choose Java/JAR file, Next.
  3. List of projects in the workspace appears. Now expand the sub-tree of interesting project and select src folder only. The test folder should not be selected.
  4. continue creating jar file and see the result.
like image 116
AlexR Avatar answered Oct 12 '22 10:10

AlexR


I also met the same problem and eventually resolved it by moving the tests into a separate Eclipse project, placing the original project as a build path dependency of the test project. I know this is rather a workaround than a desired direct solution of the problem, but to me it looks like the best approximation to the desired solution:

  • test code separation achieved
  • possibility to test package-private class members is still there
  • no test classes exported to jars or dependent projects

The only drawback is that an extra project needs to be created.

like image 30
Coryffaeus Avatar answered Oct 12 '22 10:10

Coryffaeus