3

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 プラグインで言及されている 2 つの引数があります。

以下のコマンドを引数 1 を無効にして実行すると、正常に動作します。

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"

複数の目標を実行中にコマンドラインから 1 つの目標にパラメータを渡す方法は?

4

1 に答える 1

4

複数のコマンドを実行したいので、プラグインを複数回実行したい:

<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>

この構成は複数のことを行います。

  • 呼び出す 2 つのコマンドに対して 2 つの実行を構成します。どちらも正しい<argument>属性で構成されています。
  • グローバル構成要素内のこれら 2 つの共通構成を除外します。この場合、これは単なる実行可能ファイルです。

ただし、重要な要素があります。単一のビルドで両方を実行する場合は、これらの実行をフェーズにバインドする必要があります。例として、それらをにバインドするとverify、呼び出しmvn verifyによって 2 つの実行が呼び出されます。

于 2016-01-08T22:08:23.457 に答える