forked from jacoco/jacoco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jacoco#1 from johnoliver/master
Add ability to add source and class dirs to the current projects list
- Loading branch information
Showing
3 changed files
with
186 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
jacoco-maven-plugin/src/org/jacoco/maven/ReportPomMojo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2013 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: | ||
* Evgeny Mandrikov - initial API and implementation | ||
* Kyle Lieber - implementation of CheckMojo | ||
* | ||
*******************************************************************************/ | ||
package org.jacoco.maven; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.reporting.MavenReportException; | ||
|
||
/** | ||
* Creates a code coverage report from an exec file appended to from multiple | ||
* reactor projects (HTML, XML, and CSV). | ||
* | ||
* @goal pom-report | ||
* @aggregate | ||
*/ | ||
public class ReportPomMojo extends ReportMojo { | ||
|
||
/** | ||
* Flag used to suppress execution. | ||
* | ||
* @parameter expression="${jacoco.skip}" default-value="false" | ||
*/ | ||
private boolean skip; | ||
|
||
/** | ||
* Maven project. | ||
* | ||
* @parameter expression="${project}" | ||
* @readonly | ||
*/ | ||
private MavenProject project; | ||
|
||
/** | ||
* The projects in the reactor. | ||
* | ||
* @parameter expression="${reactorProjects}" | ||
* @readonly | ||
*/ | ||
private List<MavenProject> reactorProjects; | ||
|
||
@Override | ||
public boolean canGenerateReport() { | ||
if (!"pom".equals(project.getPackaging())) { | ||
getLog().info( | ||
"Skipping JaCoCo since this is not of packaging type 'pom'"); | ||
return false; | ||
} | ||
if (skip) { | ||
getLog().info("Skipping JaCoCo execution"); | ||
return false; | ||
} | ||
if (!dataFile.exists()) { | ||
getLog().info( | ||
"Skipping JaCoCo execution due to missing execution data file"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void executeReport(final Locale locale) | ||
throws MavenReportException { | ||
List<String> sourceFolders = super.getSourceFolders(); | ||
if (sourceFolders == null) { | ||
sourceFolders = new ArrayList<String>(); | ||
} | ||
|
||
List<String> classFolders = super.getClassFolders(); | ||
if (classFolders == null) { | ||
classFolders = new ArrayList<String>(); | ||
} | ||
|
||
for (final MavenProject reactor : reactorProjects) { | ||
sourceFolders.addAll(reactor.getCompileSourceRoots()); | ||
classFolders.add(reactor.getBuild().getOutputDirectory()); | ||
} | ||
|
||
setSourceFolders(sourceFolders); | ||
setClassFolders(classFolders); | ||
super.executeReport(locale); | ||
} | ||
} |