groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 15/18: GROOVY-9312: disable direct references to local .m2 repo jars
Date Fri, 22 Nov 2019 15:11:31 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit a206e4f36116bb63573dfa9717e7fa8db7562809
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Thu Nov 21 13:48:58 2019 -0600

    GROOVY-9312: disable direct references to local .m2 repo jars
    
    (cherry picked from commit 0fdcf6aaa20d129a80ad0e517a9036ec0151840d)
---
 src/resources/groovy/grape/defaultGrapeConfig.xml |  1 -
 src/test/groovy/grape/GrapeIvyTest.groovy         | 61 +++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/src/resources/groovy/grape/defaultGrapeConfig.xml b/src/resources/groovy/grape/defaultGrapeConfig.xml
index 4d17a40..14a180f 100644
--- a/src/resources/groovy/grape/defaultGrapeConfig.xml
+++ b/src/resources/groovy/grape/defaultGrapeConfig.xml
@@ -19,7 +19,6 @@
 
 -->
 <ivysettings>
-  <caches useOrigin="true"/>
   <settings defaultResolver="downloadGrapes"/>
   <resolvers>
     <chain name="downloadGrapes" returnFirst="true">
diff --git a/src/test/groovy/grape/GrapeIvyTest.groovy b/src/test/groovy/grape/GrapeIvyTest.groovy
index 635e5b4..6238857 100644
--- a/src/test/groovy/grape/GrapeIvyTest.groovy
+++ b/src/test/groovy/grape/GrapeIvyTest.groovy
@@ -461,4 +461,65 @@ final class GrapeIvyTest {
 
         Grape.resolve([classLoader:loader], [], [groupId:'org.apache.poi', artifactId:'poi',
version:'3.7'])
     }
+
+    @Test // GROOVY-9312
+    void testResolveSucceedsFromLocalMavenRepository() {
+        def tempDir = File.createTempDir()
+
+        new File(tempDir, 'pom.xml').write '''\
+            <?xml version="1.0" encoding="UTF-8"?>
+            <project
+              xmlns="http://maven.apache.org/POM/4.0.0"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+                <modelVersion>4.0.0</modelVersion>
+                <groupId>org.codehaus.groovy.tests</groupId>
+                <artifactId>maven-bootstrap</artifactId>
+                <version>1.0-SNAPSHOT</version>
+                <dependencies>
+                    <dependency>
+                        <groupId>net.jqwik</groupId>
+                        <artifactId>jqwik</artifactId>
+                        <version>1.2.1</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>net.jqwik</groupId>
+                        <artifactId>jqwik-engine</artifactId>
+                        <version>1.2.1</version>
+                    </dependency>
+                </dependencies>
+            </project>
+        '''.stripIndent()
+
+        try {
+            // prime "${user.home}/.m2/repository" with jqwik
+            assertScript """
+                @Grab('org.apache.maven.shared:maven-invoker:3.0.1')
+                import org.apache.maven.shared.invoker.*
+
+                def request = new DefaultInvocationRequest(goals: ['compile'],
+                    baseDirectory: new File('${tempDir.absolutePath.replace('\\', '\\\\')}'))
+                def result = new DefaultInvoker().execute(request)
+                assert result.exitCode == 0
+            """
+
+            assertScript '''
+                @Grab('net.jqwik:jqwik:1.2.1')
+                import net.jqwik.api.ForAll
+                import net.jqwik.api.Property
+
+                @groovy.transform.CompileStatic
+                class Jsr308 {
+                    @Property
+                    boolean 'size zero or positive'(@ForAll List<Integer> items) {
+                        items.size() >= 0
+                    }
+                }
+
+                println 'success'
+            '''
+        } finally {
+            tempDir.deleteDir()
+        }
+    }
 }


Mime
View raw message