Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: trautonen/coveralls-maven-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.0
Choose a base ref
...
head repository: trautonen/coveralls-maven-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.1
Choose a head ref
  • 7 commits
  • 10 files changed
  • 1 contributor

Commits on Oct 11, 2014

  1. Verified

    This commit was signed with the committer’s verified signature.
    renovate-bot Mend Renovate
    Copy the full SHA
    72c26c5 View commit details

Commits on Oct 12, 2014

  1. Copy the full SHA
    135d1c9 View commit details
  2. Copy the full SHA
    c286316 View commit details

Commits on Oct 16, 2014

  1. Copy the full SHA
    76ae2d0 View commit details
  2. Copy the full SHA
    28e376d View commit details
  3. Copy the full SHA
    fae2cee View commit details
  4. Updated to version 3.0.1.

    trautonen committed Oct 16, 2014
    Copy the full SHA
    74de473 View commit details
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 3.0.0

- #48: Removed support for URL based source loading due to Coveralls changes
- #42, #45, #46: Support Coveralls new GitHub based source view
- #40: Proper multi-module support and report aggregation
- #37, #41: Disclaimer for Java 8 usage


## 2.2.0

- #31: Improved error messages for Coveralls API failures
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ Set up the Coveralls maven plugin in the build section of the project pom.xml:
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<configuration>
<repoToken>yourcoverallsprojectrepositorytoken</repoToken>
</configuration>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
<packaging>maven-plugin</packaging>

<name>coveralls-maven-plugin</name>
2 changes: 1 addition & 1 deletion sample/pom.xml
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
<configuration>
<sourceDirectories>
<sourceDirectory>module1/src/main/resources</sourceDirectory>
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@
import org.eluder.coveralls.maven.plugin.service.Travis;
import org.eluder.coveralls.maven.plugin.source.SourceCallback;
import org.eluder.coveralls.maven.plugin.source.SourceLoader;
import org.eluder.coveralls.maven.plugin.source.UniqueSourceCallback;
import org.eluder.coveralls.maven.plugin.util.CoverageParsersFactory;
import org.eluder.coveralls.maven.plugin.util.SourceLoaderFactory;

@@ -310,6 +311,7 @@ protected SourceCallback createSourceCallbackChain(final JsonWriter writer, fina
chain = coverageTracingReporter;
reporters.add(coverageTracingReporter);
}
chain = new UniqueSourceCallback(chain);
return chain;
}

39 changes: 4 additions & 35 deletions src/main/java/org/eluder/coveralls/maven/plugin/Environment.java
Original file line number Diff line number Diff line change
@@ -26,12 +26,8 @@
* %[license]
*/

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

import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.eluder.coveralls.maven.plugin.service.ServiceSetup;

@@ -55,31 +51,13 @@ public Environment(final CoverallsReportMojo mojo, final Iterable<ServiceSetup>
}

public void setup() {
setupSourceDirectories();
setupService();
verify();
}

private void setupSourceDirectories() {
if (mojo.sourceDirectories == null || mojo.sourceDirectories.isEmpty()) {
List<File> directories = new ArrayList<File>();
collectSourceDirectories(mojo.project, directories);
mojo.sourceDirectories = directories;
}
if (mojo.sourceDirectories == null || mojo.sourceDirectories.isEmpty()) {
throw new IllegalArgumentException("No source directories set up");
}
logSourceDirectories();
}

