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 dependency on maven-reporting-impl #1121

Merged
merged 4 commits into from Dec 25, 2020
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
20 changes: 0 additions & 20 deletions jacoco-maven-plugin/pom.xml
Expand Up @@ -31,22 +31,6 @@
<maven>3.0</maven>
</prerequisites>

<dependencyManagement>
<dependencies>
<!-- maven-reporting-impl and slight update of version of its transitive dependency on commons-collections -->
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down Expand Up @@ -74,10 +58,6 @@
<artifactId>maven-reporting-api</artifactId>
<version>${project.prerequisites.maven}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
46 changes: 23 additions & 23 deletions jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java
Expand Up @@ -16,12 +16,12 @@
import java.util.List;
import java.util.Locale;

import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.doxia.sink.SinkFactory;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenMultiPageReport;
import org.apache.maven.reporting.MavenReportException;
import org.jacoco.report.IReportGroupVisitor;
import org.jacoco.report.IReportVisitor;
Expand All @@ -30,7 +30,8 @@
* Base class for creating a code coverage report for tests of a single project
* in multiple formats (HTML, XML, and CSV).
*/
public abstract class AbstractReportMojo extends AbstractMavenReport {
public abstract class AbstractReportMojo extends AbstractMojo
implements MavenMultiPageReport {

/**
* Encoding of the generated reports.
Expand Down Expand Up @@ -86,29 +87,16 @@ public abstract class AbstractReportMojo extends AbstractMavenReport {
@Parameter(property = "project", readonly = true)
MavenProject project;

/**
* Doxia Site Renderer.
*/
@Component
Renderer siteRenderer;

public String getDescription(final Locale locale) {
return getName(locale) + " Coverage Report.";
}

@Override
public boolean isExternalReport() {
return true;
}

@Override
protected MavenProject getProject() {
return project;
}

@Override
protected Renderer getSiteRenderer() {
return siteRenderer;
public String getCategoryName() {
return CATEGORY_PROJECT_REPORTS;
}

/**
Expand All @@ -129,7 +117,6 @@ List<String> getExcludes() {
return excludes;
}

@Override
public boolean canGenerateReport() {
if (skip) {
getLog().info(
Expand All @@ -153,11 +140,25 @@ public boolean canGenerateReport() {

abstract boolean canGenerateReportRegardingClassesDirectory();

public void generate(
@SuppressWarnings("deprecation") final org.codehaus.doxia.sink.Sink sink,
final Locale locale) throws MavenReportException {
generate(sink, null, locale);
}

public void generate(final org.apache.maven.doxia.sink.Sink sink,
final SinkFactory sinkFactory, final Locale locale)
throws MavenReportException {
if (!canGenerateReport()) {
return;
}
executeReport(locale);
}

/**
* This method is called when the report generation is invoked directly as a
* standalone Mojo.
*/
@Override
public void execute() throws MojoExecutionException {
if (!canGenerateReport()) {
return;
Expand All @@ -170,8 +171,7 @@ public void execute() throws MojoExecutionException {
}
}

@Override
protected void executeReport(final Locale locale)
private void executeReport(final Locale locale)
throws MavenReportException {
try {
final ReportSupport support = new ReportSupport(getLog());
Expand Down
3 changes: 1 addition & 2 deletions jacoco-maven-plugin/src/org/jacoco/maven/FileFilter.java
Expand Up @@ -17,7 +17,6 @@
import java.io.IOException;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;

Expand Down Expand Up @@ -94,7 +93,7 @@ public String getExcludes() {
private String buildPattern(final List<String> patterns,
final String defaultPattern) {
String pattern = defaultPattern;
if (CollectionUtils.isNotEmpty(patterns)) {
if (patterns != null && !patterns.isEmpty()) {
pattern = StringUtils.join(patterns.iterator(), ",");
}
return pattern;
Expand Down
Expand Up @@ -107,7 +107,7 @@ void loadExecutionData(final ReportSupport support) throws IOException {

final FileFilter filter = new FileFilter(dataFileIncludes,
dataFileExcludes);
loadExecutionData(support, filter, getProject().getBasedir());
loadExecutionData(support, filter, project.getBasedir());
for (final MavenProject dependency : findDependencies(
Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME,
Artifact.SCOPE_PROVIDED, Artifact.SCOPE_TEST)) {
Expand Down Expand Up @@ -141,12 +141,10 @@ void createReport(final IReportGroupVisitor visitor,
}
}

@Override
protected String getOutputDirectory() {
return outputDirectory.getAbsolutePath();
public File getReportOutputDirectory() {
return outputDirectory;
}

@Override
public void setReportOutputDirectory(final File reportOutputDirectory) {
if (reportOutputDirectory != null && !reportOutputDirectory
.getAbsolutePath().endsWith("jacoco-aggregate")) {
Expand All @@ -168,7 +166,7 @@ public String getName(final Locale locale) {
private List<MavenProject> findDependencies(final String... scopes) {
final List<MavenProject> result = new ArrayList<MavenProject>();
final List<String> scopeList = Arrays.asList(scopes);
for (final Object dependencyObject : getProject().getDependencies()) {
for (final Object dependencyObject : project.getDependencies()) {
final Dependency dependency = (Dependency) dependencyObject;
if (scopeList.contains(dependency.getScope())) {
final MavenProject project = findProjectFromReactor(dependency);
Expand All @@ -192,7 +190,7 @@ private MavenProject findProjectFromReactor(final Dependency d) {
try {
depVersionAsRange = VersionRange
.createFromVersionSpec(d.getVersion());
} catch (InvalidVersionSpecificationException e) {
} catch (final InvalidVersionSpecificationException e) {
throw new AssertionError(e);
}

Expand Down
10 changes: 4 additions & 6 deletions jacoco-maven-plugin/src/org/jacoco/maven/ReportITMojo.java
Expand Up @@ -58,7 +58,7 @@ boolean canGenerateReportRegardingDataFiles() {

@Override
boolean canGenerateReportRegardingClassesDirectory() {
return new File(getProject().getBuild().getOutputDirectory()).exists();
return new File(project.getBuild().getOutputDirectory()).exists();
}

@Override
Expand All @@ -76,16 +76,14 @@ void addFormatters(final ReportSupport support, final Locale locale)
@Override
void createReport(final IReportGroupVisitor visitor,
final ReportSupport support) throws IOException {
support.processProject(visitor, title, getProject(), getIncludes(),
support.processProject(visitor, title, project, getIncludes(),
getExcludes(), sourceEncoding);
}

@Override
protected String getOutputDirectory() {
return outputDirectory.getAbsolutePath();
public File getReportOutputDirectory() {
return outputDirectory;
}

@Override
public void setReportOutputDirectory(final File reportOutputDirectory) {
if (reportOutputDirectory != null && !reportOutputDirectory
.getAbsolutePath().endsWith("jacoco-it")) {
Expand Down
10 changes: 4 additions & 6 deletions jacoco-maven-plugin/src/org/jacoco/maven/ReportMojo.java
Expand Up @@ -53,7 +53,7 @@ boolean canGenerateReportRegardingDataFiles() {

@Override
boolean canGenerateReportRegardingClassesDirectory() {
return new File(getProject().getBuild().getOutputDirectory()).exists();
return new File(project.getBuild().getOutputDirectory()).exists();
}

@Override
Expand All @@ -71,16 +71,14 @@ void addFormatters(final ReportSupport support, final Locale locale)
@Override
void createReport(final IReportGroupVisitor visitor,
final ReportSupport support) throws IOException {
support.processProject(visitor, title, getProject(), getIncludes(),
support.processProject(visitor, title, project, getIncludes(),
getExcludes(), sourceEncoding);
}

@Override
protected String getOutputDirectory() {
return outputDirectory.getAbsolutePath();
public File getReportOutputDirectory() {
return outputDirectory;
}

@Override
public void setReportOutputDirectory(final File reportOutputDirectory) {
if (reportOutputDirectory != null && !reportOutputDirectory
.getAbsolutePath().endsWith("jacoco")) {
Expand Down
2 changes: 2 additions & 0 deletions org.jacoco.doc/docroot/doc/changes.html
Expand Up @@ -34,6 +34,8 @@ <h3>Non-functional Changes</h3>
<li>JaCoCo now depends on ASM 9.0
(GitHub <a href="https://github.com/jacoco/jacoco/issues/1094">#1094</a>,
<a href="https://github.com/jacoco/jacoco/issues/1097">#1097</a>).</li>
<li>Maven plug-in has no dependency on <code>maven-reporting-impl</code> any more
(GitHub <a href="https://github.com/jacoco/jacoco/issues/1121">#1121</a>).</li>
Comment on lines +37 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this is pure internal non-functional change, so I do not think that we need this changelog entry and Git commit message is enough. Similar #645 wasn't mentioned either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it as it solves two tickets. But I also agree with your point of view.

</ul>


Expand Down