如何修復 maven checkstyle 插件錯誤
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.2:check (validate) on project yourproject:
Failed during checkstyle execution:
Failed during checkstyle configuration: unable to parse configuration stream:
com.puppycrawl.tools.checkstyle.api.CheckstyleException:
Property ${samedir} has not been set -> [Help 1]
${samedir} 是一個與 Eclipse 插件配合良好的屬性,并且需要獲取 checkstyle 配置中提到的相關檔案才能與 Eclipse IDE 配合良好。所以要么我需要一個一致的替換,要么我可以告訴 maven 定義屬性
任何想法如何解決這個問題?
uj5u.com熱心網友回復:
您必須通過 pom.xml 中的插件配置來設定這些值。
pom.xml如果您checks的專案根目錄中有一個名為的目錄的示例配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<configLocation>${basedir}/checks/checkstyle.xml</configLocation>
<propertiesLocation>${basedir}/checks/checkstyle_maven.properties</propertiesLocation>
</configuration>
</plugin>
以及checkstyle_maven.properties內容:
samedir=checks
作為替代,<propertiesLocation>您還可以使用以下內容,在這種情況下您不需要該.properties檔案:
<propertyExpansion>samedir=${basedir}/checks</propertyExpansion>
這將確保其中的任何配置都checkstyle.xml將像這樣作業:
<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="${samedir}/suppress.xml"/>
</module>
</module>
見參考:
- 在 Gradle 和 Eclipse 的 Checkstyle-plugins 中使用 ${samedir}
- http://rolf-engelhard.de/2011/04/using-the-same-suppression-filter-for-checkstyle-in-eclipse-and-maven/
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/481859.html
標籤:行家 检查风格 maven-checkstyle-插件
下一篇:嘗試部署到AZURE時出錯無法執行目標org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test
