You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kalyan Akella <ka...@gmail.com> on 2007/10/30 09:10:01 UTC

Maven runs surefire plugin for testing by default. How to change this?

Hi,

Recently, I developed a Java-based maven plugin intended to run in the test
phase of the maven build instead of the standard surefire-plugin. It has
just one goal, 'test'. When I configured my project's POM to include my
plugin for the testing phase and made sure the POM doesn't refernce surefire
anywhere, maven still invokes the surefire:test goal during the test phase.
Could someone please help me how to avoid maven running surefire plugin and
instead run mine.

Here are the details of my plugin POM and that of the Project POM:

Plugin POM:
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>sample.plugin</groupId>
    <artifactId>maven-sample-plugin</artifactId>
    <packaging>maven-plugin</packaging>
    <version>1.0</version>
    <name>My Sample Plugin</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
          <groupId>org.apache.maven</groupId>
          <artifactId>maven-artifact</artifactId>
          <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.4</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source> 1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

Project POM:
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>sample.project</groupId>
    <artifactId>hello</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>Hello World</name>
    <modules>
        <module>test</module>
    </modules>
    <profiles>
        <profile>
            <id>dev</id>
            <build>
                <filters>
                    <filter>${filters.dir}/dev-env.properties</filter>
                </filters>
                <plugins>
                    <plugin>
                        <groupId>sample.plugin</groupId>
                        <artifactId>maven-sample-plugin</artifactId>
                        <version>1.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>test</phase>

<inherited>false</inherited>
                            </execution>
                        </executions>
                        <configuration>
                            <goalPrefix>nfs</goalPrefix>
                            <includes>
                                <param>.*Test.class</param>
                            </includes>
                            <excludes>
                                <param>.*Abstract.* Test.class</param>
                                <param>.*$.*.class</param>
                                <param>.*Poller.*.class</param>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>sample.plugin</groupId>
                    <artifactId>maven-sample-plugin</artifactId>
                    <version> 1.0</version>
                    <executions>
                        <execution>
                            <phase>test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <!--<goalPrefix>nfs</goalPrefix>-->
                        <includes>
                            <param>.*Test.class</param>
                        </includes>
                        <excludes>
                            <param>.*Abstract.* Test.class</param>
                            <param>.*$.*.class</param>
                        </excludes>
                    </configuration>
                </plugin>
