How to execute maven plugin in given phase
Asked Answered
B

1

5

I want to aggregate all surefire reports in separate modules. In my folder there are several module and I want to generate aggregated surefire report of all those modules. I could do this when I execute following command inside the my parent folder.

mvn surefire-report:report -Daggregate=true

I want to do the same operation when I execute

mvn clean install

inside my parent folder. For that I have to change the parent folder pox.xml file.

I found it can be using following maven plugin

<build>
    <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
            ...............

But when I execute

mvn clean install 

There is no result. In addition to add the plugin to the pom.xml is there any other steps to do ? Or is this path correct ?

Thanks,

Baptista answered 26/2, 2014 at 19:17 Comment(1)
H
10

try this

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.7.2</version>
            <configuration>
                <aggregate>true</aggregate>
            </configuration>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
Hoffarth answered 26/2, 2014 at 19:21 Comment(8)
Do I have to put this inside <build> ?Baptista
sure, just like in your questionHoffarth
I just put the code segment you given in the <build>. But when i execute [ mvn clean install ] it doesn't generate the aggregated report as [ mvn surefire-report:report -Daggregate=true ]Baptista
it should generate surefire-report.html in target/siteHoffarth
it do not create target folder with [ mvn clean install ]. Should I add any other thing ?Baptista
check mvn log, this thing definitely works, I tested itHoffarth
let us continue this discussion in chatBaptista
There was a conflict as my sub module also has 'surefire-report' plugin included. Then it works fine,TnxBaptista

© 2022 - 2024 — McMap. All rights reserved.