如何在单个pom.xml文件中使用Maven执行多个命令提示符命令

4
我希望在单个pom.xml文件中使用maven运行多个命令提示符命令。我该如何做?
例如:我有2个要执行的命令。我正在使用exec-maven-plugin来执行第一个命令。 以下是我pom.xml文件的一部分,用于执行第一个命令:
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <id>load files</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>

        <executable>windchill</executable>
        <arguments>
            <argument>wt.load.LoadFileSet</argument>
            <argument>-file</argument>
            <argument>${basedir}/fileSet.xml</argument>
            <argument>-UNATTENDED</argument>
            <argument>-NOSERVERSTOP</argument>
            <argument>-u</argument>
            <argument>wcadmin</argument>
            <argument>-p</argument>
            <argument>wcadmin</argument>
        </arguments>

    </configuration>
</plugin>

构建已经成功。 是否可以在相同的pom.xml文件中执行另一个命令,就像上面那样?我无法做到这一点。因此,请有经验的人帮助我如何将其添加到pom.xml文件中。

2个回答

15
答案可以在FAQ中找到。完整答案在这里:http://article.gmane.org/gmane.comp.java.maven-plugins.mojo.user/1307
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <id>id1</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>cmd1</executable>
            </configuration>
        </execution>
        <execution>
            <id>id2</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>cmd2</executable>
            </configuration>
        </execution>
    </executions>
</plugin>

3

然后你可以将执行ID指定为:

mvn exec:exec@id2

但是这种语法只能在Maven 3.3.1及以上版本中使用。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接