简体   繁体   中英

Maven Checkstyle and Effective POM

I created a new maven project and wanted to run an initial checkstyle check against it using a custom checkstyle ruleset. I went ahead and ran mvn checkstyle:check , not expecting it to work without first adding checkstyle to my pom, but to my surprise it did. That is, maven downloaded the checkstyle jar to my local .m2 and ran checkstyle:check on my project.

I find this surprising is because I have not added checkstyle to my pom; nor do I see any reference to checkstyle in the effective pom ( mvn help:effective-pom ); nor does does checkstyle show as a dependency ( mvn dependency:tree ).

So how is maven aware of checkstyle at all? What is the elusive source within maven of the checkstyle tool and what additional features are available from that source?

I'm hoping the answer will also provide insight into how to tell mvn checkstyle:check to use a custom ruleset, not just the predefined google_checks.xml or sun_checks.xml .

How do I tell mvn checkstyle:check to use a different ruleset, say google_checks.xml, rather than sun_checks.xml, which it seems to use by default

Use the configLocation parameter, which specifies the location of the XML configuration to use: https://maven.apache.org/plugins/maven-checkstyle-plugin/checkstyle-mojo.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM