Несколько команд с плагином Maven Exec

Я немного борюсь с плагином Maven Exec. Я хочу выполнить две отдельные команды mvn с помощью плагина, поэтому мне нужно только выполнить mvn exec:exec, чтобы выполнить все команды.

Следующие две команды хорошо работают по отдельности:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <configuration>
        <executable>mvn</executable>
        <arguments>
            <argument>clean</argument>
        </arguments>
    </configuration>
</plugin>

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <configuration>
        <executable>mvn</executable>
        <arguments>
            <argument>package</argument>
        </arguments>
    </configuration>
</plugin>

И это моя попытка объединить оба, чтобы выполнить их одной командой:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>

    <executions>
        <execution>
            <id>id1</id>
            <phase>package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>mvn</executable>
                <arguments>
                    <argument>clean</argument>
                </arguments>
            </configuration>
        </execution>

        <execution>
            <id>id2</id>
            <phase>package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>mvn</executable>
                <arguments>
                    <argument>package</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>

</plugin>

К сожалению, теперь, когда я запускаю mvn exec:exec, я получаю следующее сообщение об ошибке:

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProjet 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ MyProject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.787 s
[INFO] Finished at: 2017-09-26T09:56:57+01:00
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default-cli) on project MyProject: The parameter 'executable' is missing or invalid -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

person Sebastian Dine    schedule 26.09.2017    source источник
comment
when I now execute mvn exec:exec => вы должны запустить «package», так как вы привязали свои 2 выполнения к этой фазе.   -  person Tome    schedule 26.09.2017


Ответы (1)


Когда вы запускаете mvn exec:exec в командной строке, он запускает <execution> с <id> из default-cli. Это объясняет сообщение об ошибке, так как нет выполнения с <id>default-cli</id>, у которого есть <executable>, настроенный в вашем POM.

Чтобы решить вашу проблему, ознакомьтесь с Руководством по настройке плагина -ins. В нем объясняется, как выполнить цель из командной строки с <id>, отличным от default-cli:

mvn exec:exec@id1 exec:exec@id2
person Andreas Sewe    schedule 26.09.2017