Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exclude files from jar or war in eclipse

Tags:

eclipse

Is there a way to tell Eclipse to not include specified files, directories, or patterns in a JAR or WAR?

like image 203
Jay Avatar asked Sep 28 '09 20:09

Jay


People also ask

How do I exclude files in eclipse?

Navigate to the file/folder you want to exclude. Right Click -> Resource -> Exclude from build.

How do I export a JAR file from Eclipse without libraries?

To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.


3 Answers

You can specify includes and excludes by opening the Project Properties (alt-enter) then opening Java Build Path and the Source tab. Against each source location there is a little plus sign, click on that then select Included or Excluded then select the Edit... button.

source path screenshot http://help.eclipse.org/ganymede/topic/org.eclipse.jdt.doc.user/gettingStarted/images/qs-WorkingWithExistingLayout26.png

You can then specify multiple patterns for files to be included/excluded. These files will not be processed to the output directory. The patterns follow Ant's wildcard patterns so you have quite fine-grained control over what to include.

include patterns screenshot
(source: eclipse.org)

like image 198
Rich Seller Avatar answered Sep 27 '22 20:09

Rich Seller


We fought with this problem too and didn't find a good standard solution for it in Eclipse WTP.

Hence we added Project Archives to JBoss Tools (http://jboss.org/tools) which allow you to control explicitly via "ant filter sets" what goes in and what goes out of your archive. This archive you can then deploy with the standard WTP mechanism for deployment on the server types supplied by JBoss tools.

We are working on adding similar support back into native Eclipse WTP, but that won't be available until sometime next year.

like image 23
Max Rydahl Andersen Avatar answered Sep 24 '22 20:09

Max Rydahl Andersen


to add to what @Rich_Seller said: in Eclipse Indigo:

  • Select your package from the package view right click, and choose Export.
  • Choose Java -> JAR file from the "select an export destination" tree.
  • Click Next to go to the next page of the wizard.

  • Under the "Select the resource to export" you are presented with a tree view here you can select and deselect components that will be included and excluded from the JAR.

like image 22
windsor Avatar answered Sep 25 '22 20:09

windsor