From ee1324d7dd35de7781a452932fa4701d2f410c3f Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> Date: Thu, 10 Jan 2019 22:06:42 +0100 Subject: Remove misleading parameters of jacoco-maven-plugin goals (#827) --- .../src/org/jacoco/maven/AbstractAgentMojo.java | 30 +++++++++++++----- .../src/org/jacoco/maven/AbstractJacocoMojo.java | 36 ---------------------- .../src/org/jacoco/maven/CheckMojo.java | 17 ++++++++-- .../src/org/jacoco/maven/InstrumentMojo.java | 17 +++++++++- 4 files changed, 53 insertions(+), 47 deletions(-) (limited to 'jacoco-maven-plugin') diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java index 1d3f34e6..cc85b7f7 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java @@ -12,6 +12,7 @@ package org.jacoco.maven; import java.io.File; +import java.util.List; import java.util.Map; import java.util.Properties; @@ -57,6 +58,21 @@ public abstract class AbstractAgentMojo extends AbstractJacocoMojo { */ @Parameter(property = "jacoco.append") Boolean append; + + /** + * A list of class names to include in instrumentation. May use wildcard + * characters (* and ?). When not specified everything will be included. + */ + @Parameter + private List includes; + + /** + * A list of class names to exclude from instrumentation. May use wildcard + * characters (* and ?). When not specified nothing will be excluded. + */ + @Parameter + private List excludes; + /** * A list of class loader names, that should be excluded from execution * analysis. The list entries are separated by a colon (:) and may use @@ -168,15 +184,13 @@ public abstract class AbstractAgentMojo extends AbstractJacocoMojo { if (append != null) { agentOptions.setAppend(append.booleanValue()); } - if (getIncludes() != null && !getIncludes().isEmpty()) { - final String agentIncludes = StringUtils.join(getIncludes() - .iterator(), ":"); - agentOptions.setIncludes(agentIncludes); + if (includes != null && !includes.isEmpty()) { + agentOptions + .setIncludes(StringUtils.join(includes.iterator(), ":")); } - if (getExcludes() != null && !getExcludes().isEmpty()) { - final String agentExcludes = StringUtils.join(getExcludes() - .iterator(), ":"); - agentOptions.setExcludes(agentExcludes); + if (excludes != null && !excludes.isEmpty()) { + agentOptions + .setExcludes(StringUtils.join(excludes.iterator(), ":")); } if (exclClassLoaders != null) { agentOptions.setExclClassloader(exclClassLoaders); diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java index d1612ab6..3ed86ec0 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java @@ -11,8 +11,6 @@ *******************************************************************************/ package org.jacoco.maven; -import java.util.List; - import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -30,22 +28,6 @@ public abstract class AbstractJacocoMojo extends AbstractMojo { @Parameter(property = "project", readonly = true) private MavenProject project; - /** - * A list of class files to include in instrumentation/analysis/reports. May - * use wildcard characters (* and ?). When not specified everything will be - * included. - */ - @Parameter - private List includes; - - /** - * A list of class files to exclude from instrumentation/analysis/reports. - * May use wildcard characters (* and ?). When not specified nothing will be - * excluded. - */ - @Parameter - private List excludes; - /** * Flag used to suppress execution. */ @@ -90,22 +72,4 @@ public abstract class AbstractJacocoMojo extends AbstractMojo { return project; } - /** - * Returns the list of class files to include. - * - * @return class files to include, may contain wildcard characters - */ - protected List getIncludes() { - return includes; - } - - /** - * Returns the list of class files to exclude. - * - * @return class files to exclude, may contain wildcard characters - */ - protected List getExcludes() { - return excludes; - } - } diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java index ad021b37..3b46f8ed 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java @@ -128,6 +128,20 @@ public class CheckMojo extends AbstractJacocoMojo implements IViolationsOutput { @Parameter(defaultValue = "${project.build.directory}/jacoco.exec") private File dataFile; + /** + * A list of class files to include into analysis. May use wildcard + * characters (* and ?). When not specified everything will be included. + */ + @Parameter + private List includes; + + /** + * A list of class files to exclude from analysis. May use wildcard + * characters (* and ?). When not specified nothing will be excluded. + */ + @Parameter + private List excludes; + private boolean violations; private boolean canCheckCoverage() { @@ -169,8 +183,7 @@ public class CheckMojo extends AbstractJacocoMojo implements IViolationsOutput { try { final IReportVisitor visitor = support.initRootVisitor(); support.loadExecutionData(dataFile); - support.processProject(visitor, getProject(), this.getIncludes(), - this.getExcludes()); + support.processProject(visitor, getProject(), includes, excludes); visitor.visitEnd(); } catch (final IOException e) { throw new MojoExecutionException( diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java index c74cf6bb..df31b930 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java @@ -23,6 +23,7 @@ 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.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.jacoco.core.instr.Instrumenter; @@ -44,6 +45,20 @@ import org.jacoco.core.runtime.OfflineInstrumentationAccessGenerator; @Mojo(name = "instrument", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true) public class InstrumentMojo extends AbstractJacocoMojo { + /** + * A list of class files to include in instrumentation. May use wildcard + * characters (* and ?). When not specified everything will be included. + */ + @Parameter + private List includes; + + /** + * A list of class files to exclude from instrumentation. May use wildcard + * characters (* and ?). When not specified nothing will be excluded. + */ + @Parameter + private List excludes; + @Override public void executeMojo() throws MojoExecutionException, MojoFailureException { @@ -61,7 +76,7 @@ public class InstrumentMojo extends AbstractJacocoMojo { final List fileNames; try { - fileNames = new FileFilter(this.getIncludes(), this.getExcludes()) + fileNames = new FileFilter(includes, excludes) .getFileNames(classesDir); } catch (final IOException e1) { throw new MojoExecutionException( -- cgit v1.2.3