plugin: added
This commit is contained in:
parent
c254afcca7
commit
dc639da079
7 changed files with 342 additions and 104 deletions
67
README.md
67
README.md
|
@ -22,76 +22,45 @@ 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.
|
Select the level 1-5 of strictness required:
|
||||||
|
|
||||||
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>
|
<kemitix-checkstyle-ruleset.level>2</kemitix-checkstyle-ruleset.level>
|
||||||
<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.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>2.0.0</version>
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<configLocation>net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml</configLocation>
|
<level>${kemitix-checkstyle-ruleset.level}</level>
|
||||||
</configuration>
|
</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>
|
||||||
<goal>checkstyle</goal>
|
check
|
||||||
|
</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>
|
||||||
|
|
|
@ -22,76 +22,45 @@ 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.
|
Select the level 1-5 of strictness required:
|
||||||
|
|
||||||
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>
|
<kemitix-checkstyle-ruleset.level>2</kemitix-checkstyle-ruleset.level>
|
||||||
<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.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>2.0.0</version>
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<configLocation>net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml</configLocation>
|
<level>${kemitix-checkstyle-ruleset.level}</level>
|
||||||
</configuration>
|
</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>
|
||||||
<goal>checkstyle</goal>
|
check
|
||||||
|
</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/LICENSE.txt
Normal file
23
plugin/LICENSE.txt
Normal 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.
|
||||||
|
*/
|
95
plugin/pom.xml
Normal file
95
plugin/pom.xml
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
<?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-parent</artifactId>
|
||||||
|
<version>2.2.0</version>
|
||||||
|
<relativePath/>
|
||||||
|
</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-plugin-plugin.version>3.5</maven-plugin-plugin.version>
|
||||||
|
<maven-plugin-annotations.version>3.5</maven-plugin-annotations.version>
|
||||||
|
<maven.checkstyle.plugin.version>2.17</maven.checkstyle.plugin.version>
|
||||||
|
<checkstyle.version>7.3</checkstyle.version>
|
||||||
|
<sevntu-checkstyle-maven-plugin.version>1.23.0</sevntu-checkstyle-maven-plugin.version>
|
||||||
|
<kemitix-checkstyle-ruleset.version>2.0.0-SNAPSHOT</kemitix-checkstyle-ruleset.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>
|
||||||
|
</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>
|
|
@ -0,0 +1,150 @@
|
||||||
|
/*
|
||||||
|
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 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 {
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
|
||||||
|
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<String, String> levelConfig = new MapBuilder<String, String>().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;
|
||||||
|
|
||||||
|
@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 = "5")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Parameter(defaultValue = "${project}", readonly = true)
|
||||||
|
private MavenProject mavenProject;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Parameter(defaultValue = "${session}", readonly = true)
|
||||||
|
private MavenSession mavenSession;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
private BuildPluginManager pluginManager;
|
||||||
|
|
||||||
|
private static String getConfigFile(final String level) {
|
||||||
|
return String.format("checkstyle-%s.xml", levelConfig.getOrDefault(level, COMPLEXITY));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute Checkstyle Check.
|
||||||
|
*
|
||||||
|
* @throws MojoExecutionException on execution error
|
||||||
|
* @throws MojoFailureException on execution failure
|
||||||
|
*/
|
||||||
|
public final void execute() 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, "net/kemitix/" + getConfigFile(level));
|
||||||
|
|
||||||
|
getLog().info(
|
||||||
|
"Running Checkstyle " + checkstyleVersion + " (sevntu: " + sevntuVersion + ") with " + getConfigFile(
|
||||||
|
level));
|
||||||
|
MojoExecutor.executeMojo(checkstylePlugin, "check", MojoExecutor.configuration(configLocation),
|
||||||
|
MojoExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
1
pom.xml
1
pom.xml
|
@ -20,6 +20,7 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>builder</module>
|
<module>builder</module>
|
||||||
<module>ruleset</module>
|
<module>ruleset</module>
|
||||||
|
<module>plugin</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
|
|
Loading…
Reference in a new issue