diff --git a/README.md b/README.md
index 075df53..83b34f8 100644
--- a/README.md
+++ b/README.md
@@ -25,17 +25,18 @@ The ruleset includes checks from both the core Checkstyle library and from the S
To use this ruleset add the plugin `kemitix-checktyle-ruleset-maven-plugin`.
The `maven-checkstyle-plugin` will be included automatically.
-Select the level 1-5 of strictness required:
+The following goals implement increasingly strict rulesets:
-1. layout
-2. naming
-3. javadoc
-4. tweaks
-5. complexity
+* 1-layout
+* 2-naming
+* 3-javadoc
+* 4-tweaks
+* 5-complexity
````
- 2
+ 2.0.0
+ 5-complexity
@@ -43,17 +44,12 @@ Select the level 1-5 of strictness required:
net.kemitix
kemitix-checkstyle-ruleset-maven-plugin
- 2.0.0
-
- ${kemitix-checkstyle-ruleset.level}
-
+ ${kemitix-checkstyle-ruleset.version}
validate
-
- check
-
+ ${kemitix-checkstyle-ruleset.level}
diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md
index aff6d61..489eaa5 100644
--- a/builder/src/main/resources/README-template.md
+++ b/builder/src/main/resources/README-template.md
@@ -25,17 +25,18 @@ The ruleset includes checks from both the core Checkstyle library and from the S
To use this ruleset add the plugin `kemitix-checktyle-ruleset-maven-plugin`.
The `maven-checkstyle-plugin` will be included automatically.
-Select the level 1-5 of strictness required:
+The following goals implement increasingly strict rulesets:
-1. layout
-2. naming
-3. javadoc
-4. tweaks
-5. complexity
+* 1-layout
+* 2-naming
+* 3-javadoc
+* 4-tweaks
+* 5-complexity
````
- 2
+ 2.0.0
+ 5-complexity
@@ -43,17 +44,12 @@ Select the level 1-5 of strictness required:
net.kemitix
kemitix-checkstyle-ruleset-maven-plugin
- 2.0.0
-
- ${kemitix-checkstyle-ruleset.level}
-
+ ${kemitix-checkstyle-ruleset.version}
validate
-
- check
-
+ ${kemitix-checkstyle-ruleset.level}
diff --git a/plugin-sample/pom.xml b/plugin-sample/pom.xml
index 927b4d2..3775fa7 100644
--- a/plugin-sample/pom.xml
+++ b/plugin-sample/pom.xml
@@ -22,16 +22,11 @@
net.kemitix
kemitix-checkstyle-ruleset-maven-plugin
2.0.0-SNAPSHOT
-
- 2
-
validate
-
- check
-
+ 2-naming
diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/CheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java
similarity index 69%
rename from plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/CheckMojo.java
rename to plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java
index eca0617..6098958 100644
--- a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/CheckMojo.java
+++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/AbstractCheckMojo.java
@@ -26,28 +26,22 @@ package net.kemitix.checkstyle.ruleset.plugin;
import lombok.Setter;
import lombok.val;
-import me.andrz.builder.map.MapBuilder;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.twdata.maven.mojoexecutor.MojoExecutor;
-import java.util.Map;
-
/**
* Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Ruleset.
*
* @author Paul Campbell (pcampbell@kemitix.net)
*/
-@Mojo(name = "check", defaultPhase = LifecyclePhase.VALIDATE)
-public class CheckMojo extends AbstractMojo {
+public abstract class AbstractCheckMojo extends AbstractMojo {
private static final String CHECKSTYLE_GROUPID = "com.puppycrawl.tools";
@@ -67,28 +61,6 @@ public class CheckMojo extends AbstractMojo {
private static final String CONFIG_LOCATION = "configLocation";
-
- private static final String LAYOUT = "1-layout";
-
- private static final String NAMING = "2-naming";
-
- private static final String JAVADOC = "3-javadoc";
-
- private static final String TWEAKS = "4-tweaks";
-
- private static final String COMPLEXITY = "5-complexity";
-
- private static Map levelConfig = new MapBuilder().put("1", LAYOUT)
- .put("2", NAMING)
- .put("3", JAVADOC)
- .put("4", TWEAKS)
- .put("5", COMPLEXITY)
- .build();
-
- //@Setter
- //@Parameter(defaultValue = "check")
- //private String goal;
-
@Setter
@Parameter(defaultValue = "2.17")
private String mavenCheckstylePluginVersion;
@@ -105,10 +77,6 @@ public class CheckMojo extends AbstractMojo {
@Parameter(defaultValue = "2.0.0-SNAPSHOT")
private String rulesetVersion;
- @Setter
- @Parameter(defaultValue = "5")
- private String level;
-
@Setter
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject mavenProject;
@@ -120,17 +88,15 @@ public class CheckMojo extends AbstractMojo {
@Component
private BuildPluginManager pluginManager;
- private static String getConfigFile(final String level) {
- return String.format("checkstyle-%s.xml", levelConfig.getOrDefault(level, COMPLEXITY));
- }
-
/**
* Execute Checkstyle Check.
*
+ * @param level The level of config file to use.
+ *
* @throws MojoExecutionException on execution error
* @throws MojoFailureException on execution failure
*/
- public final void execute() throws MojoExecutionException, MojoFailureException {
+ protected final void performCheck(final String level) throws MojoExecutionException, MojoFailureException {
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);
@@ -138,11 +104,11 @@ public class CheckMojo extends AbstractMojo {
MojoExecutor.plugin(APACHE_PLUGIN_GROUPID, APACHE_PLUGIN_ARTIFACTID, mavenCheckstylePluginVersion,
MojoExecutor.dependencies(checkstyle, sevntu, ruleset)
);
- val configLocation = MojoExecutor.element(CONFIG_LOCATION, "net/kemitix/" + getConfigFile(level));
+ val configLocation =
+ MojoExecutor.element(CONFIG_LOCATION, String.format("net/kemitix/checkstyle-%s.xml", level));
getLog().info(
- "Running Checkstyle " + checkstyleVersion + " (sevntu: " + sevntuVersion + ") with " + getConfigFile(
- level));
+ String.format("Running Checkstyle %s (sevntu: %s) with %s", checkstyleVersion, sevntuVersion, level));
MojoExecutor.executeMojo(checkstylePlugin, "check", MojoExecutor.configuration(configLocation),
MojoExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager)
);
diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/ComplexityCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/ComplexityCheckMojo.java
new file mode 100644
index 0000000..94090c8
--- /dev/null
+++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/ComplexityCheckMojo.java
@@ -0,0 +1,44 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Paul Campbell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+package net.kemitix.checkstyle.ruleset.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Ruleset: COMPLEXITY, TWEAKS, JAVADOC, NAMING and LAYOUT.
+ *
+ * @author Paul Campbell (pcampbell@kemitix.net)
+ */
+@Mojo(name = "5-complexity", defaultPhase = LifecyclePhase.VALIDATE)
+public class ComplexityCheckMojo extends AbstractCheckMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ performCheck("5-complexity");
+ }
+}
diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/JavadocCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/JavadocCheckMojo.java
new file mode 100644
index 0000000..2952110
--- /dev/null
+++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/JavadocCheckMojo.java
@@ -0,0 +1,44 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Paul Campbell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+package net.kemitix.checkstyle.ruleset.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Ruleset: JAVADOC, NAMING and LAYOUT.
+ *
+ * @author Paul Campbell (pcampbell@kemitix.net)
+ */
+@Mojo(name = "3-javadoc", defaultPhase = LifecyclePhase.VALIDATE)
+public class JavadocCheckMojo extends AbstractCheckMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ performCheck("3-javadoc");
+ }
+}
diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/LayoutCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/LayoutCheckMojo.java
new file mode 100644
index 0000000..e6aee8e
--- /dev/null
+++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/LayoutCheckMojo.java
@@ -0,0 +1,44 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Paul Campbell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+package net.kemitix.checkstyle.ruleset.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Ruleset: LAYOUT.
+ *
+ * @author Paul Campbell (pcampbell@kemitix.net)
+ */
+@Mojo(name = "1-layout", defaultPhase = LifecyclePhase.VALIDATE)
+public class LayoutCheckMojo extends AbstractCheckMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ performCheck("1-layout");
+ }
+}
diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/NamingCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/NamingCheckMojo.java
new file mode 100644
index 0000000..a650885
--- /dev/null
+++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/NamingCheckMojo.java
@@ -0,0 +1,44 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Paul Campbell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+package net.kemitix.checkstyle.ruleset.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Rulesets: NAMING and LAYOUT.
+ *
+ * @author Paul Campbell (pcampbell@kemitix.net)
+ */
+@Mojo(name = "2-naming", defaultPhase = LifecyclePhase.VALIDATE)
+public class NamingCheckMojo extends AbstractCheckMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ performCheck("2-naming");
+ }
+}
diff --git a/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/TweaksCheckMojo.java b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/TweaksCheckMojo.java
new file mode 100644
index 0000000..6cb2144
--- /dev/null
+++ b/plugin/src/main/java/net/kemitix/checkstyle/ruleset/plugin/TweaksCheckMojo.java
@@ -0,0 +1,44 @@
+/*
+The MIT License (MIT)
+
+Copyright (c) 2016 Paul Campbell
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+package net.kemitix.checkstyle.ruleset.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+/**
+ * Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Ruleset: TWEAKS, JAVADOC, NAMING and LAYOUT.
+ *
+ * @author Paul Campbell (pcampbell@kemitix.net)
+ */
+@Mojo(name = "4-tweaks", defaultPhase = LifecyclePhase.VALIDATE)
+public class TweaksCheckMojo extends AbstractCheckMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ performCheck("4-tweaks");
+ }
+}