exclude files from jar or war in eclipse

前端 未结 4 1853
别那么骄傲
别那么骄傲 2020-12-01 22:01

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

相关标签:
4条回答
  • 2020-12-01 22:03

    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.


    (source: eclipse.org)

    0 讨论(0)
  • 2020-12-01 22:08

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

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-01 22:29

    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.

    0 讨论(0)
提交回复
热议问题