private void collectSourceDirectories(final MavenProject project, final List<File> directories) {
for (String sourceRoot : project.getCompileSourceRoots()) {
File directory = new File(sourceRoot);
if (directory.exists() && directory.isDirectory()) {
directories.add(directory);
}
}
for (MavenProject collectedProject : project.getCollectedProjects()) {
collectSourceDirectories(collectedProject, directories);
private void verify() {
if (mojo.sourceEncoding == null) {
throw new IllegalArgumentException("Source encoding not set, use <sourceEncoding> configuration option or set project wide property <project.build.sourceEncoding>");
}
}

@@ -129,13 +107,4 @@ private void setupEnvironment(final ServiceSetup service) {
mojo.serviceEnvironment = environment;
}
}

private void logSourceDirectories() {
if (mojo.getLog().isDebugEnabled()) {
mojo.getLog().debug("Using " + mojo.sourceDirectories.size() + " source directories to scan source files:");
for (File sourceDirectory : mojo.sourceDirectories) {
mojo.getLog().debug("- " + sourceDirectory.getAbsolutePath());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.eluder.coveralls.maven.plugin.source;

/*
* #[license]
* coveralls-maven-plugin
* %%
* Copyright (C) 2013 - 2014 Tapio Rautonen
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* %[license]
*/

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

import org.eluder.coveralls.maven.plugin.ProcessingException;
import org.eluder.coveralls.maven.plugin.domain.Source;

/**
* Source callback that tracks passed by source files and provides only unique
* source files to the delegate. Note that the implementation is not thread
* safe so the {@link #onSource(org.eluder.coveralls.maven.plugin.domain.Source)}
* can be called only from single thread concurrently.
*/
public class UniqueSourceCallback implements SourceCallback {

private static final String LINES_SEPARATOR = "#";

private final Set<String> cache = new HashSet<String>();
private final SourceCallback delegate;

public UniqueSourceCallback(final SourceCallback delegate) {
this.delegate = delegate;
}

@Override
public void onSource(final Source source) throws ProcessingException, IOException {
String key = getKey(source);
if (!cache.contains(key)) {
cache.add(key);
delegate.onSource(source);
}
}

private String getKey(final Source source) {
return source.getFullName() + LINES_SEPARATOR + getRelevantLines(source);
}

private int getRelevantLines(final Source source) {
int relevant = 0;
for (Integer cov : source.getCoverage()) {
if (cov != null) {
relevant++;
}
}
return relevant;
}
}
Original file line number Diff line number Diff line change
@@ -150,6 +150,7 @@ public Log getLog() {
}
};
mojo.project = projectMock;
mojo.sourceEncoding = "UTF-8";

when(modelMock.getReporting()).thenReturn(reportingMock);
when(reportingMock.getOutputDirectory()).thenReturn(folder.getRoot().getAbsolutePath());
Original file line number Diff line number Diff line change
@@ -26,34 +26,26 @@
* %[license]
*/

import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.eluder.coveralls.maven.plugin.service.ServiceSetup;
import org.eluder.coveralls.maven.plugin.source.SourceLoader;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class EnvironmentTest {

@Rule
public TemporaryFolder folder = new TemporaryFolder();

private CoverallsReportMojo mojo;

@@ -66,29 +58,8 @@ public class EnvironmentTest {
@Mock
private ServiceSetup serviceMock;

@Mock
private MavenProject mavenProjectMock;

@Mock
private MavenProject mavenProjectMock2;
private File folder2;

@Mock
private MavenProject mavenProjectMock3;

@Mock
private MavenProject mavenProjectMock4;
private File folder4;

@Mock
private MavenProject mavenProjectMock5;
private File folder5;

@Before
public void init() throws Exception {
folder2 = folder.newFolder();
folder4 = folder.newFolder();
folder5 = folder.newFolder();
mojo = new CoverallsReportMojo() {
@Override
protected List<CoverageParser> createCoverageParsers(SourceLoader sourceLoader) {
@@ -101,15 +72,10 @@ public Log getLog() {
}
};
mojo.serviceName = "service";
mojo.project = mavenProjectMock;
mojo.sourceEncoding = "UTF-8";
when(logMock.isDebugEnabled()).thenReturn(true);
when(logMock.isInfoEnabled()).thenReturn(true);
when(serviceMock.isSelected()).thenReturn(true);
when(mavenProjectMock.getCollectedProjects()).thenReturn(Arrays.asList(mavenProjectMock2, mavenProjectMock3));
when(mavenProjectMock3.getCollectedProjects()).thenReturn(Arrays.asList(mavenProjectMock4, mavenProjectMock5));
when(mavenProjectMock2.getCompileSourceRoots()).thenReturn(Arrays.asList(folder2.getAbsolutePath()));
when(mavenProjectMock4.getCompileSourceRoots()).thenReturn(Arrays.asList(folder4.getAbsolutePath()));
when(mavenProjectMock5.getCompileSourceRoots()).thenReturn(Arrays.asList(folder5.getAbsolutePath()));
}

@Test(expected = IllegalArgumentException.class)
@@ -122,33 +88,18 @@ public void testMissingServices() {
new Environment(mojo, null);
}

@Test(expected = IllegalArgumentException.class)
public void testSetupWithoutSourceDirectories() {
when(mavenProjectMock.getCollectedProjects()).thenReturn(new ArrayList<MavenProject>());
create(Collections.<ServiceSetup>emptyList()).setup();
}

@Test
public void testSetupWithProjectSourceDirectories() {
create(Collections.<ServiceSetup>emptyList()).setup();
assertThat(mojo.sourceDirectories, contains(folder2.getAbsoluteFile(), folder4.getAbsoluteFile(), folder5.getAbsoluteFile()));
verify(logMock).debug("Using 3 source directories to scan source files:");
}

@Test
public void testSetupWithMojoSourceDirectories() {
mojo.sourceDirectories = Arrays.asList(folder.getRoot());
create(Collections.<ServiceSetup>emptyList()).setup();
assertThat(mojo.sourceDirectories, contains(folder.getRoot()));
verify(logMock).debug("Using 1 source directories to scan source files:");
}

@Test
public void testSetupWithoutServices() {
create(Collections.<ServiceSetup>emptyList()).setup();
assertEquals("service", mojo.serviceName);
}

@Test(expected = IllegalArgumentException.class)
public void testSetupWithoutSourceEncoding() {
mojo.sourceEncoding = null;
create(Arrays.asList(serviceMock)).setup();
}

@Test
public void testSetupWithIncompleteJob() {
when(serviceMock.getJobId()).thenReturn("");
Loading