Skip to content

Commit

Permalink
Remove misleading parameters of jacoco-maven-plugin goals
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Jan 10, 2019
1 parent db5fefe commit 3dfb48f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 43 deletions.
28 changes: 22 additions & 6 deletions jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java
Expand Up @@ -12,6 +12,7 @@
package org.jacoco.maven;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Properties;

Expand Down Expand Up @@ -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<String> 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<String> 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
Expand Down Expand Up @@ -168,14 +184,14 @@ AgentOptions createAgentOptions() {
if (append != null) {
agentOptions.setAppend(append.booleanValue());
}
if (getIncludes() != null && !getIncludes().isEmpty()) {
final String agentIncludes = StringUtils.join(getIncludes()
.iterator(), ":");
if (includes != null && !includes.isEmpty()) {
final String agentIncludes = StringUtils.join(includes.iterator(),
":");
agentOptions.setIncludes(agentIncludes);
}
if (getExcludes() != null && !getExcludes().isEmpty()) {
final String agentExcludes = StringUtils.join(getExcludes()
.iterator(), ":");
if (excludes != null && !excludes.isEmpty()) {
final String agentExcludes = StringUtils.join(excludes.iterator(),
":");
agentOptions.setExcludes(agentExcludes);
}
if (exclClassLoaders != null) {
Expand Down
34 changes: 0 additions & 34 deletions jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java
Expand Up @@ -30,22 +30,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<String> 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<String> excludes;

/**
* Flag used to suppress execution.
*/
Expand Down Expand Up @@ -90,22 +74,4 @@ protected final MavenProject getProject() {
return project;
}

/**
* Returns the list of class files to include.
*
* @return class files to include, may contain wildcard characters
*/
protected List<String> getIncludes() {
return includes;
}

/**
* Returns the list of class files to exclude.
*
* @return class files to exclude, may contain wildcard characters
*/
protected List<String> getExcludes() {
return excludes;
}

}
17 changes: 15 additions & 2 deletions jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java
Expand Up @@ -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<String> 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<String> excludes;

private boolean violations;

private boolean canCheckCoverage() {
Expand Down Expand Up @@ -169,8 +183,7 @@ private void executeCheck() throws MojoExecutionException {
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(
Expand Down
18 changes: 17 additions & 1 deletion jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java
Expand Up @@ -23,6 +23,7 @@
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;
Expand All @@ -44,6 +45,21 @@
@Mojo(name = "instrument", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true)
public class InstrumentMojo extends AbstractJacocoMojo {

/**
* 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<String> 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<String> excludes;

@Override
public void executeMojo() throws MojoExecutionException,
MojoFailureException {
Expand All @@ -61,7 +77,7 @@ public void executeMojo() throws MojoExecutionException,

final List<String> fileNames;
try {
fileNames = new FileFilter(this.getIncludes(), this.getExcludes())
fileNames = new FileFilter(includes, excludes)
.getFileNames(classesDir);
} catch (final IOException e1) {
throw new MojoExecutionException(
Expand Down
4 changes: 4 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Expand Up @@ -59,6 +59,10 @@ <h3>Fixed Bugs</h3>
<li><code>synthetic</code> methods that represent Kotlin <code>suspend</code>
functions should not be ignored
(GitHub <a href="https://github.com/jacoco/jacoco/issues/804">#804</a>).</li>
<li>Removed misleading parameters "includes" and "excludes" from "dump",
"merge" and "restore-instrumented-classes" goals of jacoco-maven-plugin,
because they have no effect
(GitHub <a href="https://github.com/jacoco/jacoco/issues/827">#827</a>).</li>
</ul>

<h3>Non-functional Changes</h3>
Expand Down

0 comments on commit 3dfb48f

Please sign in to comment.