将另一个项目的资源文件发布到上下文路径而不是eclipse中的jar文件
我有一些常见的资源文件,例如基本 JS、CSS 文件和 HTML 文件,这些文件将由两个 Maven 项目/模块使用。我已将这些文件移至一个公共项目 &将其作为两个项目的依赖项包含在内。公共项目作为 jar 文件发布,我不想从 jar 文件提供文件(使用 ClassLoader 的东西)。
有没有办法将公共项目资源按原样复制到实际项目上下文文件夹中,例如:
COMMON_PROJECT/src/main/webapp/login.html
到WEBAPP1/src/main /web应用程序
COMMON_PROJECT/src/main/webapp/login.html
到 WEBAPP2/src/main/webapp
实际要求:我不想将公共文件发布为 jar 文件,因为稍后这些文件将从 war 文件中移出并直接放置在 Ngnix 服务器中。有人可以从这个角度提供更好管理的指导方针吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Maven,您可以将常用项目声明为 覆盖项目作为依赖,因此它的资源可以在其他项目中共享。您必须使用最新的 m2eclipse 插件与 WTP 集成来支持覆盖 Eclipse IDE。
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.
您可以将资源文件作为 war 项目提供。
然后使用 Warpath 插件 使您的两个项目导入 war (及其资源)。
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).
我尝试使用 @Eugene Kuleshov 回答的插件,但该插件与最新的 m2e 版本存在依赖性问题。
经过一番搜索, m2e-wtp 插件(更新站点:
http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/
)支持确切的网络覆盖功能。这需要最新的 m2e 插件 (1.0 +)(更新站点:
http://download.eclipse.org/technology/m2e/releases/
)安装完
m2e-wtp
后,我们需要安装buildhelper
生命周期映射器来自m2e
目录窗口>首选项>梅文>发现>打开目录
生命周期映射> buildhelper
仅在这些
m2e
和m2e-wtp
插件的最新版本中,支持 weboverlays(我们在Project 属性中看到的旧 Maven 构建器> Builders
无法做到这一点)但是,使用正常的 Maven 构建,覆盖可以开箱即用。默认情况下,当我们 Maven 构建项目时,Maven war 插件(不是 eclipse 插件)会将资源文件从依赖项 war(也是 jar)复制到上下文路径中。如果我们想要对此过程进行更多控制(例如某些排除),则需要覆盖。
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 thebuildhelper
lifecycle mapper fromm2e
catalogWindow > Preferences > Maven > Discovery > Open Catalog
Lifecycle mappings > buildhelper
Only in the latest versions of these
m2e
andm2e-wtp
plugins, weboverlays are supported (the old Maven builder we see in theProject 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.