【问题标题】:Maven checkstyle plugin - check goal cannot find configuration fileMaven checkstyle插件 - 检查目标找不到配置文件
【发布时间】:2016-08-18 22:02:03
【问题描述】:

我一直无法使用 checkstyle 检查目标。我收到以下错误:

无法在以下位置找到配置文件: ${project.parent.basedir}/.settings/my_checks.xml:找不到 资源'${project.parent.basedir}/.settings/my_checks.xml'。

当我使用命令mvn checkstyle:check 时出现此错误,但如果我运行mvn checkstyle:checkstyle,则会找到并按预期使用此配置文件。

插件配置如下图。

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.17</version>
            <executions>
                <execution>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <phase>test</phase>
                </execution>
            </executions>           
        </plugin>   

...

    <properties>
        <checkstyle.config.location>${project.parent.basedir}/.settings/my_checks.xml</checkstyle.config.location>         
    </properties>

有什么建议吗?为什么 checkstyle 目标有效,而 check 目标无效?

编辑:经过进一步审查,我了解到 ${project.parent.basedir} 在运行检查目标时无法解决。它在调用 checkstyle 目标时确实解决了。仍在寻找建议/解决方法...

【问题讨论】:

  • 这只是发生在我身上。原因是我在main pom.xml中更新了版本号,却忘记在modules的pom文件中更新了

标签: maven checkstyle


【解决方案1】:

我的解决方法是放弃使用 ${project.parent.basedir} 变量并使用相对路径。这适用于我的情况,因为我的所有模块都是并行目录。

 <checkstyle.config.location>../parent/.settings/my_checks.xml</checkstyle.config.location>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-08
    • 2011-04-28
    • 1970-01-01
    • 2022-07-28
    • 1970-01-01
    • 2018-10-05
    • 2020-01-02
    • 1970-01-01
    相关资源
    最近更新 更多