【发布时间】:2018-11-13 19:41:19
【问题描述】:
我希望我的“预集成测试”阶段是以下目标的执行,按照这个特定的顺序。
PHASE : 预集成测试
- 获取一个 spring boot jar (maven-dependency-plugin:copy)
- get-a-port (build-helper-maven-plugin:reserve-network-port)
- 显示端口(maven-antrun-plugin:run #1)
- 启动服务器(exec-maven-plugin)
- 等待启动(maven-antrun-plugin:run #2)
有没有办法使用 Maven 3 来做到这一点?
我面临的问题是 "maven-antrun-plugin:run" 1 & 2 将始终一个接一个地运行,因为它们是在同一个插件元素中定义的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>display-port</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Displaying value of 'tomcat.http.port' property</echo>
<echo>[tomcat.http.port] ${tomcat.http.port}</echo>
</target>
</configuration>
</execution>
<execution>
<id>wait-for-startup</id>
<phase>pre-integration-test</phase>
<configuration>
<target>
<sleep seconds="10" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
现在,我发现这样做的唯一方法是在 pom 文件中复制“maven-antrun-plugin:”插件元素。 但这给了我一个警告
'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration
对于这个问题的范围,我不是在寻找解决方法,例如更改“显示端口”或“等待启动”的插件,或者更改目标的阶段。
我只是想了解我正在尝试做的事情是否可行。
【问题讨论】:
-
与tomcat/display port相关的Spring Boot需要做哪些测试?此外,您知道 spring-boot-maven-plugin:run 吗?我不明白你为什么要这样做
dependency:copy? -
无论我想做什么,问题都是关于 Maven 订购。我引用自己的话:“对于这个问题的范围,我不是在寻找解决方法,例如更改“显示端口”或“等待启动”的插件,或者更改目标。”