简体   繁体   English

使用Maven从一个项目产生多次战争

[英]Generate multiple War from one project with Maven

I have developed a WebApp (that i'll call W)used in conjunction with 3 different applications (A,B and C). 我开发了一个WebApp(我称为W),它与3种不同的应用程序(A,B和C)结合使用。

W needs different dependencies based on which application it is used in conjunction with(for example different versions of Oracle Coherence). W需要不同的依赖关系,具体取决于它与哪个应用程序一起使用(例如,不同版本的Oracle Coherence)。

At the moment I use 3 maven projects with the exact same code (the code from W) with different configuration files and different dependencies. 目前,我使用3个maven项目,它们具有完全相同的代码(来自W的代码),具有不同的配置文件和不同的依赖关系。

I would like to be able to generate my 3 wars without having 3 times the very same code (the code from W) in 3 different projects. 我希望能够在3个不同的项目中没有3次相同代码(来自W的代码)的情况下进行3次战争。

Is it possible?Is it possible with maven? 有可能吗? Thanks in advance. 提前致谢。

If these projects have anything in common, it makes most sense to have 4 war projects: 如果这些项目有共同点,那么拥有四个战争项目是最有意义的:

  • one for the common part, with all the common classes and resources 一个用于公共部分,具有所有公共类和资源
  • one for each deviation 每个偏差一个

Then you can use WAR Overlays to embed the common part in each project. 然后,您可以使用WAR叠加层将公用部分嵌入每个项目中。

IMHO this is better than trying to put all the dependencies into one pom, using profiles or other tricks. 恕我直言,这比尝试使用配置文件或其他技巧将所有依赖项放入一个pom更好。

BTW this question is very similar to yours. 顺便说一句, 这个问题与您的非常相似。

Why not create a library project and set this as dependency to your web applications? 为什么不创建一个库项目并将其设置为对Web应用程序的依赖?

So you have one code base only (in the library) and the configuration is in the 3 war projects. 因此,您只有一个代码库(在库中),并且配置在3个war项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM