我正在尝试在maven中执行多个目标
我的Pom.xml就像
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<testFilesIncluded>
<jMeterTestFile>${mytest}</jMeterTestFile>
</testFilesIncluded>
<propertiesUser>
<hostName>${myhost}</hostName>
<port>${myport}</port>
<protocol>${myprotocol}</protocol>
</propertiesUser>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.codecentric</groupId>
<artifactId>jmeter-graph-maven-plugin</artifactId>
<version>0.1.0</version>
<executions>
<execution>
<id>create-graphs</id>
<goals>
<goal>create-graph</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>runcommand</id>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>**com.lazerycode.jmeter:jmeter-maven-plugin:1.4.1:jmeter@jmeter-tests -Dmyhost=hix.qa.com -Dmyport=80 -Dmyprotocol=http -Dmythreads=5 -Dmyloopcount=20 -Dmyrampup=1 -Dmytest=ScreenerAPI.jmx**</argument>
<argument>de.codecentric:jmeter-graph-maven-plugin:0.1.0:create-graph@create-graphs</argument>
</arguments>
</configuration>
</plugin>
</plugins>
我在org.codehaus插件中提到了两个参数。
运行带有argument1的以下命令可以正常工作。
mvn org.codehaus.mojo:exec-maven-plugin:1.4.0:exec@runcommand
但是当我运行两个命令时,启用了参数会给我一个错误
无法执行目标com.lazerycode.jmeter:jmeter-maven-plugin:1.4.1:jmeter @ jmeter-tests -Dmyhost = hix.qa.com -Dmyport = 80 -Dmyprotocol = http -Dmythreads = 5 -Dmyloopcount = 20 -Dmyrampup = 1 -Dmytest = ScreenerAPI.jmx
使用cmd行中的参数单独运行goal1和goal2可以正常工作。
mvn de.codecentric:jmeter-graph-maven-plugin:0.1.0:create-graph@create-graphs
mvn com.lazerycode.jmeter:jmeter-maven-plugin:1.4.1:jmeter@jmeter-tests "-Dmyhost=hix.qa.com" "-Dmyport=80" "-Dmyprotocol=http" "-Dmythreads=5" "-Dmyloopcount=20" "-Dmyrampup=1" "-Dmytest=ScreenerAPI.jmx"
如何在运行多个目标时从命令行将参数传递给一个目标?
答案 0 :(得分:3)
您想要执行多个命令,因此您希望拥有多个executions插件:
stdout
此配置可以执行多项操作:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<!-- First execution executing jmeter-maven-plugin -->
<execution>
<id>runcommand1</id>
<goals>
<goal>exec</goal>
</goals>
<phase> <!-- you need to write a phase here --> </phase>
<configuration>
<arguments>
<argument>com.lazerycode.jmeter:jmeter-maven-plugin:1.4.1:jmeter@jmeter-tests -Dmyhost=hix.qa.com -Dmyport=80 -Dmyprotocol=http -Dmythreads=5 -Dmyloopcount=20 -Dmyrampup=1 -Dmytest=ScreenerAPI.jmx</argument>
</arguments>
</configuration>
</execution>
<!-- Second execution executing jmeter-graph-maven-plugin -->
<execution>
<id>runcommand2</id>
<goals>
<goal>exec</goal>
</goals>
<phase> <!-- you need to write a phase here --> </phase>
<configuration>
<arguments>
<argument>de.codecentric:jmeter-graph-maven-plugin:0.1.0:create-graph@create-graphs</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<executable>mvn</executable>
</configuration>
</plugin>
属性。但是有一个重要的因素:如果你想在一个版本中执行这两个执行,那么这些执行需要绑定到一个阶段。例如,如果将它们绑定到<argument>
,则调用verify
将调用两次执行。