[java-mvn-enforcer] 03/03: JMVN-11 Would like to be able to control where reports are sent

Rod Widdowson rdw at steadingsoftware.com
Fri Dec 10 11:24:40 UTC 2021


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-mvn-enforcer.

View the commit online:
http://git.shibboleth.net/view/?p=java-mvn-enforcer.git;a=commit;h=2b14978cf98efdfb9d845b9ecd44ed6e6800dcf4

commit 2b14978cf98efdfb9d845b9ecd44ed6e6800dcf4
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Dec 10 11:23:54 2021 +0000

    JMVN-11 Would like to be able to control where reports are sent
    
    https://shibboleth.atlassian.net/browse/JMVN-11
---
 .../shibboleth/mvn/enforcer/impl/JarEnforcer.java  | 38 +++++++++++++++++-----
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java b/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
index ad1d861..3ac6889 100644
--- a/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
+++ b/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
@@ -92,6 +92,12 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
     private boolean listJarSources;
     /** Will we check that all jars in ~/.m2/... jars have valid signatures? */
     private boolean checkM2;
+    /** Fully Qualified Path of M2 Report.*/
+    private String m2ReportPath;
+    /** Fully Qualified Path of Signature Report.*/
+    private String sigCheckReportPath;
+    /** Fully Qualified Path of Dependency Report.*/
+    private String depCheckReportPath;
 
     /** The list of things which get added to real versions. */
     private String versionExtensions = "-SNAPSHOT -GA -jre -empty-to-avoid-conflict-with-guava";
@@ -260,10 +266,15 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
                 index = group.indexOf('.', index+1);
             }
             root = root.getParent();
-            log.info("Inferred M2 Root at ", root);
-            final File out2 = target.resolve("m2SignatureReport.txt").toFile();
+            log.info("Inferred M2 Root at {}", root);
+            final Path reportPath;
+            if (m2ReportPath == null) {
+                reportPath = target.resolve("m2SignatureReport.txt");
+            } else {
+                reportPath = Path.of(m2ReportPath);
+            }
             try (final PrintWriter report =
-                    new PrintWriter(new BufferedOutputStream(new FileOutputStream(out2)))) {
+                    new PrintWriter(new BufferedOutputStream(new FileOutputStream(reportPath.toFile())))) {
                 report.format("M2 Signature Testing started at %s\n\n", Instant.now().toString());
                 final M2SigChecker chk = new M2SigChecker(pomContext, report);
                 m2Result = chk.testSignatures(root);
@@ -289,9 +300,14 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
             if (isGPGDataASnapshot() && !pomContext.isSnapShot()) {
                 throw new EnforcerRuleException("Running a signature check of a non SNAPSHOT build against a SNAPSHOT of GPGData");
             }
-            final File out = target.resolve("signatureReport.txt").toFile();
+            final Path reportPath;
+            if (sigCheckReportPath == null) {
+                reportPath = target.resolve("signatureReport.txt");
+            } else {
+                reportPath = Path.of(sigCheckReportPath);
+            }
             try (final PrintWriter report =
-                    new PrintWriter(new BufferedOutputStream(new FileOutputStream(out)))) {
+                    new PrintWriter(new BufferedOutputStream(new FileOutputStream(reportPath.toFile())))) {
 
                 report.format("Signature Testing started at %s\n\n", Instant.now().toString());
                 final SigChecker sigChecker = new SigChecker(pomContext, report);
@@ -329,9 +345,15 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
                                            final List<Path> tgzPaths, final List<Path> zipPaths) throws IOException {
         boolean depdendencyResult = true;
         if (checkDependencies) {
-            final File out = target.resolve("dependencyReport.txt").toFile();
-            try (final PrintWriter report = new PrintWriter(
-                    new BufferedOutputStream(new FileOutputStream(out)))) {
+            final Path reportPath;
+            if (depCheckReportPath == null) {
+                reportPath = target.resolve("dependencyReport.txt");
+            } else {
+                reportPath = Path.of(depCheckReportPath);
+            }
+            try (final PrintWriter report =
+                    new PrintWriter(new BufferedOutputStream(new FileOutputStream(reportPath.toFile())))) {
+
                 report.format("POM based Dependency Testing started at %s\n", Instant.now().toString());
 
                 for (final Path tgzPath: tgzPaths) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list