diff options
3 files changed, 42 insertions, 8 deletions
diff --git a/jacoco-maven-plugin.test/it/it-report-aggregate/report/src/test/java/packagereport/ReportTest.java b/jacoco-maven-plugin.test/it/it-report-aggregate/report/src/test/java/packagereport/ReportTest.java new file mode 100644 index 00000000..a1be3ed4 --- /dev/null +++ b/jacoco-maven-plugin.test/it/it-report-aggregate/report/src/test/java/packagereport/ReportTest.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc R. Hoffmann - initial API and implementation + * + *******************************************************************************/ +package packagereport; + +import org.junit.Test; + +public class ReportTest { + + @Test + public void test() { + } + +} diff --git a/jacoco-maven-plugin.test/it/it-report-aggregate/verify.bsh b/jacoco-maven-plugin.test/it/it-report-aggregate/verify.bsh index 10e020fa..fbccdddf 100644 --- a/jacoco-maven-plugin.test/it/it-report-aggregate/verify.bsh +++ b/jacoco-maven-plugin.test/it/it-report-aggregate/verify.bsh @@ -10,21 +10,26 @@ * *******************************************************************************/ import org.codehaus.plexus.util.*; +import java.util.regex.*; String buildLog = FileUtils.fileRead( new File( basedir, "build.log" ) ); -if ( buildLog.indexOf( "/child1/target/jacoco.exec".replace('/', File.separatorChar) ) < 0 ) { +if ( !Pattern.compile( "Loading execution data file \\S*child1.target.jacoco.exec").matcher( buildLog ).find() ) { throw new RuntimeException( "Execution data from child1 was not loaded." ); } -if ( buildLog.indexOf( "/child1-test/target/jacoco.exec".replace('/', File.separatorChar) ) < 0 ) { +if ( !Pattern.compile( "Loading execution data file \\S*child1-test.target.jacoco.exec").matcher( buildLog ).find() ) { throw new RuntimeException( "Execution data from child1-test was not loaded." ); } -if ( buildLog.indexOf( "/child2/target/jacoco.exec".replace('/', File.separatorChar) ) < 0 ) { +if ( !Pattern.compile( "Loading execution data file \\S*child2.target.jacoco.exec").matcher( buildLog ).find() ) { throw new RuntimeException( "Execution data from child2 was not loaded." ); } +if ( !Pattern.compile( "Loading execution data file \\S*report.target.jacoco.exec").matcher( buildLog ).find() ) { + throw new RuntimeException( "Execution data from report was not loaded." ); +} + File reportChild1 = new File( basedir, "report/target/site/jacoco-aggregate/child1/index.html" ); if ( !reportChild1.isFile() ) { throw new RuntimeException( "Report for child1 was not created." ); diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/ReportAggregateMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/ReportAggregateMojo.java index 1c17682f..9a839d6e 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/ReportAggregateMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/ReportAggregateMojo.java @@ -30,14 +30,15 @@ import org.jacoco.report.IReportGroupVisitor; * Creates a structured code coverage report (HTML, XML, and CSV) from multiple * projects within reactor. The report is created from all modules this project * depends on. From those projects class and source files as well as JaCoCo - * execution data files will be collected. This also allows to create coverage + * execution data files will be collected. In addition execution data is + * collected from the project itself. This also allows to create coverage * reports when tests are in separate projects than the code under test, for * example in case of integration tests. * </p> * * <p> * Using the dependency scope allows to distinguish projects which contribute - * execution data but should not be part of the report itself: + * execution data but should not become part of the report: * </p> * * <ul> @@ -97,11 +98,17 @@ public class ReportAggregateMojo extends AbstractReportMojo { void loadExecutionData(final ReportSupport support) throws IOException { final FileFilter filter = new FileFilter(dataFileIncludes, dataFileExcludes); + loadExecutionData(support, filter, getProject().getBasedir()); for (final MavenProject dependency : findDependencies( Artifact.SCOPE_COMPILE, Artifact.SCOPE_TEST)) { - for (final File execFile : filter.getFiles(dependency.getBasedir())) { - support.loadExecutionData(execFile); - } + loadExecutionData(support, filter, dependency.getBasedir()); + } + } + + private void loadExecutionData(final ReportSupport support, + final FileFilter filter, final File basedir) throws IOException { + for (final File execFile : filter.getFiles(basedir)) { + support.loadExecutionData(execFile); } } |