plugin:AbstractCheckMojo: load dependency versions from plugin pom.xml

This commit is contained in:
Paul Campbell 2017-02-08 10:56:55 +00:00
parent e951d2c99b
commit ca01a08e81
2 changed files with 39 additions and 12 deletions

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

@ -61,18 +61,6 @@ public abstract class AbstractCheckMojo extends AbstractMojo {
private static final String CONFIG_LOCATION = "configLocation"; private static final String CONFIG_LOCATION = "configLocation";
@Setter
@Parameter(defaultValue = "2.17")
private String mavenCheckstylePluginVersion;
@Setter
@Parameter(defaultValue = "7.5.1")
private String checkstyleVersion;
@Setter
@Parameter(defaultValue = "1.23.0")
private String sevntuVersion;
@Setter @Setter
@Parameter(defaultValue = "${project.version}") @Parameter(defaultValue = "${project.version}")
private String rulesetVersion; private String rulesetVersion;
@ -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);