[java-identity-provider] branch dev/JPAR-175 updated: JPAR-176 Change the how managed dependencies are inherited.

Rod Widdowson rdw at steadingsoftware.com
Tue Jun 22 09:21:54 UTC 2021


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

rdw pushed a commit to branch dev/JPAR-175
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=9f110278161f3007eb505f124802bac04ac4835f

The following commit(s) were added to refs/heads/dev/JPAR-175 by this push:
       new  9f1102781 JPAR-176 Change the how managed dependencies are inherited.
9f1102781 is described below

commit 9f110278161f3007eb505f124802bac04ac4835f
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Jun 22 10:17:46 2021 +0100

    JPAR-176 Change the how managed dependencies are inherited.
    
    https://issues.shibboleth.net/jira/browse/JPAR-176
    
    see
    
    https://issues.shibboleth.net/jira/browse/JPAR-179?focusedCommentId=37194&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-37194
    
    for more details.
---
 .../idp/dependencies/DependencyTest.java           | 16 ++++------
 .../net/shibboleth/idp/dependencies/ParsedPom.java | 36 +++++++++++++++-------
 2 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
index 76df4ea42..382b473ff 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/DependencyTest.java
@@ -138,30 +138,26 @@ public class DependencyTest extends OpenSAMLInitBaseTestCase {
         parentArtefact = idpParent.getParent(); 
         assertNotNull(parentArtefact);
         final Path parentPath = downloadPom(parentArtefact);
+        final Set<PomArtifact> allManagedDeps = new HashSet<>();
         final ParsedPom projectParent = new ParsedPom(parserPool, parentPath, "parent/pom.xml", new Properties(), Collections.emptyList());
+        allManagedDeps.addAll(projectParent.getManagedDependencies());
         idpParent = new ParsedPom(parserPool, Path.of("../idp-parent/pom.xml"), "idp-parent/pom.xml", projectParent.getProperties(), projectParent.getCompileDependencies());
+        allManagedDeps.addAll(idpParent.getManagedDependencies());
         dependencies.addAll(projectParent.getCompileDependencies());
         dependencies.addAll(idpParent.getCompileDependencies());
         for (final PomArtifact bom : projectParent.getBomDependencies()) {
             final Path bomPath = downloadPom(bom);
             final ParsedPom bomContents = new ParsedPom(parserPool, bomPath, bom.getArtifactId()+".pom", projectParent.getProperties(), projectParent.getCompileDependencies());
             dependencies.addAll(bomContents.getCompileDependencies());
+            allManagedDeps.addAll(bomContents.getManagedDependencies());
         }
         for (final PomArtifact bom : idpParent.getBomDependencies()) {
             final Path bomPath = downloadPom(bom);
             final ParsedPom bomContents = new ParsedPom(parserPool, bomPath, bom.getArtifactId()+".pom", projectParent.getProperties(), projectParent.getCompileDependencies());
             dependencies.addAll(bomContents.getCompileDependencies());
+            allManagedDeps.addAll(bomContents.getManagedDependencies());
         }
-        final Set<PomArtifact> allDeps = new HashSet<>(projectParent.getCompileDependencies().size() +
-                idpParent.getCompileDependencies().size() +
-                projectParent.getRuntimeDependencies().size() +
-                idpParent.getRuntimeDependencies().size() 
-                );
-        allDeps.addAll(projectParent.getCompileDependencies());
-        allDeps.addAll(idpParent.getCompileDependencies());
-        allDeps.addAll(projectParent.getRuntimeDependencies());
-        allDeps.addAll(idpParent.getRuntimeDependencies());
-        final ParsedPom warDist = new ParsedPom(parserPool, Path.of("../idp-war-distribution/pom.xml"), "idp-war-distribution/pom.xml", projectParent.getProperties(), allDeps);
+        final ParsedPom warDist = new ParsedPom(parserPool, Path.of("../idp-war-distribution/pom.xml"), "idp-war-distribution/pom.xml", projectParent.getProperties(), allManagedDeps);
         dependencies.addAll(warDist.getRuntimeDependencies());
         final File out = new File("target/dependencyReport.txt");
         final FileOutputStream outStream = new FileOutputStream(out);
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
index e2ef70836..3b76c27f8 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/dependencies/ParsedPom.java
@@ -63,8 +63,11 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
     /** Rumtime dependencies. */
     private final List<PomArtifact> runtimeDependencies = new ArrayList<>();    
 
+    /** managed dependencies. */
+    private final List<PomArtifact> myManagedDependencies = new ArrayList<>();    
+    
     /** Inherits dependencies. */
-    private final Map<String, PomArtifact> managedDependencies;
+    private final Map<String, PomArtifact> inputManagedDependencies;
     
     /** Which the POM.*/
     @Nonnull private final String sourcePomInfo;
@@ -98,7 +101,7 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
                      @Nonnull final Collection<PomArtifact> managed)
             throws FileNotFoundException, IOException, XMLParserException {
 
-        managedDependencies = managed.stream().collect(Collectors.toMap(e->e.getGroupId()+"+"+e.getArtifactId(), Function.identity()));
+        inputManagedDependencies = managed.stream().collect(Collectors.toMap(e->e.getGroupId()+"+"+e.getArtifactId(), Function.identity()));
                 
         sourcePomInfo = pomName;
         Document document;
@@ -138,11 +141,11 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
         final List<Element> dependencyMgt = ElementSupport.getChildElementsByTagName(el, "dependencyManagement");
         if (!dependencyMgt.isEmpty()) {
             final List<Element> dependencies = ElementSupport.getChildElementsByTagName(dependencyMgt.get(0), "dependencies");
-            parseDependencies(dependencies.get(0));
+            parseDependencies(dependencies.get(0), true);
         }
         final List<Element> dependencies = ElementSupport.getChildElementsByTagName(el, "dependencies");
         if (!dependencies.isEmpty()) {
-            parseDependencies(dependencies.get(0));
+            parseDependencies(dependencies.get(0), false);
         }
     }
 
