简体   繁体   中英

How to prioritize or order the Maven plugin Execution?

I define the Maven plugins in POM.xml as follows:

<build>
    <outputDirectory>reports/maven/classes</outputDirectory>
    <testOutputDirectory>reports/maven/test-classes</testOutputDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.6.1</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>${basedir}/reports/maven/mail</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.2</version>
            <configuration>
                <reportsDirectory>${basedir}/reports/maven/mail</reportsDirectory>
                <suiteXmlFiles>
                    <suiteXmlFile>${basedir}/src/test/resources/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
                <includes>
                    <include>**/*.java</include>
                </includes>
                <!-- <testFailureIgnore>true</testFailureIgnore> -->
                <!-- <properties> Setting ReportNG listeners <property> <name>listener</name> 
                    <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value> 
                    </property> </properties> -->
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <!-- here the phase you need -->
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/reports/maven/archieve/new</outputDirectory>
                        <resources>
                            <resource>
                                <directory>${basedir}/reports/maven/mail</directory>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>ch.fortysix</groupId>
            <artifactId>maven-postman-plugin</artifactId>
            <version>0.1.6</version>
            <executions>
                <execution>
                    <id>send_an_email</id>
                    <phase>test</phase>
                    <goals>
                        <goal>send-mail</goal>
                    </goals>
                    <inherited>true</inherited>
                    <configuration>
                        <mailhost>smtp.mail.yahoo.com</mailhost>
                        <mailport>465</mailport>
                        <mailssl>true</mailssl>
                        <mailAltConfig>true</mailAltConfig>
                        <mailuser>sams.prashanth@yahoo.com</mailuser>
                        <mailpassword>************</mailpassword>

                        <from>sams.prashanth@yahoo.com</from>
                        <receivers>
                            <receiver>sams.prashanth@gmail.com</receiver>
                            <receiver>*********</receiver>
                        </receivers>

                        <subject>Demo project - Smoke results</subject>
                        <failonerror>false</failonerror>
                        <htmlMessage>
                                    <![CDATA[
                                        <p>New Build Arrived! </p><br>
                                        <p>Check the smoke results from attachment :)</p>                                       
                                    ]]>
                        </htmlMessage>

                        <fileSets>
                            <fileSet>
                                <directory>${basedir}/reports/maven/mail</directory>
                                <includes>
                                    <include>**/html/index.html</include>
                                </includes>
                            </fileSet>
                        </fileSets>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

But the maven plugin, 'maven-resources-plugin' seems to run at the first whereas I need the same to run at the last. Please provide the work around to post-run 'maven-resources-plugin'. Thanks in advance!

Tools used:

Maven 3.1.0

JDK 7

The following link helps you to order the maven plugin execution. https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Add proper < phase > tag to achieve it.

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