<!-- Commented out maven-surefire-plugin
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <excludes>
                            <exclude>**/Abstract*Test.java</exclude>
                            <exclude>**/Abstract*TestCase.java</exclude>
                            <exclude>**/Data*Poller*.java</exclude>
                            <exclude>**/*$*</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins </groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <configuration>
                        <showSuccess>false</showSuccess>
                    </configuration>
                    <version>2.0</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <phase>test</phase>
                        </execution>
                    </executions>
                </plugin>
-->
            </plugins>
        </pluginManagement>
    </build>
</project>

Moreover, I included the following annotations while coding this plugin:
@requiresDependencyResolution test
@phase test
@goal test

Please help me. Thank you.
Sincere Regards,
Kalyan

Re: Maven runs surefire plugin for testing by default. How to change this?

Posted by Tim Kettler <ti...@udo.edu>.
Hi,

as Brett told you on the dev list, just use the skip parameter to
disable surefire execution. The surefire plugin is bound to the
lifecycle by the default packagings and can't be removed.

-Tim

Kalyan Akella schrieb:
> Hi,
> 
> Recently, I developed a Java-based maven plugin intended to run in the test
> phase of the maven build instead of the standard surefire-plugin. It has
> just one goal, 'test'. When I configured my project's POM to include my
> plugin for the testing phase and made sure the POM doesn't refernce surefire
> anywhere, maven still invokes the surefire:test goal during the test phase.
> Could someone please help me how to avoid maven running surefire plugin and
> instead run mine.
> 
> Here are the details of my plugin POM and that of the Project POM:
> 
> Plugin POM:
> <project>
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>sample.plugin</groupId>
>     <artifactId>maven-sample-plugin</artifactId>
>     <packaging>maven-plugin</packaging>
>     <version>1.0</version>
>     <name>My Sample Plugin</name>
>     <dependencies>
>         <dependency>
>             <groupId>org.apache.maven</groupId>
>             <artifactId>maven-plugin-api</artifactId>
>             <version>2.0</version>
>         </dependency>
>         <dependency>
>           <groupId>org.apache.maven</groupId>
>           <artifactId>maven-artifact</artifactId>
>           <version>2.0</version>
>         </dependency>
>         <dependency>
>             <groupId>junit</groupId>
>             <artifactId>junit</artifactId>
>             <version>4.4</version>
>         </dependency>
>     </dependencies>
>     <build>
>         <pluginManagement>
>             <plugins>
>                 <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-compiler-plugin</artifactId>
>                     <configuration>
>                         <source> 1.5</source>
>                         <target>1.5</target>
>                     </configuration>
>                 </plugin>
>             </plugins>
>         </pluginManagement>
>     </build>
> </project>
> 
> Project POM:
> <project>
>     <modelVersion>4.0.0</modelVersion>
>     <groupId>sample.project</groupId>
>     <artifactId>hello</artifactId>
>     <version>1.0-SNAPSHOT</version>
>     <packaging>pom</packaging>
>     <name>Hello World</name>
>     <modules>
>         <module>test</module>
>     </modules>
>     <profiles>
>         <profile>
>             <id>dev</id>
>             <build>
>                 <filters>
>                     <filter>${filters.dir}/dev-env.properties</filter>
>                 </filters>
>                 <plugins>
>                     <plugin>
>                         <groupId>sample.plugin</groupId>
>                         <artifactId>maven-sample-plugin</artifactId>
>                         <version>1.0</version>
>                         <executions>
>                             <execution>
>                                 <goals>
>                                     <goal>test</goal>
>                                 </goals>
>                                 <phase>test</phase>
> 
> <inherited>false</inherited>
>                             </execution>
>                         </executions>
>                         <configuration>
>                             <goalPrefix>nfs</goalPrefix>
>                             <includes>
>                                 <param>.*Test.class</param>
>                             </includes>
>                             <excludes>
>                                 <param>.*Abstract.* Test.class</param>
>                                 <param>.*$.*.class</param>
>                                 <param>.*Poller.*.class</param>
>                             </excludes>
>                         </configuration>
>                     </plugin>
>                 </plugins>
>             </build>
>         </profile>
>     </profiles>
>     <build>
>         <pluginManagement>
>             <plugins>
>                 <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-compiler-plugin</artifactId>
>                     <configuration>
>                         <source>1.5</source>
>                         <target>1.5</target>
>                     </configuration>
>                 </plugin>
>                 <plugin>
>                     <groupId>sample.plugin</groupId>
>                     <artifactId>maven-sample-plugin</artifactId>
>                     <version> 1.0</version>
>                     <executions>
>                         <execution>
>                             <phase>test</phase>
>                             <goals>
>                                 <goal>test</goal>
>                             </goals>
>                         </execution>
>                     </executions>
>                     <configuration>
>                         <!--<goalPrefix>nfs</goalPrefix>-->
>                         <includes>
>                             <param>.*Test.class</param>
>                         </includes>
>                         <excludes>
>                             <param>.*Abstract.* Test.class</param>
>                             <param>.*$.*.class</param>
>                         </excludes>
>                     </configuration>
>                 </plugin>
> <!-- Commented out maven-surefire-plugin
>                 <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-surefire-plugin</artifactId>
>                     <version>2.3</version>
>                     <configuration>
>                         <excludes>
>                             <exclude>**/Abstract*Test.java</exclude>
>                             <exclude>**/Abstract*TestCase.java</exclude>
>                             <exclude>**/Data*Poller*.java</exclude>
>                             <exclude>**/*$*</exclude>
>                         </excludes>
>                     </configuration>
>                 </plugin>
>                 <plugin>
>                     <groupId>org.apache.maven.plugins </groupId>
>                     <artifactId>maven-surefire-report-plugin</artifactId>
>                     <configuration>
>                         <showSuccess>false</showSuccess>
>                     </configuration>
>                     <version>2.0</version>
>                     <executions>
>                         <execution>
>                             <goals>
>                                 <goal>report</goal>
>                             </goals>
>                             <phase>test</phase>
>                         </execution>
>                     </executions>
>                 </plugin>
> -->
>             </plugins>
>         </pluginManagement>
>     </build>
> </project>
> 
> Moreover, I included the following annotations while coding this plugin:
> @requiresDependencyResolution test
> @phase test
> @goal test
> 
> Please help me. Thank you.
> Sincere Regards,
> Kalyan
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org