Reputation: 3
Maven-checkstyle-plugin is included to lifecycle on compile phase.FailsOneError configuration is enabled.It generates .xml report and crash the build.I want to get html version using my custom .xsl file for transforming.For it, I use xml-maven-plugin but I cant configure it for auto-execution and can not integrate to lifecycle.
I have to implement this steps:
1)run "mvn install"
2)maven-checkstyle-plugin analyses code
3)plugin finds errors and generates xml report
4)build breaks down
5)xml-maven-plugin automacilly generates .html report
Part of my pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>check</goal>
</goals>
<phase>compile</phase>
<configuration>
<configLocation>checkstyle/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>${xml.maven.version}</version>
<executions>
<execution>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>target\</dir>
<stylesheet>checkstyle\checkstyle-author.xsl</stylesheet>
<includes>checkstyle-result.xml</includes>
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.RegExpFileMapper">
<pattern>\.xml$</pattern>
<replacement>.html</replacement>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 0
Views: 4416
Reputation: 8160
You need to watch the phases and plugins closely.
The checkstyle plugin executes in phase "compile". According to the docs of the xml-maven-plugin its default phase is "generate-resources".
So you need to put that goal into a phase later than the checkstyle plugin (process-classes comes after compile):
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
I believe the logs of the xml plugin should complain about the missing file or should work if you run the build twice without a clean? Which would not be a good result. So having order in what is executed when usually is best :)
Upvotes: 1