尚未设置Maven错误;属性$ {samedir}尚未设置

发布于 2025-01-31 19:46:27 字数 542 浏览 1 评论 0原文

如何修复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定义该物业的

任何想法如何解决此问题?

How to fix the maven checkstyle plugin error

[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} is a property working well with eclipse plugin and is required to get related files mentioned in the checkstyle configuration working well with eclipse IDE. So either I need a consistent replacement, or I can tell maven to define the property

Any ideas how to fix this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倦话 2025-02-07 19:46:27

您将必须通过POM中的插件配置设置这些值。

pom.xml的示例配置如果您的项目root中有名为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 cottents cottents:

samedir=checks

作为替代方法: &lt; propertiesLocation&gt;您也可以使用以下内容,在这种情况下,您不需要.properties file:

<propertyExpansion>samedir=${basedir}/checks</propertyExpansion>

这将确保在checkStyle中确保任何配置。

<module name="Checker">
    <module name="SuppressionFilter">
        <property name="file" value="${samedir}/suppress.xml"/>
    </module>
</module>

You will have to set these values via the plugin configuration in your pom.

Example configuration of pom.xml if you have a directory named checks in your project root:

<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>

And the checkstyle_maven.properties contents:

samedir=checks

As an alternative to the <propertiesLocation> you can also use the following, in which case you don't need the .properties file:

<propertyExpansion>samedir=${basedir}/checks</propertyExpansion>

This will make sure any configuration in checkstyle.xml will work like this:

<module name="Checker">
    <module name="SuppressionFilter">
        <property name="file" value="${samedir}/suppress.xml"/>
    </module>
</module>

See for reference:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文