@@ -158,28 +161,33 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
     }
 
     /**
-     * @param item
+     * @param item what to parse
+     * @param isManaged to we add to the managed dependencies?
      */
-    private void parseDependencies(Element item) {
+    private void parseDependencies(final Element item, final boolean isManaged) {
         final List<Element> dependencies = ElementSupport.getChildElementsByTagName(item, "dependency");
         
         for (Element dependency : dependencies) {
+            final PomArtifact artifact = new PomArtifact(dependency);
             final List<Element> types = ElementSupport.getChildElementsByTagName(dependency, "type");
             if (!types.isEmpty()) {
                 final String type = StringSupport.trimOrNull(types.get(0).getTextContent());
                 if ("pom".equals(type)) {
-                    bomDependencies.add(new PomArtifact(dependency));
+                    bomDependencies.add(artifact);
                     continue;
                 } else if (!"jar".equals(type)) {
                     // not for us
                     continue;
                 }                
             }
+            if (isManaged) {
+                myManagedDependencies.add(artifact);
+            }
             final List<Element> scopes = ElementSupport.getChildElementsByTagName(dependency, "scope");
             if (!scopes.isEmpty()) {
                 final String scope = StringSupport.trimOrNull(scopes.get(0).getTextContent());
                 if ("runtime".equals(scope)) {
-                    runtimeDependencies.add(new PomArtifact(dependency));
+                    runtimeDependencies.add(artifact);
                     continue;
                 }
                 if (!"compile".equals(scope)) {
@@ -187,8 +195,7 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
                     continue;
                 }
             }
-            final PomArtifact dep = new PomArtifact(dependency);
-            compileDependencies.add(dep);
+            compileDependencies.add(artifact);
         }
     }
 
@@ -231,6 +238,13 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
     public List<PomArtifact> getRuntimeDependencies() {
         return runtimeDependencies;
     }
+    
+    /**
+     * @return Returns the myManagedDependencies.
+     */
+    public List<PomArtifact> getManagedDependencies() {
+        return myManagedDependencies;
+    }
 
     /** Return our artifactInformation.
      * @return us.
@@ -321,7 +335,7 @@ public class ParsedPom extends OpenSAMLInitBaseTestCase{
             } else if (parentArtifact != null) {
                 version = parentArtifact.getVersion();
             } else {
-                final PomArtifact inherited = managedDependencies.get(groupId+"+"+artifactId);
+                final PomArtifact inherited = inputManagedDependencies.get(groupId+"+"+artifactId);
                 if (inherited != null) {
                     version = inherited.getVersion();
                 } else {

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


More information about the commits mailing list