Maven 2 如何从父pom部署多个对等Web应用程序

Maven 2 如何从父pom部署多个对等Web应用程序,maven-2,jetty,Maven 2,Jetty,我有一套我管理的网络应用程序,我正试图转移到maven /pom.xml // parent pom webapp1/pom.xml // configured to point to parent webapp2/pom.xml // peer of webapp1 and points to parent. /pom.xml//父pom webapp1/pom.xml//配置为指向父级 webapp2/pom.xml//webapp1的对等项并指向父项。

我有一套我管理的网络应用程序,我正试图转移到maven

/pom.xml // parent pom webapp1/pom.xml // configured to point to parent webapp2/pom.xml // peer of webapp1 and points to parent. /pom.xml//父pom webapp1/pom.xml//配置为指向父级 webapp2/pom.xml//webapp1的对等项并指向父项。 每个webapps都引用父pom,它们目前都有一个jetty-maven插件

我的问题是如何从父pom装载每个WebApp,以便mvn jetty:run在父目录中工作

编辑到anwer:Pascal T 问题不在于我在尝试从根pom运行命令时出错,而在于我不确定如何配置它

例如webapp1/pom.xml 看起来像:

<project>
...
<plugins>
  <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
  </plugin>
</plugins>
...
</project>

...
org.mortbay.jetty

但是,我希望位于webapp1的父目录中,并从父目录运行所有“n”个webapps。因此,具有一个命令行参数,并且可以使用该参数


顺便说一句,如果答案涉及tomcat插件,那就好了。

编辑:我已经完全编辑了我的第一个答案,现在我对OP的期望有了更好的理解

请看,这是一个薄包装器,允许您以标准方式操作JavaEE容器

实际上,Cargo的网站上有一个演示如何使用Cargo Maven2插件来自动启动/停止容器(可能在容器启动时部署一些可部署的组件),这正是我所了解的

我只是不确定从父目录执行此操作是否可行,以及是否需要这样做,或者是否可以从另一个目录执行此操作。我稍后再谈这个问题。让我们首先看看Cargo Maven2插件的设置

在您的情况下,可以从最低配置开始(使用Jetty 5.x,这是Cargo的默认容器):


我只是不确定这是否能与父pom一起工作(我想知道这是否会导致循环依赖性问题),我没有测试它。但就我个人而言,我会把所有这些东西放在一个专门项目的pom中,例如,放在你的webapps的兄弟项目中,而不是放在父pom中。我不认为这是一个真正的大问题,这是一个更好的设置,特别是如果你计划使用货物的

我更了解你想做什么,并编辑了我最初的回答和你的问题相同。这个问题有很好的答案!(从@ Janning)+1,但是考虑一个补充:如果父插件中的配置设置在插件管理部分中,子WebApp只需要声明插件(如在OPS代码片段中)要继承的配置。这避免了任何周期问题。
[...]
<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
    </plugin>
  </plugins>
</build>
[...]
[...]
<plugin>
 <groupId>org.codehaus.cargo</groupId>
 <artifactId>cargo-maven2-plugin</artifactId>
 <configuration>
   <container>
     <containerId>jetty6x</containerId>
     <type>embedded</type>
   </container>
 </configuration>
</plugin>
[...]
<deployables>
  <deployable>
    <groupId>com.mycompany.myproject</groupId>
    <artifactId>myproject-alpha</artifactId>
    <type>war</type>
    <properties>
      <context>optional alpha root context</context>
    </properties>
  </deployable>
  <deployable>
    <groupId>com.mycompany.myproject</groupId>
    <artifactId>myproject-beta</artifactId>
    <type>war</type>
    <properties>
      <context>optional beta root context</context>
    </properties>
  </deployable>
  [...]
</deployables>
$ mvn cargo:start