如何使jetty-maven-plugin部署从存储库中检索的战争?

Joh*_*ohn 4 maven-2 soapui pom.xml maven-assembly-plugin maven-jetty-plugin

我正在为一个大小合适的Web项目设置集成测试模块.集成测试模块与Web项目本身是分开的,它有自己的pom.

我们的想法是使用maven-soapui-plugin发送请求并验证响应.设置soapui-plugin并不麻烦.但是,我在弄清楚如何告诉jetty-maven-plugin从远程存储库部署战争时遇到了麻烦.

如果我理解正确,jetty-maven-plugin有一个名为'<webApp>/<webApp>'的属性,它允许我指定要部署的war文件.问题是war文件本身不存在war文件.

我听说我可以使用maven程序集插件通过项目artifactId从存储库中检索战争,但我还没弄清楚我将如何去做.

这是我想要的总结:

  1. 从存储库等中检索特定的战争,例如通过其artifactId.
  2. 将此战争部署到jetty-maven-plugin(目标部署 - 战争?)
  3. 获取maven-soapui-plugin来运行测试并在集成测试阶段报告结果.

我很确定我已经完成了第3步,但我不确定如何实现第1步和第2步.

任何帮助是极大的赞赏

Pas*_*ent 6

也许可以使用dependency:copy检索战争,拆开包装并得到整个事情使用Maven插件码头工作,但这将是哈克还挺难看.一个更清洁的解决方案是使用Maven Cargo插件,这是我的建议.下面是一个示例POM,展示了如何使用其坐标检索WAR工件以及如何使用Cargo在嵌入式Jetty容器上部署它:

<dependencies>
  <dependency>
    <groupId>war group id</groupId>
    <artifactId>war artifact id</artifactId>
    <type>war</type>
    <version>war version</version>
  </dependency>
  ...
</dependencies>
...
<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <configuration>
        <!-- Container configuration -->
        <container>
          <containerId>jetty6x</containerId>
          <type>embedded</type>
        </container>
        <!-- Configuration to use with the container or the deployer -->
        <configuration>
          <deployables>
            <deployable>
              <groupId>war group id</groupId>
              <artifactId>war artifact id</artifactId>
              <type>war</type>
              <properties>
                <context>war context</context>
              </properties>
            </deployable>
          </deployables>
        </configuration>
        <!-- Don't wait, execute the tests after the container is started -->
        <wait>false</wait>
      </configuration>
      <executions>
        <execution>
          <id>start-container</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>start</goal>
          </goals>
        </execution>
        <execution>
          <id>stop-container</id>
          <phase>post-integration-test</phase>
          <goals>
            <goal>stop</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  </plugins>
  ...
</build>
Run Code Online (Sandbox Code Playgroud)

最后,只需绑定integration-test相位上的soapui插件即可.


bla*_*lor 5

我正在做同样的事情,约翰,但我对 Jetty 插件采取了不同的方法。我认为最终的结果是一样的。我正在开发一个集成测试套件来针对多个 Web 服务 WAR 运行。我dependency:copypackage阶段中使用,然后<contextHandler/>配置了一个列表maven-jetty-plugin

\n\n
<project>\n    \xe2\x80\xa6\n    <build>\n        <plugins>\n            <plugin>\n                <groupId>org.apache.maven.plugins</groupId>\n                <artifactId>maven-dependency-plugin</artifactId>\n                <executions>\n                    <execution>\n                        <id>copy-wars</id>\n                        <phase>package</phase>\n                        <goals>\n                            <goal>copy</goal>\n                        </goals>\n\n                        <configuration>\n                            <outputDirectory>${project.build.directory}/wars-to-be-tested</outputDirectory>\n                            <stripVersion>true</stripVersion>\n                            <artifactItems>\n                                \xe2\x80\xa6\n                                <artifactItem>\n                                    <groupId>groupId</groupId>\n                                    <artifactId>artifactId</artifactId>\n                                    <version>version</version>\n                                    <type>war</type>\n                                </artifactItem>\n                                \xe2\x80\xa6\n                            </artifactItems>\n                        </configuration>\n                    </execution>\n               </executions>\n            </plugin>\n\n            <plugin>\n                <groupId>org.mortbay.jetty</groupId>\n                <artifactId>jetty-maven-plugin</artifactId>\n                <version>7.1.3.v20100526</version>\n                <configuration>\n                    \xe2\x80\xa6\n                    <contextHandlers>\n                        \xe2\x80\xa6\n                        <contextHandler implementation="org.mortbay.jetty.plugin.JettyWebAppContext">\n                            <war>${project.build.directory}/wars-to-be-tested/artifactId.war</war>\n                            <contextPath>/context</contextPath>\n                        </contextHandler>\n                    </contextHandlers>\n                </configuration>\n\n                <executions>\n                    <execution>\n                        <id>start-jetty</id>\n                        <phase>pre-integration-test</phase>\n                        <goals>\n                            <goal>stop</goal>\n                            <goal>run</goal>\n                        </goals>\n                        <configuration>\n                            <scanIntervalSeconds>0</scanIntervalSeconds>\n                            <daemon>true</daemon>\n                        </configuration>\n                    </execution>\n\n                    <execution>\n                        <id>stop-jetty</id>\n                        <phase>post-integration-test</phase>\n                        <goals>\n                            <goal>stop</goal>\n                        </goals>\n                    </execution>\n                </executions>\n            </plugin>\n        </plugins>\n    </build>\n</project>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我更愿意将各种战争声明为依赖项,然后用于dependency:copy-dependencies设置wars-to-be-tested目录;这将使 Maven 反应器知道它需要在将要测试的战争结束后构建我的集成测试模块。我遇到的问题是 Jetty 插件认为我想“覆盖”所有列为依赖项的战争(这个概念在我看到它发生之前我从未听说过);我不知道允许这种情况发生是否会造成任何伤害,但我不喜欢它,所以我就采用了这种dependency:copy方法。

\n\n

这只是使用 Cargo 的一种替代方法。我会自己研究这个问题,但我只是想提供另一种方法。

\n