Search code examples
javaeclipsemaveneclipse-wtp

publishing the resource files of another project to context path instead of jar file in eclipse


I've few common resource files, like base JS, CSS files and HTML files and those files will be used by two maven projects/modules. I've moved these files to a common project & included that as a dependency to both projects. The common project is published as a jar files and I don't want to serve the files from jar file (using ClassLoader' stuff).

Is there a way to make the common project resource copied as it is into the actual project context folder, like:

COMMON_PROJECT/src/main/webapp/login.html to WEBAPP1/src/main/webapp COMMON_PROJECT/src/main/webapp/login.html to WEBAPP2/src/main/webapp

Actual requirement: I don't want to publish the common files as a jar file because later those files will be moved out of war file and placed directly in Ngnix server. Can some provide the guidelines for better management in this perspective?


Solution

  • I tried with the plugin answered by @Eugene Kuleshov, but the plugin is having dependency issues with the latest m2e version.

    After some search, m2e-wtp plugin (update site: http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/) is supporting the exact web-overlay feature.

    This requires the latest m2e plugin (1.0 +) (update site: http://download.eclipse.org/technology/m2e/releases/)

    After installing the m2e-wtp, we need to install the buildhelper lifecycle mapper from m2e catalog

    • Window > Preferences > Maven > Discovery > Open Catalog
    • install Lifecycle mappings > buildhelper

    Only in the latest versions of these m2e and m2e-wtp plugins, weboverlays are supported (the old Maven builder we see in the Project properties > Builders is not capable of doing that)

    However, with the normal Maven build, overlays work out of the box. By default, Maven war plugin (not eclipse plugin) will copy the resource files from dependency war (also jar) in to the context path when we Maven build the project. overlay are required if we want more control on this process, like some excluding.