Jay
Jay

Reputation: 27464

exclude files from jar or war in eclipse

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

Upvotes: 10

Views: 23506

Answers (4)

Rich Seller
Rich Seller

Reputation: 84028

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)

Upvotes: 9

windsor
windsor

Reputation: 183

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.

Upvotes: 1

Pablo Jomer
Pablo Jomer

Reputation: 10378

I think including an XML file in another and then removing its visibility in the war file should give you an on off switch.

Upvotes: 0

Max Rydahl Andersen
Max Rydahl Andersen

Reputation: 3890

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.

Upvotes: 1

Related Questions