Launch Maven Checkstyle with Custom Checkstyle

I ran mvn checkstyle:checkstyle but did not use my own checkstyle XML file.

Please tell me how to use my own checkstyle file, not the default / depending on what it has configured now?

+4
source share
2 answers

You need to configure the file location in pom.xml :

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> <configLocation><!-- Specify file here --></configLocation> </configuration> </plugin> </plugins> </build> 

Browse this page to view other configuration options.

+3
source

Now this has changed for the latest version of CheckStyle, you need to declare the file location using the property:

 <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"> ... <properties> <checkstyle.config.location><!-- Specify file here --></checkstyle.config.location> </properties> <build> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> </plugin> </plugins> </build> </project> 

Taken from my example how to write a custom validation check:

http://blog.blundellapps.co.uk/create-your-own-checkstyle-check/

and the source code is here:

https://github.com/blundell/CreateYourOwnCheckStyleCheck

+3
source

Source: https://habr.com/ru/post/1438963/


All Articles