情况
我有一个带有CheckStyle设置的项目,该项目使用SuppressionFilter将checkstyle_suppressions.xml文件设置为忽略文件。
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/checkstyle_suppressions.xml"/>
<property name="optional" value="false"/>
</module>
将checkstyle.xml含有该文件SuppressionFilter中引用从项目pom.xml文件:
<!-- Checkstyle plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>test</phase>
<configuration>
<sourceDirectories>${project.compileSourceRoots}</sourceDirectories>
<testSourceDirectories>${project.testCompileSourceRoots}</testSourceDirectories>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
问题
使用Java Eclipse执行CheckStyle检查时,所有功能均按预期运行。但是,在使用maven进行构建时,由于${config_loc}未设置该属性,因此构建失败。原始错误: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (checkstyle) on project MyProject: Failed during checkstyle execution: Failed during checkstyle configuration: unable to parse configuration stream: Property ${config_loc} has not been set -> [Help 1]
当更改${config_loc}/checkstyle_suppressions.xml为checkstyle_suppressions.xml上述配置时,maven会按预期构建应用程序,但是Java Eclipse的CheckStyle插件不再能够解析该文件
相关分类