Merge pull request #4 from kemitix/plugin

Add Plugin
This commit is contained in:
Paul Campbell 2017-01-14 17:35:23 +00:00 committed by GitHub
commit f2ad6b566d
17 changed files with 660 additions and 127 deletions

View file

@ -22,76 +22,41 @@ The ruleset includes checks from both the core Checkstyle library and from the S
## Usage ## Usage
To use this ruleset in your `maven-checkstyle-plugin` configuration add `checkstyle`, `sevntu-checkstyle-maven-plugin` and `kemitix-checktyle-ruleset` as dependencies of the `maven-checkstyle-plugin`. To use this ruleset add the plugin `kemitix-checktyle-ruleset-maven-plugin`.
The `maven-checkstyle-plugin` will be included automatically.
You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. The following goals implement increasingly strict rulesets:
Select the `configLocation` for the level of strictness required: * 1-layout
* 2-naming
* checkstyle-1-layout.xml * 3-javadoc
* checkstyle-2-naming.xml * 4-tweaks
* checkstyle-3-javadoc.xml * 5-complexity
* checkstyle-4-tweaks.xml
* checkstyle-5-complexity.xml
Only specify a single `configLocation` as each increasing level includes all the rules
from the previous.
```` ````
<properties> <properties>
<maven.checkstyle.plugin.version>2.17</maven.checkstyle.plugin.version>
<checkstyle.version>7.3</checkstyle.version>
<sevntu-checkstyle-maven-plugin.version>1.22.0</sevntu-checkstyle-maven-plugin.version>
<kemitix-checkstyle-ruleset.version>2.0.0</kemitix-checkstyle-ruleset.version> <kemitix-checkstyle-ruleset.version>2.0.0</kemitix-checkstyle-ruleset.version>
<kemitix-checkstyle-ruleset.level>5-complexity</kemitix-checkstyle-ruleset.level> <kemitix-checkstyle-ruleset.level>5-complexity</kemitix-checkstyle-ruleset.level>
</properties> </properties>
<build> <build>
<pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
<dependency>
<groupId>com.github.sevntu.checkstyle</groupId>
<artifactId>sevntu-checkstyle-maven-plugin</artifactId>
<version>${sevntu-checkstyle-maven-plugin.version}</version>
</dependency>
<dependency>
<groupId>net.kemitix</groupId> <groupId>net.kemitix</groupId>
<artifactId>kemitix-checkstyle-ruleset</artifactId> <artifactId>kemitix-checkstyle-ruleset-maven-plugin</artifactId>
<version>${kemitix-checkstyle-ruleset.version}</version> <version>${kemitix-checkstyle-ruleset.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml</configLocation>
</configuration>
</plugin><!-- maven-checkstyle-plugin -->
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>validate</id>
<phase>validate</phase> <phase>validate</phase>
<goals> <goals>
<goal>check</goal> <goal>${kemitix-checkstyle-ruleset.level}</goal>
<goal>checkstyle</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin><!-- maven-checkstyle-plugin --> </plugin>
</plugins> </plugins>
</build> </build>
<pluginRepositories> <pluginRepositories>
<pluginRepository> <pluginRepository>
<id>sevntu-maven</id> <id>sevntu-maven</id>

View file

@ -34,9 +34,12 @@
<inceptionYear>2016</inceptionYear> <inceptionYear>2016</inceptionYear>
<properties> <properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>1.4.3.RELEASE</spring-boot.version> <spring-boot.version>1.4.3.RELEASE</spring-boot.version>
<kemitix-checkstyle-ruleset.version>2.0.0-SNAPSHOT</kemitix-checkstyle-ruleset.version> <kemitix-checkstyle-ruleset.version>2.0.0-SNAPSHOT</kemitix-checkstyle-ruleset.version>
<kemitix-checkstyle-ruleset.level>5-complexity</kemitix-checkstyle-ruleset.level> <lombok.version>1.16.12</lombok.version>
<assertj.version>3.6.1</assertj.version> <assertj.version>3.6.1</assertj.version>
<mapstream.version>2.3.4</mapstream.version> <mapstream.version>2.3.4</mapstream.version>
<mapbuilder.version>1.0.0</mapbuilder.version> <mapbuilder.version>1.0.0</mapbuilder.version>
@ -66,6 +69,8 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.speedment.common</groupId> <groupId>com.speedment.common</groupId>
@ -81,6 +86,7 @@
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<version>${assertj.version}</version> <version>${assertj.version}</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.andrz</groupId> <groupId>me.andrz</groupId>
@ -90,35 +96,28 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>net.kemitix</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>kemitix-checkstyle-ruleset-maven-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version> <version>${kemitix-checkstyle-ruleset.version}</version>
<configuration> </plugin>
<configLocation>net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml</configLocation>
</configuration>
</plugin><!-- maven-checkstyle-plugin -->
</plugins>
</pluginManagement>
<plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version> <version>${spring-boot.version}</version>
<!--<configuration>--> <configuration>
<!--<executable>true</executable>--> <executable>true</executable>
<!--</configuration>--> </configuration>
<!--<executions>--> <executions>
<!--<execution>--> <execution>
<!--<goals>--> <goals>
<!--<goal>--> <goal>
<!--repackage--> repackage
<!--</goal>--> </goal>
<!--</goals>--> </goals>
<!--</execution>--> </execution>
<!--</executions>--> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.eluder.coveralls</groupId> <groupId>org.eluder.coveralls</groupId>

View file

@ -25,7 +25,6 @@ SOFTWARE.
package net.kemitix.checkstyle.ruleset.builder; package net.kemitix.checkstyle.ruleset.builder;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -37,7 +36,6 @@ import java.util.List;
* *
* @author Paul Campbell (pcampbell@kemitix.net) * @author Paul Campbell (pcampbell@kemitix.net)
*/ */
@Slf4j
@Getter @Getter
@Configuration @Configuration
@ConfigurationProperties @ConfigurationProperties

View file

@ -22,76 +22,41 @@ The ruleset includes checks from both the core Checkstyle library and from the S
## Usage ## Usage
To use this ruleset in your `maven-checkstyle-plugin` configuration add `checkstyle`, `sevntu-checkstyle-maven-plugin` and `kemitix-checktyle-ruleset` as dependencies of the `maven-checkstyle-plugin`. To use this ruleset add the plugin `kemitix-checktyle-ruleset-maven-plugin`.
The `maven-checkstyle-plugin` will be included automatically.
You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. The following goals implement increasingly strict rulesets:
Select the `configLocation` for the level of strictness required: * 1-layout
* 2-naming
* checkstyle-1-layout.xml * 3-javadoc
* checkstyle-2-naming.xml * 4-tweaks
* checkstyle-3-javadoc.xml * 5-complexity
* checkstyle-4-tweaks.xml
* checkstyle-5-complexity.xml
Only specify a single `configLocation` as each increasing level includes all the rules
from the previous.
```` ````
<properties> <properties>
<maven.checkstyle.plugin.version>2.17</maven.checkstyle.plugin.version>
<checkstyle.version>7.3</checkstyle.version>
<sevntu-checkstyle-maven-plugin.version>1.22.0</sevntu-checkstyle-maven-plugin.version>
<kemitix-checkstyle-ruleset.version>2.0.0</kemitix-checkstyle-ruleset.version> <kemitix-checkstyle-ruleset.version>2.0.0</kemitix-checkstyle-ruleset.version>
<kemitix-checkstyle-ruleset.level>5-complexity</kemitix-checkstyle-ruleset.level> <kemitix-checkstyle-ruleset.level>5-complexity</kemitix-checkstyle-ruleset.level>
</properties> </properties>
<build> <build>
<pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
<dependency>
<groupId>com.github.sevntu.checkstyle</groupId>
<artifactId>sevntu-checkstyle-maven-plugin</artifactId>
<version>${sevntu-checkstyle-maven-plugin.version}</version>
</dependency>
<dependency>
<groupId>net.kemitix</groupId> <groupId>net.kemitix</groupId>
<artifactId>kemitix-checkstyle-ruleset</artifactId> <artifactId>kemitix-checkstyle-ruleset-maven-plugin</artifactId>
<version>${kemitix-checkstyle-ruleset.version}</version> <version>${kemitix-checkstyle-ruleset.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml</configLocation>
</configuration>
</plugin><!-- maven-checkstyle-plugin -->
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<id>validate</id>
<phase>validate</phase> <phase>validate</phase>
<goals> <goals>
<goal>check</goal> <goal>${kemitix-checkstyle-ruleset.level}</goal>
<goal>checkstyle</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin><!-- maven-checkstyle-plugin --> </plugin>
</plugins> </plugins>
</build> </build>
<pluginRepositories> <pluginRepositories>
<pluginRepository> <pluginRepository>
<id>sevntu-maven</id> <id>sevntu-maven</id>

23
plugin-sample/LICENSE.txt Normal file
View file

@ -0,0 +1,23 @@
/*
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.
*/

44
plugin-sample/pom.xml Normal file
View file

@ -0,0 +1,44 @@
<?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>
<!-- don't use parent to avoid using grandparent's checkstyle configuration -->
<groupId>net.kemitix</groupId>
<artifactId>kemitix-checkstyle-ruleset-plugin-sample</artifactId>
<version>2.0.0-SNAPSHOT</version>
<properties>
<!--<java.version>1.8</java.version>-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>net.kemitix</groupId>
<artifactId>kemitix-checkstyle-ruleset-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>2-naming</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sevntu-maven</id>
<name>sevntu-maven</name>
<url>http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2</url>
</pluginRepository>
</pluginRepositories>
</project>

View file

@ -0,0 +1,38 @@
/*
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.sample;
/**
* Sample class to test the Kemitix Checkstyle Ruleset Maven Plugin against.
*
* @author Paul Campbell (paul.campbell@hubio.com)
*/
public class Sample {
public static void main(String[] args) {
System.out.println("Sample!");
}
}

23
plugin/LICENSE.txt Normal file
View file

@ -0,0 +1,23 @@
/*
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.
*/

104
plugin/pom.xml Normal file
View file

@ -0,0 +1,104 @@
<?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>
<parent>
<groupId>net.kemitix</groupId>
<artifactId>kemitix-checkstyle-ruleset-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>kemitix-checkstyle-ruleset-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Kemitix Checkstyle Ruleset Maven Plugin</name>
<description>Checkstyle configuration using the Kemitix Checkstyle Ruleset</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.version>3.3.9</maven.version>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-plugin-plugin.version>3.5</maven-plugin-plugin.version>
<maven-plugin-annotations.version>3.5</maven-plugin-annotations.version>
<mojo-executor.version>2.2.0</mojo-executor.version>
<lombok.version>1.16.12</lombok.version>
<map-builder.version>1.0.0</map-builder.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${maven-plugin-annotations.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor</artifactId>
<version>${mojo-executor.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.andrz</groupId>
<artifactId>map-builder</artifactId>
<version>${map-builder.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven-plugin-plugin.version}</version>
<executions>
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin><!-- maven-compiler-plugin -->
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>sevntu-maven</id>
<name>sevntu-maven</name>
<url>http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2</url>
</pluginRepository>
</pluginRepositories>
</project>

View file

@ -0,0 +1,116 @@
/*
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 lombok.Setter;
import lombok.val;
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.Parameter;
import org.apache.maven.project.MavenProject;
import org.twdata.maven.mojoexecutor.MojoExecutor;
/**
* Runs the Checkstyle Maven Plugin with the Kemitix Checkstyle Ruleset.
*
* @author Paul Campbell (pcampbell@kemitix.net)
*/
public abstract class AbstractCheckMojo extends AbstractMojo {
private static final String CHECKSTYLE_GROUPID = "com.puppycrawl.tools";
private static final String CHECKSTYLE_ARTIFACTID = "checkstyle";
private static final String SEVNTU_GROUPID = "com.github.sevntu.checkstyle";
private static final String SEVNTU_ARTIFACTID = "sevntu-checkstyle-maven-plugin";
private static final String KEMITIX_GROUPID = "net.kemitix";
private static final String KEMITIX_ARTIFACTID = "kemitix-checkstyle-ruleset";
private static final String APACHE_PLUGIN_GROUPID = "org.apache.maven.plugins";
private static final String APACHE_PLUGIN_ARTIFACTID = "maven-checkstyle-plugin";
private static final String CONFIG_LOCATION = "configLocation";
@Setter
@Parameter(defaultValue = "2.17")
private String mavenCheckstylePluginVersion;
@Setter
@Parameter(defaultValue = "7.3")
private String checkstyleVersion;
@Setter
@Parameter(defaultValue = "1.23.0")
private String sevntuVersion;
@Setter
@Parameter(defaultValue = "2.0.0-SNAPSHOT")
private String rulesetVersion;
@Setter
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject mavenProject;
@Setter
@Parameter(defaultValue = "${session}", readonly = true)
private MavenSession mavenSession;
@Component
private BuildPluginManager pluginManager;
/**
* Execute Checkstyle Check.
*
* @param level The level of config file to use.
*
* @throws MojoExecutionException on execution error
* @throws MojoFailureException on execution failure
*/
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);
val checkstylePlugin =
MojoExecutor.plugin(APACHE_PLUGIN_GROUPID, APACHE_PLUGIN_ARTIFACTID, mavenCheckstylePluginVersion,
MojoExecutor.dependencies(checkstyle, sevntu, ruleset)
);
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));
MojoExecutor.executeMojo(checkstylePlugin, "check", MojoExecutor.configuration(configLocation),
MojoExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager)
);
}
}

View file

@ -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");
}
}

View file

@ -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");
}
}

View file

@ -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");
}
}

View file

@ -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");
}
}

View file

@ -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");
}
}

View file

@ -0,0 +1,31 @@
/*
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.
*/
/**
* .
*
* @author Paul Campbell (pcampbell@kemitix.net)
*/
package net.kemitix.checkstyle.ruleset.plugin;

View file

@ -12,9 +12,16 @@
<name>Kemitix Checkstyle Ruleset (Parent)</name> <name>Kemitix Checkstyle Ruleset (Parent)</name>
<description>Parent POM for the Kemitix Checkstyle Ruleset and it's Builder</description> <description>Parent POM for the Kemitix Checkstyle Ruleset and it's Builder</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules> <modules>
<module>builder</module> <module>builder</module>
<module>ruleset</module> <module>ruleset</module>
<module>plugin</module>
<module>plugin-sample</module>
</modules> </modules>
<issueManagement> <issueManagement>