From 4fdcae8d12f728d2ceff41aa34d4b9317424adfb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 8 Feb 2017 09:48:06 +0000 Subject: [PATCH 1/5] plugin-sample:Sample: add note clarifying ruleset level compliance The class is meant to fail at higher levels. --- .../src/main/java/net/kemitix/checkstyle/sample/Sample.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin-sample/src/main/java/net/kemitix/checkstyle/sample/Sample.java b/plugin-sample/src/main/java/net/kemitix/checkstyle/sample/Sample.java index 9f7eaba..55b178e 100644 --- a/plugin-sample/src/main/java/net/kemitix/checkstyle/sample/Sample.java +++ b/plugin-sample/src/main/java/net/kemitix/checkstyle/sample/Sample.java @@ -27,6 +27,9 @@ package net.kemitix.checkstyle.sample; /** * Sample class to test the Kemitix Checkstyle Ruleset Maven Plugin against. * + *

This sample is deliberately only valid for level 1-layout and 2-naming. The plugin should report errors for levels + * 3-javadoc and above.

+ * * @author Paul Campbell (paul.campbell@hubio.com) */ public class Sample { From d54ae55f0a57ab793d811c7fdad7fedc556392bd Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 8 Feb 2017 09:49:01 +0000 Subject: [PATCH 2/5] plugin:AbstractCheckMojo: upgrade checkstyle to 7.5.1 http://checkstyle.sourceforge.net/releasenotes.html#Release_7.5.1 Bug fixes: * PackageObjectFactory hides real exception. Author: rnveach #3778 * RightCurly: handling of try-with-resources on several lines with CS 7.5. Author: rnveach, Roman Ivanov #3776 Notes: * Add the Hibernate Search project to the Checkstyle CI. Author: Roman Ivanov #3790 --- .../kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java index fabc414..27d57e0 100644 --- a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java +++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java @@ -66,7 +66,7 @@ public abstract class AbstractCheckMojo extends AbstractMojo { private String mavenCheckstylePluginVersion; @Setter - @Parameter(defaultValue = "7.4") + @Parameter(defaultValue = "7.5.1") private String checkstyleVersion; @Setter From 87f74dec16b3397b650d1d38e4576d5706cf47f2 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 8 Feb 2017 09:49:28 +0000 Subject: [PATCH 3/5] plugin:AbstractCheckMojo: use ruleset version from pom.xml --- .../kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java index 27d57e0..2ea025e 100644 --- a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java +++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java @@ -74,7 +74,7 @@ public abstract class AbstractCheckMojo extends AbstractMojo { private String sevntuVersion; @Setter - @Parameter(defaultValue = "2.1.0-SNAPSHOT") + @Parameter(defaultValue = "${project.version}") private String rulesetVersion; @Setter From e951d2c99bc2692759d138367e0f54434d8b49cb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 8 Feb 2017 09:55:29 +0000 Subject: [PATCH 4/5] plugin:AbstractCheckMojo: include ruleset version on log line --- .../kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java index 2ea025e..235d04c 100644 --- a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java +++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java @@ -107,8 +107,9 @@ public abstract class AbstractCheckMojo extends AbstractMojo { val configLocation = MojoExecutor.element(CONFIG_LOCATION, String.format("net/kemitix/checkstyle-%s.xml", level)); - getLog().info( - String.format("Running Checkstyle %s (sevntu: %s) with %s", checkstyleVersion, sevntuVersion, level)); + getLog().info(String.format("Running Checkstyle %s (sevntu: %s) with ruleset %s (%s)", checkstyleVersion, + sevntuVersion, level, rulesetVersion + )); MojoExecutor.executeMojo(checkstylePlugin, "check", MojoExecutor.configuration(configLocation), MojoExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager) ); From ca01a08e81444e2a4e9f51c99e9133954d3284ef Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 8 Feb 2017 10:56:55 +0000 Subject: [PATCH 5/5] plugin:AbstractCheckMojo: load dependency versions from plugin pom.xml --- plugin/pom.xml | 33 +++++++++++++++++++ .../ruleset/plugin/AbstractCheckMojo.java | 18 ++++------ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/plugin/pom.xml b/plugin/pom.xml index eb53577..c9fb04c 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -30,6 +30,11 @@ 2.2.0 1.16.12 1.0.0 + + 1.0.0 + 2.17 + 7.5.1 + 1.23.0 @@ -96,6 +101,34 @@ 1.8 + + org.codehaus.mojo + properties-maven-plugin + ${properties-maven-plugin.version} + + + + set-system-properties + + + + + maven-checkstyle-plugin.version + ${maven-checkstyle-plugin.version} + + + checkstyle.version + ${checkstyle.version} + + + sevntu.version + ${sevntu.version} + + + + + + diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java index 235d04c..fbb72f1 100644 --- a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java +++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java @@ -61,18 +61,6 @@ public abstract class AbstractCheckMojo extends AbstractMojo { private static final String CONFIG_LOCATION = "configLocation"; - @Setter - @Parameter(defaultValue = "2.17") - private String mavenCheckstylePluginVersion; - - @Setter - @Parameter(defaultValue = "7.5.1") - private String checkstyleVersion; - - @Setter - @Parameter(defaultValue = "1.23.0") - private String sevntuVersion; - @Setter @Parameter(defaultValue = "${project.version}") private String rulesetVersion; @@ -97,6 +85,12 @@ public abstract class AbstractCheckMojo extends AbstractMojo { * @throws MojoFailureException on execution failure */ protected final void performCheck(final String level) throws MojoExecutionException, MojoFailureException { + // load versions from plugin's pom.xml + val properties = System.getProperties(); + val mavenCheckstylePluginVersion = properties.getProperty("maven-checkstyle-plugin.version"); + val checkstyleVersion = properties.getProperty("checkstyle.version"); + val sevntuVersion = properties.getProperty("sevntu.version"); + val checkstyle = MojoExecutor.dependency(CHECKSTYLE_GROUPID, CHECKSTYLE_ARTIFACTID, checkstyleVersion); val sevntu = MojoExecutor.dependency(SEVNTU_GROUPID, SEVNTU_ARTIFACTID, sevntuVersion); val ruleset = MojoExecutor.dependency(KEMITIX_GROUPID, KEMITIX_ARTIFACTID, rulesetVersion);