开发者

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

开发者 https://www.devze.com 2023-04-10 17:38 出处:网络
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

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/开发者_StackOverflowwebapp/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?


With Maven, you can make your common project an overlay project declared as dependency, so its resources can be shared in other projects. You will have to use the latest m2eclipse plugin with WTP integration to support overlays in Eclipse IDE.


You can provide your resources files as war project. And then use the Warpath Plugin to make your two project import the war (and its resources).


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号