ste*_*try 4 configuration plugins checkstyle maven
我正在尝试使maven-checkstyle-plugin对我们所有的项目使用相同的配置文件.
我尝试了几种方法,但没有一种方法是有效的.
唯一似乎有用的是当我将配置文件放在我的maven项目的根目录,然后在pom.xml中使用名称作为configLocation配置参数
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.10</version>
<configuration>
<configLocation>my-checkstyle-checker.xml</configLocation>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我已经尝试指定绝对磁盘路径,但这似乎不起作用.(考虑到endgoal是让jenkins做checkstyle,如果文件位于指定位置的jenkins服务器上,这似乎是一个有效的选项)
我还尝试制作一个只包含xml文件的单独jar文件,然后将其用作依赖项.(这也会将配置集中在一个位置,并防止项目特定的偏差.)不幸的是,这也不起作用.
[错误]无法在项目jenkins-sandbox-project上执行目标org.apache.maven.plugins:maven-checkstyle-plugin:2.10:checkstyle(default-cli):Checkstyle报告生成中发生错误.在checkstyle执行期间失败:无法在位置找到配置文件my-checkstyle-checker.xml:找不到资源'my-checkstyle-checker.xml'. - > [帮助1]
有没有人可以告诉我这里我做错了什么?
它似乎只知道与maven命令启动位置相同的文件.
San*_*gen 14
创建一个单独的Maven项目,它只包含Checkstyle配置.在我的情况下,我调用了这个项目checkstyle-config,它包含以下内容:
checkstyle-config\src\main\resources\checkstyle.config.xml
checkstyle-config\src\main\resources\checkstyle.suppressions.xml
checkstyle-config\pom.xml
Run Code Online (Sandbox Code Playgroud)
这个项目的POM文件很简单:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.totaalsoftware.incidentmanager</groupId>
<artifactId>checkstyle-config</artifactId>
<version>2.0.0-SNAPSHOT</version>
</project>
Run Code Online (Sandbox Code Playgroud)
构建它,以便安装它.然后将其用作Checkstyle执行的依赖项,例如:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.totaalsoftware.incidentmanager</groupId>
<artifactId>checkstyle-config</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<configLocation>checkstyle.config.xml</configLocation>
<suppressionsLocation>checkstyle.suppressions.xml</suppressionsLocation>
... other configuration ...
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我有类似的问题。我用以下配置解决了它。
${project.basedir}/src/main/resources/checkstyle.xml
注意:我的 checkstyle 文件位于“src/main/resources”中
| 归档时间: |
|
| 查看次数: |
9275 次 |
| 最近记录: |