Merge pull request #7 from kemitix/upgrade-checkstyle-to-7.5.1

Upgrade checkstyle to 7.5.1
This commit is contained in:
Paul Campbell 2017-02-08 11:05:17 +00:00 committed by GitHub
commit 472758f1dc
3 changed files with 46 additions and 15 deletions

View file

@ -27,6 +27,9 @@ package net.kemitix.checkstyle.sample;
/**
* Sample class to test the Kemitix Checkstyle Ruleset Maven Plugin against.
*
* <p>This sample is deliberately only valid for level 1-layout and 2-naming. The plugin should report errors for levels
* 3-javadoc and above.</p>
*
* @author Paul Campbell (paul.campbell@hubio.com)
*/
public class Sample {

View file

@ -30,6 +30,11 @@
<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-maven-plugin.version>1.0.0</properties-maven-plugin.version>
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
<checkstyle.version>7.5.1</checkstyle.version>
<sevntu.version>1.23.0</sevntu.version>
</properties>
<dependencies>
@ -96,6 +101,34 @@
<target>1.8</target>
</configuration>
</plugin><!-- maven-compiler-plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>${properties-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>maven-checkstyle-plugin.version</name>
<value>${maven-checkstyle-plugin.version}</value>
</property>
<property>
<name>checkstyle.version</name>
<value>${checkstyle.version}</value>
</property>
<property>
<name>sevntu.version</name>
<value>${sevntu.version}</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin><!-- properties-maven-plugin -->
</plugins>
</build>
<profiles>

View file

@ -62,19 +62,7 @@ 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.4")
private String checkstyleVersion;
@Setter
@Parameter(defaultValue = "1.23.0")
private String sevntuVersion;
@Setter
@Parameter(defaultValue = "2.1.0-SNAPSHOT")
@Parameter(defaultValue = "${project.version}")
private String rulesetVersion;
@Setter
@ -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);
@ -107,8 +101,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)
);