plugin: AbstractCheckMojo: replace abstract execute() with getLevel()
Child classes don't need to implement the execute() method now, but a getLevel() method instead.
This commit is contained in:
parent
6f9f07709f
commit
e46f8d5d1f
6 changed files with 35 additions and 27 deletions
|
@ -94,6 +94,13 @@ abstract class AbstractCheckMojo extends AbstractMojo {
|
||||||
this.pluginExecutor = pluginExecutor;
|
this.pluginExecutor = pluginExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||||
|
performCheck(getLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract String getLevel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute Checkstyle Check.
|
* Execute Checkstyle Check.
|
||||||
*
|
*
|
||||||
|
@ -118,7 +125,8 @@ abstract class AbstractCheckMojo extends AbstractMojo {
|
||||||
val checkstylePlugin = getPlugin(pluginVersion, checkstyleVersion, sevntuVersion);
|
val checkstylePlugin = getPlugin(pluginVersion, checkstyleVersion, sevntuVersion);
|
||||||
val configuration = pluginExecutor.configuration(
|
val configuration = pluginExecutor.configuration(
|
||||||
pluginExecutor.element(CONFIG_LOCATION, String.format("net/kemitix/checkstyle-%s.xml", level)),
|
pluginExecutor.element(CONFIG_LOCATION, String.format("net/kemitix/checkstyle-%s.xml", level)),
|
||||||
pluginExecutor.element(SOURCE_DIR, mavenProject.getBuild().getSourceDirectory())
|
pluginExecutor.element(SOURCE_DIR, mavenProject.getBuild()
|
||||||
|
.getSourceDirectory())
|
||||||
);
|
);
|
||||||
val environment = pluginExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager);
|
val environment = pluginExecutor.executionEnvironment(mavenProject, mavenSession, pluginManager);
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@ SOFTWARE.
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
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.LifecyclePhase;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
|
||||||
|
@ -37,15 +35,17 @@ import org.apache.maven.plugins.annotations.Mojo;
|
||||||
@Mojo(name = "5-complexity", defaultPhase = LifecyclePhase.VALIDATE)
|
@Mojo(name = "5-complexity", defaultPhase = LifecyclePhase.VALIDATE)
|
||||||
public final class ComplexityCheckMojo extends AbstractCheckMojo {
|
public final class ComplexityCheckMojo extends AbstractCheckMojo {
|
||||||
|
|
||||||
|
private static final String LEVEL = "5-complexity";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Mojo.
|
* Create the Mojo.
|
||||||
*/
|
*/
|
||||||
ComplexityCheckMojo() {
|
public ComplexityCheckMojo() {
|
||||||
super(new DefaultPluginExecutor());
|
super(new DefaultPluginExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
String getLevel() {
|
||||||
performCheck("5-complexity");
|
return LEVEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ SOFTWARE.
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
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.LifecyclePhase;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
|
||||||
|
@ -37,15 +35,17 @@ import org.apache.maven.plugins.annotations.Mojo;
|
||||||
@Mojo(name = "3-javadoc", defaultPhase = LifecyclePhase.VALIDATE)
|
@Mojo(name = "3-javadoc", defaultPhase = LifecyclePhase.VALIDATE)
|
||||||
public final class JavadocCheckMojo extends AbstractCheckMojo {
|
public final class JavadocCheckMojo extends AbstractCheckMojo {
|
||||||
|
|
||||||
|
private static final String LEVEL = "3-javadoc";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Mojo.
|
* Create the Mojo.
|
||||||
*/
|
*/
|
||||||
JavadocCheckMojo() {
|
public JavadocCheckMojo() {
|
||||||
super(new DefaultPluginExecutor());
|
super(new DefaultPluginExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
String getLevel() {
|
||||||
performCheck("3-javadoc");
|
return LEVEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ SOFTWARE.
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
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.LifecyclePhase;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
|
||||||
|
@ -37,15 +35,17 @@ import org.apache.maven.plugins.annotations.Mojo;
|
||||||
@Mojo(name = "1-layout", defaultPhase = LifecyclePhase.VALIDATE)
|
@Mojo(name = "1-layout", defaultPhase = LifecyclePhase.VALIDATE)
|
||||||
public final class LayoutCheckMojo extends AbstractCheckMojo {
|
public final class LayoutCheckMojo extends AbstractCheckMojo {
|
||||||
|
|
||||||
|
private static final String LEVEL = "1-layout";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Mojo.
|
* Create the Mojo.
|
||||||
*/
|
*/
|
||||||
LayoutCheckMojo() {
|
public LayoutCheckMojo() {
|
||||||
super(new DefaultPluginExecutor());
|
super(new DefaultPluginExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
String getLevel() {
|
||||||
performCheck("1-layout");
|
return LEVEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ SOFTWARE.
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
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.LifecyclePhase;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
|
||||||
|
@ -37,15 +35,17 @@ import org.apache.maven.plugins.annotations.Mojo;
|
||||||
@Mojo(name = "2-naming", defaultPhase = LifecyclePhase.VALIDATE)
|
@Mojo(name = "2-naming", defaultPhase = LifecyclePhase.VALIDATE)
|
||||||
public final class NamingCheckMojo extends AbstractCheckMojo {
|
public final class NamingCheckMojo extends AbstractCheckMojo {
|
||||||
|
|
||||||
|
private static final String LEVEL = "2-naming";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Mojo.
|
* Create the Mojo.
|
||||||
*/
|
*/
|
||||||
NamingCheckMojo() {
|
public NamingCheckMojo() {
|
||||||
super(new DefaultPluginExecutor());
|
super(new DefaultPluginExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
String getLevel() {
|
||||||
performCheck("2-naming");
|
return LEVEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ SOFTWARE.
|
||||||
|
|
||||||
package net.kemitix.checkstyle.ruleset.plugin;
|
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.LifecyclePhase;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
|
|
||||||
|
@ -37,15 +35,17 @@ import org.apache.maven.plugins.annotations.Mojo;
|
||||||
@Mojo(name = "4-tweaks", defaultPhase = LifecyclePhase.VALIDATE)
|
@Mojo(name = "4-tweaks", defaultPhase = LifecyclePhase.VALIDATE)
|
||||||
public final class TweaksCheckMojo extends AbstractCheckMojo {
|
public final class TweaksCheckMojo extends AbstractCheckMojo {
|
||||||
|
|
||||||
|
private static final String LEVEL = "4-tweaks";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Mojo.
|
* Create the Mojo.
|
||||||
*/
|
*/
|
||||||
TweaksCheckMojo() {
|
public TweaksCheckMojo() {
|
||||||
super(new DefaultPluginExecutor());
|
super(new DefaultPluginExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
String getLevel() {
|
||||||
performCheck("4-tweaks");
|
return LEVEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue