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. * 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) * @author Paul Campbell (paul.campbell@hubio.com)
*/ */
public class Sample { public class Sample {

View file

@ -30,6 +30,11 @@
<mojo-executor.version>2.2.0</mojo-executor.version> <mojo-executor.version>2.2.0</mojo-executor.version>
<lombok.version>1.16.12</lombok.version> <lombok.version>1.16.12</lombok.version>
<map-builder.version>1.0.0</map-builder.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> </properties>
<dependencies> <dependencies>
@ -96,6 +101,34 @@
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin><!-- maven-compiler-plugin --> </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> </plugins>
</build> </build>
<profiles> <profiles>

View file

@ -62,19 +62,7 @@ public abstract class AbstractCheckMojo extends AbstractMojo {
private static final String CONFIG_LOCATION = "configLocation"; private static final String CONFIG_LOCATION = "configLocation";
@Setter @Setter
@Parameter(defaultValue = "2.17") @Parameter(defaultValue = "${project.version}")
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")
private String rulesetVersion; private String rulesetVersion;
@Setter @Setter
@ -97,6 +85,12 @@ public abstract class AbstractCheckMojo extends AbstractMojo {
* @throws MojoFailureException on execution failure * @throws MojoFailureException on execution failure
*/ */
protected final void performCheck(final String level) throws MojoExecutionException, MojoFailureException { 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 checkstyle = MojoExecutor.dependency(CHECKSTYLE_GROUPID, CHECKSTYLE_ARTIFACTID, checkstyleVersion);
val sevntu = MojoExecutor.dependency(SEVNTU_GROUPID, SEVNTU_ARTIFACTID, sevntuVersion); val sevntu = MojoExecutor.dependency(SEVNTU_GROUPID, SEVNTU_ARTIFACTID, sevntuVersion);
val ruleset = MojoExecutor.dependency(KEMITIX_GROUPID, KEMITIX_ARTIFACTID, rulesetVersion); val ruleset = MojoExecutor.dependency(KEMITIX_GROUPID, KEMITIX_ARTIFACTID, rulesetVersion);
@ -107,8 +101,9 @@ public abstract class AbstractCheckMojo extends AbstractMojo {
val configLocation = val configLocation =
MojoExecutor.element(CONFIG_LOCATION, String.format("net/kemitix/checkstyle-%s.xml", level)); MojoExecutor.element(CONFIG_LOCATION, String.format("net/kemitix/checkstyle-%s.xml", level));
getLog().info( getLog().info(String.format("Running Checkstyle %s (sevntu: %s) with ruleset %s (%s)", checkstyleVersion,
String.format("Running Checkstyle %s (sevntu: %s) with %s", checkstyleVersion, sevntuVersion, level)); sevntuVersion, level, rulesetVersion
));
MojoExecutor.executeMojo(checkstylePlugin, "check", MojoExecutor.configuration(configLocation), MojoExecutor.executeMojo(checkstylePlugin, "check", MojoExecutor.configuration(configLocation),
MojoExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager) MojoExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager)
); );