diff --git a/.idea/runConfigurations/Run Tests.xml b/.idea/runConfigurations/Run Tests.xml
deleted file mode 100644
index 1c87a6e..0000000
--- a/.idea/runConfigurations/Run Tests.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/rife/bld/extension/JacocoReportOperation.java b/src/main/java/rife/bld/extension/JacocoReportOperation.java
index 999dc0e..75c633b 100644
--- a/src/main/java/rife/bld/extension/JacocoReportOperation.java
+++ b/src/main/java/rife/bld/extension/JacocoReportOperation.java
@@ -35,6 +35,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
@@ -52,61 +53,61 @@ public class JacocoReportOperation extends AbstractOperation classFiles = new ArrayList<>();
+ final private Collection classFiles_ = new ArrayList<>();
/**
* The location of the exec files.
*/
- final List execFiles = new ArrayList<>();
+ final private Collection execFiles_ = new ArrayList<>();
/**
* The location of the source files.
*/
- final List sourceFiles = new ArrayList<>();
+ final private Collection sourceFiles_ = new ArrayList<>();
/**
* The location of the CSV report.
*/
- File csv;
+ private File csv_;
/**
* The file to write execution data to.
*/
- File destFile;
+ private File destFile_;
/**
* The source file encoding.
*/
- String encoding;
+ private String encoding_;
/**
* The location of the HTML report.
*/
- File html;
- /**
- * The report name.
- */
- String name = "JaCoCo Coverage Report";
+ private File html_;
/**
* The project reference.
*/
- BaseProject project;
+ private BaseProject project_;
/**
* The quiet flag.
*/
- boolean quiet;
+ private boolean quiet_;
+ /**
+ * The report name.
+ */
+ private String reportName_ = "JaCoCo Coverage Report";
/**
* THe tab width.
*/
- int tabWidth = 4;
+ private int tabWidth_ = 4;
/**
* THe location of the XML report
*/
- File xml;
+ private File xml_;
private IBundleCoverage analyze(ExecutionDataStore data) throws IOException {
var builder = new CoverageBuilder();
var analyzer = new Analyzer(data, builder);
- for (var f : classFiles) {
+ for (var f : classFiles_) {
LOGGER.info(f.getAbsolutePath());
analyzer.analyzeAll(f);
}
- return builder.getBundle(name);
+ return builder.getBundle(reportName_);
}
/**
@@ -116,10 +117,30 @@ public class JacocoReportOperation extends AbstractOperation classFiles() {
+ return classFiles_;
+ }
+
/**
* Sets the locations of Java class files.
*
@@ -127,7 +148,7 @@ public class JacocoReportOperation extends AbstractOperation classFiles) {
- this.classFiles.addAll(classFiles);
+ classFiles_.addAll(classFiles);
return this;
}
@@ -138,7 +159,29 @@ public class JacocoReportOperation extends AbstractOperation execFiles) {
- this.execFiles.addAll(execFiles);
+ execFiles_.addAll(execFiles);
return this;
}
+ /**
+ * Returns the locations of the JaCoCo *.exec files to read.
+ *
+ * @return the exec files
+ */
+ public Collection execFiles() {
+ return execFiles_;
+ }
+
/**
* Performs the operation execution that can be wrapped by the {@code #executeOnce} call.
*/
@Override
public void execute() throws IOException {
- if ((project == null) && LOGGER.isLoggable(Level.SEVERE)) {
+ if ((project_ == null) && LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.severe("A project must be specified.");
} else {
- var buildJacocoReportsDir = Path.of(project.buildDirectory().getPath(), "reports", "jacoco", "test").toFile();
- var buildJacocoExecDir = Path.of(project.buildDirectory().getPath(), "jacoco").toFile();
+ var buildJacocoReportsDir = Path.of(project_.buildDirectory().getPath(), "reports", "jacoco", "test").toFile();
+ var buildJacocoExecDir = Path.of(project_.buildDirectory().getPath(), "jacoco").toFile();
var buildJacocoExec = Path.of(buildJacocoExecDir.getPath(), "jacoco.exec").toFile();
- if (destFile == null) {
- destFile = Path.of(buildJacocoExecDir.getPath(), "jacoco.exec").toFile();
+ if (destFile_ == null) {
+ destFile_ = Path.of(buildJacocoExecDir.getPath(), "jacoco.exec").toFile();
}
- if (execFiles.isEmpty()) {
- var testOperation = project.testOperation().fromProject(project);
- testOperation.javaOptions().javaAgent(Path.of(project.libBldDirectory().getPath(),
+ if (execFiles_.isEmpty()) {
+ var testOperation = project_.testOperation().fromProject(project_);
+ testOperation.javaOptions().javaAgent(Path.of(project_.libBldDirectory().getPath(),
"org.jacoco.agent-" + JaCoCo.VERSION.substring(0, JaCoCo.VERSION.lastIndexOf('.'))
- + "-runtime.jar").toFile(), "destfile=" + destFile.getPath());
+ + "-runtime.jar").toFile(), "destfile=" + destFile_.getPath());
try {
testOperation.execute();
} catch (InterruptedException | ExitStatusException e) {
throw new IOException(e);
}
- if (LOGGER.isLoggable(Level.INFO) && !quiet) {
- LOGGER.log(Level.INFO, "Execution Data: {0}", destFile);
+ if (LOGGER.isLoggable(Level.INFO) && !quiet_) {
+ LOGGER.log(Level.INFO, "Execution Data: {0}", destFile_);
}
if (buildJacocoExec.exists()) {
- execFiles.add(buildJacocoExec);
+ execFiles_.add(buildJacocoExec);
}
}
- if (sourceFiles.isEmpty()) {
- sourceFiles.add(project.srcMainJavaDirectory());
+ if (sourceFiles_.isEmpty()) {
+ sourceFiles_.add(project_.srcMainJavaDirectory());
}
- if (classFiles.isEmpty()) {
- classFiles.add(project.buildMainDirectory());
+ if (classFiles_.isEmpty()) {
+ classFiles_.add(project_.buildMainDirectory());
}
- if (html == null) {
- html = new File(buildJacocoReportsDir, "html");
+ if (html_ == null) {
+ html_ = new File(buildJacocoReportsDir, "html");
}
- if (xml == null) {
- xml = new File(buildJacocoReportsDir, "jacocoTestReport.xml");
+ if (xml_ == null) {
+ xml_ = new File(buildJacocoReportsDir, "jacocoTestReport.xml");
}
- if (csv == null) {
- csv = new File(buildJacocoReportsDir, "jacocoTestReport.csv");
+ if (csv_ == null) {
+ csv_ = new File(buildJacocoReportsDir, "jacocoTestReport.csv");
}
//noinspection ResultOfMethodCallIgnored
@@ -260,7 +322,7 @@ public class JacocoReportOperation extends AbstractOperation visitors = new ArrayList<>();
- if (xml != null) {
+ if (xml_ != null) {
var formatter = new XMLFormatter();
- visitors.add(formatter.createVisitor(Files.newOutputStream(xml.toPath())));
+ visitors.add(formatter.createVisitor(Files.newOutputStream(xml_.toPath())));
}
- if (csv != null) {
+ if (csv_ != null) {
var formatter = new CSVFormatter();
- visitors.add(formatter.createVisitor(Files.newOutputStream(csv.toPath())));
+ visitors.add(formatter.createVisitor(Files.newOutputStream(csv_.toPath())));
}
- if (html != null) {
+ if (html_ != null) {
var formatter = new HTMLFormatter();
- visitors.add(formatter.createVisitor(new FileMultiReportOutput(html)));
+ visitors.add(formatter.createVisitor(new FileMultiReportOutput(html_)));
}
return new MultiReportVisitor(visitors);
@@ -341,7 +413,18 @@ public class JacocoReportOperation extends AbstractOperation sourceFiles) {
- this.sourceFiles.addAll(sourceFiles);
+ sourceFiles_.addAll(sourceFiles);
return this;
}
+ /**
+ * Returns the locations of the source files.
+ *
+ * @return the source files
+ */
+ public Collection sourceFiles() {
+ return sourceFiles_;
+ }
+
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private ISourceFileLocator sourceLocator() {
- var multi = new MultiSourceFileLocator(tabWidth);
- for (var f : sourceFiles) {
- multi.add(new DirectorySourceFileLocator(f, encoding, tabWidth));
+ var multi = new MultiSourceFileLocator(tabWidth_);
+ for (var f : sourceFiles_) {
+ multi.add(new DirectorySourceFileLocator(f, encoding_, tabWidth_));
}
return multi;
}
@@ -372,13 +464,13 @@ public class JacocoReportOperation extends AbstractOperation