简体   繁体   中英

Maven do not execute script extern in clean phase but only in compile or install

With maven I set up a plugin that runs an external script.

              <plugin>
                <artifactId>exec-maven-plugin</artifactId>
                <groupId>org.codehaus.mojo</groupId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>Execute External Command</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>
                                ${basedir}/external.sh
                            </executable>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

The problem is that it also starts with the mvn clean command. Is it possible not to start the plugin in clean phase? or is it possible to parameterize my external script with a parameter that makes me understand that I am in the clean phase?

Something like:

                        <executable>
                            ${basedir}/external.sh ${phase}
                        </executable>

Can you try to change the phase in your plugin, for exmple:

  <phase>install</phase>

full plugin:

         <plugin>
            <artifactId>exec-maven-plugin</artifactId>
            <groupId>org.codehaus.mojo</groupId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>Execute External Command</id>
                    <phase>install</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>
                            ${basedir}/external.sh
                        </executable>
                    </configuration>
                </execution>
            </executions>
        </plugin>

you can choose any of the other suitable phases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM