Edm*_*984 21 maven-3 maven exec-maven-plugin
我正在尝试在自定义容器的顶部执行我的应用程序部署的集成品尝.由于我的容器是自定义的,我不能使用Maven Cargo插件来设置容器.
我的容器:
我的问题是我必须在不同的进程中运行我的容器,因为它需要在我的测试执行时继续运行.此外,我的测试中有一个API,让我等待容器准备就绪(一种带超时的查找).
我已将以下行添加到我的pom.xml中
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>scripts/start-agent.bat</executable>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这将调用一个仅包含的脚本
开始调用gs-agent.bat
然而,mvn exec插件被卡住了,我的测试没有运行.根据我如何从Java应用程序运行批处理文件中的建议?,我已经修改了我的pom.xml如下:
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/C</argument>
<argument>start</argument>
<argument>gs-agent.bat</argument>
</arguments>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但这似乎没有解决问题:

eis*_*eis 19
exec插件无法做到这一点,我也发现了它的问题:http://jira.codehaus.org/browse/MEXEC-87
在上面链接的jira问题中,提到了一个具有该功能的exec插件的fork和链接.
除此之外,我认为你暂时需要使用antrun-plugin.
以下是从工作配置中获取并运行的示例mvn verify.这需要在<plugins>,而不是<pluginManagement>(exec可以驻留在插件管理中就好了).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<configuration>
<target>
<exec executable="cmd.exe"
spawn="true">
<arg value="/c"/>
<arg value="D:\myfolder\test.bat"/>
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
请注意,spawn="true"如果您不希望执行阻止,这是关键,如问题中指定的那样.如果您确实希望它立即阻止并查看输出,请将其设置为false.
请参阅此问题:如何从Java应用程序运行批处理文件?
Windows批处理文件不可执行.它们是由cmd可执行文件运行的脚本.
更多信息
Exec插件源代码显示Apache Commons Executor用于实际执行命令行.
你可以在这里做很多阅读,例如Apache Commons Executor文档及其JIRA问题,但简短版本是:这不是"Maven"的问题,它是平台依赖性的问题.执行exec()命令.
我之前已经解决了这类问题,我总是设计的解决方案是将.bat脚本解构为实际命令并直接从exec插件启动它,而不是调用脚本.
| 归档时间: |
|
| 查看次数: |
35521 次 |
| 最近记录: |