如何使Jetty-Maven-Plug部署从存储库检索的战争? [英] How to make jetty-maven-plugin deploy a war that is retrieved from a repository?
问题描述
我正在为一个大小合适的Web项目设置一个集成测试模块.集成测试模块与Web项目本身分离,并且具有自己的pom.
I'm setting up an integration test module for a good sized web project. The integration test module is separated from the web project itself, and it has it's own pom.
这个想法是使用maven-soapui-plugin发送请求并验证响应.设置soapui插件很简单.但是,我在弄清楚如何告诉jetty-maven-plugin从远程存储库部署战争方面遇到了麻烦.
The idea is to use the maven-soapui-plugin to send requests and verify the response. Setting up the soapui-plugin is no hassle. However, I'm having trouble with figuring out how I can tell the jetty-maven-plugin to deploy a war from a remote repository.
如果我正确理解,jetty-maven-plugin具有一个名为< webApp>/< webApp>"的属性,该属性使我可以指定要部署的war文件.问题是模块本身不存在war文件.
If I have understood correctly, the jetty-maven-plugin has a property called '<webApp>/<webApp>' which lets me specify the war file to deploy. The problem is that the war file is not present in the module itself.
我听说我可以使用maven程序集插件通过项目artifactId从存储库中检索战争,但是我还没有弄清楚该怎么做.
I have heard that I can use the maven assembly plugin to retrieve the war from a repository via the projects artifactId, but I am yet to figure out how I would go about doing so.
以下是我想要的摘要:
- 例如通过其artifactId从存储库等中检索特定战争.
- 将这场战争部署到jetty-maven-plugin(目标为deploy-war?)
- 获取maven-soapui-plugin以运行测试并将结果报告回集成测试阶段.
我很确定我已经涵盖了第3步,但是我不确定如何实现第1步和第2步.
I am pretty sure I've got step 3 covered, but I am very unsure how to achieve step 1 and 2.
非常感谢您的帮助
推荐答案
也许可能使用dependency:copy
来检索战争,将其解压缩并使整个事情与行家一起工作码头插件,但这会很hacky,有点丑陋.较干净的解决方案是使用 Maven Cargo插件,这是我的建议.下面是一个示例POM,显示了如何使用其坐标检索WAR工件以及如何使用Cargo将其部署在嵌入式Jetty容器上:
It is maybe possible to use dependency:copy
to retrieve the war, unpack it and to get the whole thing working with the maven jetty plugin, but this would be hacky and kinda ugly. A cleaner solution would be to use the Maven Cargo plugin and this is my suggestion. Below, a sample POM showing how to retrieve a WAR artifact using its coordinates and how to deploy it on an embedded Jetty container using Cargo:
<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>
最后,只需在integration-test
阶段绑定soapui插件即可.
Finally, just bind the soapui plugin on the integration-test
phase.
这篇关于如何使Jetty-Maven-Plug部署从存储库检索的战争?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!