You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by po...@apache.org on 2019/11/03 10:07:44 UTC

[creadur-rat] branch feature/RAT-259 updated: RAT-259: Get rid of static stuff in Report

This is an automated email from the ASF dual-hosted git repository.

pottlinger pushed a commit to branch feature/RAT-259
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git


The following commit(s) were added to refs/heads/feature/RAT-259 by this push:
     new c0f0c57  RAT-259: Get rid of static stuff in Report
c0f0c57 is described below

commit c0f0c57025cc57170dc25a579df0a5a13c426d10
Author: Hugo Hirsch <gi...@hugo-hirsch.de>
AuthorDate: Sun Nov 3 11:07:11 2019 +0100

    RAT-259: Get rid of static stuff in Report
---
 apache-rat-core/src/main/java/org/apache/rat/Report.java            | 6 +++---
 apache-rat-core/src/test/java/org/apache/rat/ReportTest.java        | 2 +-
 .../src/main/java/org/apache/rat/mp/AbstractRatMojo.java            | 4 ++--
 apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java  | 6 ++++--
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/apache-rat-core/src/main/java/org/apache/rat/Report.java b/apache-rat-core/src/main/java/org/apache/rat/Report.java
index c0c1e23..0c0c9d0 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/Report.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/Report.java
@@ -150,7 +150,7 @@ public class Report {
      * @throws InterruptedException              in case of threading errors.
      * @throws RatException                      in case of internal errors.
      */
-    public static void report(PrintStream out, IReportable base, final InputStream style,
+    public void report(PrintStream out, IReportable base, final InputStream style,
                               ReportConfiguration pConfiguration)
             throws IOException, TransformerConfigurationException, InterruptedException, RatException {
         report(new OutputStreamWriter(out), base, style, pConfiguration);
@@ -169,7 +169,7 @@ public class Report {
      * @throws InterruptedException              in case of threading errors.
      * @throws RatException                      in case of internal errors.
      */
-    public static ClaimStatistic report(Writer out, IReportable base, final InputStream style,
+    public ClaimStatistic report(Writer out, IReportable base, final InputStream style,
                                         ReportConfiguration pConfiguration)
             throws IOException, TransformerConfigurationException, InterruptedException, RatException {
         PipedReader reader = new PipedReader();
@@ -192,7 +192,7 @@ public class Report {
      * @throws IOException  in case of I/O errors.
      * @throws RatException in case of internal errors.
      */
-    public static ClaimStatistic report(final IReportable container, final Writer out,
+    public ClaimStatistic report(final IReportable container, final Writer out,
                                         ReportConfiguration pConfiguration) throws IOException, RatException {
         IXmlWriter writer = new XmlWriter(out);
         final ClaimStatistic statistic = new ClaimStatistic();
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
index 5ecdf5c..51e4267 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
@@ -121,7 +121,7 @@ public class ReportTest {
         final ReportConfiguration configuration = new ReportConfiguration();
         configuration.setApproveDefaultLicenses(true);
         configuration.setHeaderMatcher(matcherMultiplexer);
-        Report.report(out, new DirectoryWalker(new File(elementsPath)),
+        new Report(null).report(out, new DirectoryWalker(new File(elementsPath)),
                 Defaults.getPlainStyleSheet(), configuration);
 
         String result = out.getBuffer().toString();
diff --git a/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java b/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
index 5e143be..7dec350 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
@@ -512,9 +512,9 @@ public abstract class AbstractRatMojo extends AbstractMojo {
         final ReportConfiguration configuration = getConfiguration();
         try {
             if (style != null) {
-                return Report.report(out, getResources(), style, configuration);
+                return new Report(basedir).report(out, getResources(), style, configuration);
             } else {
-                return Report.report(getResources(), out, configuration);
+                return new Report(basedir).report(getResources(), out, configuration);
             }
         } catch (final TransformerConfigurationException | RatException | InterruptedException | IOException e) {
             throw new MojoExecutionException(e.getMessage(), e);
diff --git a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
index 78b27f9..4c79598 100644
--- a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
+++ b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
@@ -260,8 +260,10 @@ public class Report extends Task {
             throw new BuildException("Invalid value for addLicenseHeaders: " + addLicenseHeaders.getValue());
         }
         ResourceCollectionContainer rcElement = new ResourceCollectionContainer(nestedResources);
+        // reportFile is not used from Ant to actually get the report
+        org.apache.rat.Report report = new org.apache.rat.Report(reportFile);
         if (format.getValue().equals(Format.XML_KEY)) {
-            org.apache.rat.Report.report(rcElement, out, configuration);
+            report.report(rcElement, out, configuration);
         } else {
             InputStream style = null;
             try {
@@ -273,7 +275,7 @@ public class Report extends Task {
                     throw new BuildException("unsupported format '"
                                              + format.getValue() + "'");
                 }
-                org.apache.rat.Report.report(out, rcElement, style,
+                report.report(out, rcElement, style,
                                              configuration);
             } finally {
                 FileUtils.close(style);