Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove misleading parameters of jacoco-maven-plugin goals #827

Merged
merged 2 commits into from Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 22 additions & 8 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,15 +184,13 @@ AgentOptions createAgentOptions() {
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);
Expand Down
36 changes: 0 additions & 36 deletions jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java
Expand Up @@ -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;
Expand All @@ -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<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;
Godin marked this conversation as resolved.
Show resolved Hide resolved

/**
* Flag used to suppress execution.
*/
Expand Down Expand Up @@ -90,22 +72,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
17 changes: 16 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,20 @@
@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<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 +76,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
5 changes: 5 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Expand Up @@ -59,6 +59,11 @@ <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 <code>includes</code> and
<code>excludes</code> from <code>dump</code>, <code>merge</code> and
<code>restore-instrumented-classes</code> 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