You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2019/11/06 22:32:19 UTC

[groovy] branch GROOVY-8372 updated (50ea7be -> 0eb7525)

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

emilles pushed a change to branch GROOVY-8372
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard 50ea7be  GROOVY-8372: pass remote (not local) conf to addDependencyArtifact
     new 0eb7525  GROOVY-8372: pass remote (not local) conf to addDependencyArtifact

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (50ea7be)
            \
             N -- N -- N   refs/heads/GROOVY-8372 (0eb7525)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/groovy/groovy/grape/GrapeIvy.groovy | 8 +++-----
 src/test/groovy/grape/GrapeIvyTest.groovy    | 6 ++----
 2 files changed, 5 insertions(+), 9 deletions(-)


[groovy] 01/01: GROOVY-8372: pass remote (not local) conf to addDependencyArtifact

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-8372
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 0eb7525ee876eb4700458a49c0032f6dd2638d7e
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Wed Nov 6 15:33:01 2019 -0600

    GROOVY-8372: pass remote (not local) conf to addDependencyArtifact
    
    add dependency artifacts only if ext, type or classifier is non-default
---
 src/main/groovy/groovy/grape/GrapeIvy.groovy | 18 ++++-----
 src/test/groovy/grape/GrapeIvyTest.groovy    | 56 +++++++++++++++++++++++++++-
 2 files changed, 64 insertions(+), 10 deletions(-)

diff --git a/src/main/groovy/groovy/grape/GrapeIvy.groovy b/src/main/groovy/groovy/grape/GrapeIvy.groovy
index c1c637e..f8a5e58 100644
--- a/src/main/groovy/groovy/grape/GrapeIvy.groovy
+++ b/src/main/groovy/groovy/grape/GrapeIvy.groovy
@@ -422,23 +422,23 @@ class GrapeIvy implements GrapeEngine {
         addExcludesIfNeeded(args, md)
 
         for (IvyGrabRecord grabRecord : grabRecords) {
-            def conf = grabRecord.conf ?: ['*']
+            def confs = grabRecord.conf ?: ['*']
             DefaultDependencyDescriptor dd = (DefaultDependencyDescriptor) md.dependencies.find {
                 it.dependencyRevisionId == grabRecord.mrid
             }
             if (!dd) {
                 dd = new DefaultDependencyDescriptor(md, grabRecord.mrid, grabRecord.force, grabRecord.changing, grabRecord.transitive)
-                conf.each { dd.addDependencyConfiguration('default', it) }
+                confs.each { conf -> dd.addDependencyConfiguration('default', conf) }
                 md.addDependency(dd)
             }
 
-            // the optional configuration typically does not extend the default or master configuration, so prevent grabbing the main artifact
-            if (Collections.singleton('optional') == (conf as Set)) continue
-
-            // add artifact descriptor to dependency descriptor
-            def dad = new DefaultDependencyArtifactDescriptor(dd, grabRecord.mrid.name, grabRecord.type ?: 'jar', grabRecord.ext ?: 'jar', null, grabRecord.classifier ? [classifier: grabRecord.classifier] : null)
-            conf.each { dad.addConfiguration(it) }
-            dd.addDependencyArtifact('default', dad)
+            if (grabRecord.classifier != null
+                    || (grabRecord.ext != null && grabRecord.ext != 'jar')
+                    || (grabRecord.type != null && grabRecord.type != 'jar')) {
+                // add artifact descriptor to dependency descriptor
+                def dad = new DefaultDependencyArtifactDescriptor(dd, grabRecord.mrid.name, grabRecord.type ?: 'jar', grabRecord.ext ?: 'jar', null, grabRecord.classifier ? [classifier: grabRecord.classifier] : null)
+                confs.each { conf -> dd.addDependencyArtifact(conf, dad) }
+            }
         }
 
         // resolve grab and dependencies
diff --git a/src/test/groovy/grape/GrapeIvyTest.groovy b/src/test/groovy/grape/GrapeIvyTest.groovy
index 375d0c7..635e5b4 100644
--- a/src/test/groovy/grape/GrapeIvyTest.groovy
+++ b/src/test/groovy/grape/GrapeIvyTest.groovy
@@ -209,7 +209,7 @@ final class GrapeIvyTest {
     }
 
     @Test
-    void testConf() {
+    void testConf1() {
         Set noJars = [
         ]
         Set coreJars = [
@@ -257,6 +257,60 @@ final class GrapeIvyTest {
         assert jars == coreJars + optionalJars, 'assert that no extraneous jars are present'
     }
 
+    @Test // GROOVY-8372
+    void testConf2() {
+        def tempDir = File.createTempDir()
+        def jarsDir = new File(tempDir, 'foo/bar/jars'); jarsDir.mkdirs()
+
+        new File(jarsDir, 'bar-1.2.3.jar').createNewFile()
+        new File(jarsDir, 'baz-1.2.3.jar').createNewFile()
+
+        new File(tempDir, 'ivysettings.xml').write '''\
+            <?xml version="1.0" encoding="UTF-8"?>
+            <ivysettings>
+                <caches useOrigin="true" />
+                <resolvers>
+                    <filesystem name="downloadGrapes">
+                        <ivy pattern="${ivy.settings.dir}/[organization]/[module]/ivy-[revision].xml" />
+                        <artifact pattern="${ivy.settings.dir}/[organization]/[module]/[type]s/[artifact]-[revision].[ext]" />
+                    </filesystem>
+                </resolvers>
+            </ivysettings>
+            '''.stripIndent()
+
+        new File(tempDir, 'foo/bar/ivy-1.2.3.xml').write '''\
+            <?xml version="1.0" encoding="UTF-8"?>
+            <ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
+                <info organisation="foo" module="bar" revision="1.2.3" status="release" />
+                <configurations>
+                    <conf name="default" visibility="public" extends="master" />
+                    <conf name="master" visibility="public" />
+                    <conf name="other" visibility="public" />
+                </configurations>
+                <publications>
+                    <artifact name="bar" type="jar" ext="jar" conf="master" />
+                    <artifact name="baz" type="jar" ext="jar" conf="other" />
+                </publications>
+            </ivy-module>
+            '''.stripIndent()
+
+        System.setProperty('grape.config', tempDir.absolutePath + File.separator + 'ivysettings.xml')
+        try {
+            Grape.@instance = null
+            def loader = new GroovyClassLoader()
+            // request conf="other" which should resolve to artifact "baz-1.2.3.jar"
+            def uris = Grape.resolve(classLoader:loader, validate:false, [group:'foo', module:'bar', version:'1.2.3', conf:'other'])
+
+            def jars = uris.collect { uri -> uri.path.split('/')[-1] } as Set
+            assert 'baz-1.2.3.jar' in jars
+            assert 'bar-1.2.3.jar' !in jars
+        } finally {
+            System.clearProperty('grape.config')
+            Grape.@instance = null
+            tempDir.deleteDir()
+        }
+    }
+
     @Test
     void testClassifier() {
         def shell = new GroovyShell(new GroovyClassLoader())