From 601961ac07feb86fe7a4b24eac7df78b75179194 Mon Sep 17 00:00:00 2001 From: Peter Frank Date: Wed, 17 May 2017 11:01:11 -0700 Subject: [PATCH] Added a sourcesPaths array tag that will add multiple Sources to the Cobertura ArgumentBuilder. E.g. ${project.basedir}/src/main/groovy/ ${project.basedir}/src/main/java/ Adds support for both groovy files and java files in a GMavenPlus Plugin default layout. --- .../core/reporting/AbstractReportMojo.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/qualinsight/mojo/cobertura/core/reporting/AbstractReportMojo.java b/core/src/main/java/com/qualinsight/mojo/cobertura/core/reporting/AbstractReportMojo.java index e85b330..a965cd1 100644 --- a/core/src/main/java/com/qualinsight/mojo/cobertura/core/reporting/AbstractReportMojo.java +++ b/core/src/main/java/com/qualinsight/mojo/cobertura/core/reporting/AbstractReportMojo.java @@ -52,6 +52,9 @@ public abstract class AbstractReportMojo extends AbstractMojo { @Parameter(defaultValue = "${project.basedir}/src/main/java/", required = false) private String sourcesPath; + @Parameter(defaultValue = "${project.basedir}/src/main/java/", required = false) + private String[] sourcesPaths; + @Parameter(defaultValue = "UTF-8", required = false) private String encoding; @@ -139,6 +142,10 @@ protected String sourcesPath() { return this.sourcesPath; } + protected String[] sourcesPaths(){ + return this.sourcesPaths; + } + protected String encoding() { return this.encoding; } @@ -152,13 +159,21 @@ protected String[] formats() { Arguments buildCoberturaReportArguments(final File sourcesDirectory, final File destinationDirectory, final File dataFile) { getLog().debug("Building Cobertura report generation arguments"); final ArgumentsBuilder builder = new ArgumentsBuilder(); - return builder.setBaseDirectory(sourcesDirectory.getAbsolutePath()) + builder.setBaseDirectory(sourcesDirectory.getAbsolutePath()) .setDestinationDirectory(destinationDirectory.getAbsolutePath()) .setDataFile(dataFile.getAbsolutePath()) .setEncoding(encoding()) - .calculateMethodComplexity(this.calculateMethodComplexity) - .addSources(sourcesPath, true) - .build(); + .calculateMethodComplexity(this.calculateMethodComplexity); + + if(sourcesPaths != null && sourcesPaths.length > 0) { + for (String sourcesPath : sourcesPaths) { + builder.addSources(sourcesPath, true); + } + }else{ + builder.addSources(this.sourcesPath, true); + } + + return builder.build(); } }