Maven-在构建时包含不同的文件 [英] Maven - Include Different Files at Build Time

查看:89
本文介绍了Maven-在构建时包含不同的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有十个WAR文件,所有文件都具有几乎相同的代码和标记.唯一的区别在于图像,CSS和消息.我遇到了个人档案"的概念,但还没有完全理解它,我不确定这是否可以满足我的需要.

I have ten WAR files, all of which have nearly identical code and markup. The only differences lie in the images, CSS and Messages. I hit on the concept of Profiles but I haven't quite groked it yet and I'm not sure if this can handle what I need it to do.

基本上,我想要一个针对10个不同WAR的具有不同配置文件的基础项目.每当以给定的配置文件开始构建时,它都会进入存储库(本地或我的组织的存储库)并检索CSS,图像和消息文件,并将它们放置在正确的位置,然后再完成此过程.我无法想象这与将JAR文件取出并将其放入WEB-INF库中有很大不同.

Basically, I want a base project with different profiles for the 10 different WARs. Whenever a build is started with a given profile, it goes to a repository (either local or my organization's) and retrieves the CSS, images and messages files and places them in the correct spot before finishing out the process. I can't imagine this is much different than going out and retrieving a JAR file and putting it in WEB-INF lib.

我确定这在左字段中距离不太远,我想尽可能地坚持Maven的最佳表现.任何帮助将不胜感激!

I'm sure this isn't TOO far out in left field and I want to stick to Maven's sweet spot as much as possible. Any help would be appreciated!

推荐答案

如果要使每个项目保持独立,则可以为每个项目分配自己的pom.xml.在每个子项目pom中,为父项目添加一个依赖项.这将导致构建执行叠加"操作,其中子项目中的文件被添加到父项目中(或覆盖父项目中的文件).子项目的依存关系示例:

If you want to keep each of the projects separate, you can give each project its own pom.xml. In each child project pom, add a dependency for the parent project. This will cause the build to do an "overlay" in which files from the child project are added to (or overwrite files in the) parent project. Example dependency for child project:

<dependency>
   <groupId>com.example.app</groupId>
   <artifactId>example</artifactId>
   <version>1.0.0</version>
   <type>war</type>
</dependency>

这篇关于Maven-在构建时包含不同的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