[java-mvn-enforcer] 03/03: JMVN-59 MVN-DATA should be able to check itself.

Rod Widdowson rdw at steadingsoftware.com
Wed Nov 1 14:12:39 UTC 2023


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=16d03cc41e08c78b4e90b1882ca4e5c7caef1f50

commit 16d03cc41e08c78b4e90b1882ca4e5c7caef1f50
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Mon Oct 30 14:51:19 2023 +0000

    JMVN-59 MVN-DATA should be able to check itself.
    
    https://shibboleth.atlassian.net/browse/JMVN-59
    
    Add ability to configure what the enforcer resolves to find local repo
---
 .../shibboleth/mvn/enforcer/impl/JarEnforcer.java  | 35 +++++++++++++++++++---
 1 file changed, 31 insertions(+), 4 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 4db5cee..3a77802 100644
--- a/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
+++ b/src/main/java/net/shibboleth/mvn/enforcer/impl/JarEnforcer.java
@@ -73,10 +73,18 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
     @Nonnull private String zipFiles="";
     /** Where to get external data. Group */
     @Nonnull private String dataGroupId = "";
-    /** Where to get external data. ArtifactName*/
+    /** Where to get external data. ArtifactId. */
     @Nonnull private String dataArtifactId = "";
-    /** Where to get external data. Version*/
+    /** Where to get external data. Version. */
     @Nonnull private String dataVersion = "";
+    /** How to get maven base. Group */
+    @Nonnull private String m2GroupId = "";
+    /** How to get maven base. ArtifactName*/
+    @Nonnull private String m2ArtifactId = "";
+    /** How to get maven base. Version*/
+    @Nonnull private String m2Version = "";
+    /** How to get maven base. file type*/
+    @Nonnull private String m2Type = "";
     /** The key rings for the data .*/
     private String dataKeyRing;
     /** Will we check that all jars we distribute jars have valid signatures? */
@@ -292,11 +300,30 @@ public class JarEnforcer implements EnforcerRule, MavenLoader{
     private boolean performM2Check(@Nonnull final ProjectPomContext pomContext) throws Exception {
         boolean m2Result = true;
         if (checkM2) {
-            final File resolvePomFile = downloadArtifact(dataGroupId, dataArtifactId, dataVersion, "", "jar");
+            final File resolvePomFile;
+            if (!"".equals(m2GroupId) || !"".equals(m2ArtifactId) || !"".equals(m2Version) || !"".equals(m2Type)) {
+                if ("".equals(m2GroupId) || "".equals(m2ArtifactId) || "".equals(m2Version)) {
+                    log.error("Must specify all of m2GroupId, m2ArtifactId, m2Version and m2Type or none.  Provided {}, {}, {}, {}",
+                            m2GroupId, m2ArtifactId, m2Version, m2Type);
+                    throw new EnforcerRuleException("Configuration for m2 check failed");
+                }
+                log.debug("Resolving {}, {}, {} as {}",m2GroupId, m2ArtifactId, m2Version, m2Type);
+                resolvePomFile = downloadArtifact(m2GroupId, m2ArtifactId, m2Version, "", m2Type);
+            } else {
+                log.debug("Resolving {}, {}, {} as jar", dataGroupId, dataArtifactId, dataVersion);
+                resolvePomFile = downloadArtifact(dataGroupId, dataArtifactId, dataVersion, "", "jar");
+            }
             if (resolvePomFile == null) {
-                log.error("Could not ressolve maven-enforcer-data");
+                log.error("Could not ressolve m2 root");
                 return false;
             }
+            if (!"".equals(m2GroupId) || !"".equals(m2ArtifactId)|| !"".equals(m2Version)) {
+                if ("".equals(m2GroupId) || "".equals(m2ArtifactId) || "".equals(m2Version)) {
+                    log.error("Must specify all of m2GroupId, m2ArtifactId and m2Version, not none.  Provided {}, {}, {}",
+                            m2GroupId, m2ArtifactId, m2Version);
+                    throw new EnforcerRuleException("Configuration for m2 check failed");
+                }
+            }
             final Path resolvedPom = resolvePomFile.toPath();
             // Resolved pom path is <pathTpM2Repo>/group1/group2/..../artifact/version/pomfilename
             log.debug("Resolved Pom = {}", resolvedPom);

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


More information about the commits mailing list