【发布时间】:2017-12-28 15:32:58
【问题描述】:
Maven-checkstyle-plugin 包含在编译阶段的生命周期中。FailsOneError 配置已启用。它会生成 .xml 报告并使构建崩溃。我想使用我的自定义 .xsl 文件获取 html 版本进行转换。为此,我使用 xml-maven-plugin 但我无法将其配置为自动执行,也无法集成到生命周期中。
我必须执行以下步骤:
1) 运行“mvn install”
2)maven-checkstyle-plugin 分析代码
3)插件发现错误并生成xml报告
4) 构建崩溃
5)xml-maven-plugin 自动生成.html 报告
我的 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>
【问题讨论】:
标签: xml maven xslt maven-plugin checkstyle