You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/08/16 14:46:26 UTC

[1/2] groovy git commit: Cleanup the build script

Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X ba8e6a1ec -> 35200c4f7


Cleanup the build script

(cherry picked from commit a52f77a)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/35200c4f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/35200c4f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/35200c4f

Branch: refs/heads/GROOVY_2_6_X
Commit: 35200c4f7fff47fdcac9f33c0ae5340dafb9a049
Parents: 3229ea4
Author: sunlan <su...@apache.org>
Authored: Wed Aug 16 22:44:46 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Wed Aug 16 22:46:15 2017 +0800

----------------------------------------------------------------------
 build.gradle | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/35200c4f/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 5f46375..4f4c599 100644
--- a/build.gradle
+++ b/build.gradle
@@ -79,9 +79,6 @@ File javaHome = new File(System.getProperty('java.home'))
 logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})"
 indyBanner()
 
-// TODO use antlr plugin
-//apply plugin: 'antlr'
-
 allprojects {
     apply plugin: 'java'
 


[2/2] groovy git commit: Add toList and toSet DGMs to java.util.stream.Stream

Posted by su...@apache.org.
Add toList and toSet DGMs to java.util.stream.Stream

(cherry picked from commit fca6e0f)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3229ea43
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3229ea43
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3229ea43

Branch: refs/heads/GROOVY_2_6_X
Commit: 3229ea43af1cd2ba8d7910a4c6b43cce4f104332
Parents: ba8e6a1
Author: sunlan <su...@apache.org>
Authored: Wed Aug 16 22:36:48 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Wed Aug 16 22:46:15 2017 +0800

----------------------------------------------------------------------
 build.gradle                                    |  4 ++++
 .../vmplugin/v8/PluginDefaultGroovyMethods.java | 23 ++++++++++++++++++++
 .../v8/PluginDefaultGroovyMethodsTest.groovy    | 13 +++++++++++
 3 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/3229ea43/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index aef3ce2..5f46375 100644
--- a/build.gradle
+++ b/build.gradle
@@ -92,6 +92,10 @@ allprojects {
     group = 'org.codehaus.groovy'
     version = groovyVersion
     repositories {
+        if (!InetAddress.getByName('www.google.com').isReachable(3000)) {
+            // Try to use Aliyun maven repository when building in China
+            maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
+        }
         jcenter()
         maven { url 'http://dl.bintray.com/melix/thirdparty-apache' } // openbeans
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/3229ea43/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java b/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
index b26a381..19136cf 100644
--- a/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
@@ -18,7 +18,11 @@
  */
 package org.codehaus.groovy.vmplugin.v8;
 
+import java.util.List;
 import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * Defines new Groovy methods which appear on normal JDK 8
@@ -42,4 +46,23 @@ public class PluginDefaultGroovyMethods {
         return optional.isPresent();
     }
 
+    /**
+     * Accumulates the elements of stream into a new List.
+     * @param stream the Stream
+     * @param <T>
+     * @return a new {@code java.util.List} instance
+     */
+    public static <T> List<T> toList(Stream<T> stream) {
+        return stream.collect(Collectors.toList());
+    }
+
+    /**
+     * Accumulates the elements of stream into a new Set.
+     * @param stream the Stream
+     * @param <T>
+     * @return a new {@code java.util.Set} instance
+     */
+    public static <T> Set<T> toSet(Stream<T> stream) {
+        return stream.collect(Collectors.toSet());
+    }
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/3229ea43/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy b/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy
index 6139654..1c82c6e 100644
--- a/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy
+++ b/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy
@@ -42,4 +42,17 @@ class PluginDefaultGroovyMethodsTest extends StaticTypeCheckingTestCase {
         '''
     }
 
+    void testStreamToList() {
+        assertScript '''
+            def list = [1, 2, 3]
+            assert list == list.stream().toList() 
+        '''
+    }
+
+    void testStreamToSet() {
+        assertScript '''
+            def set = [1, 2, 3] as Set
+            assert set.sort() == set.stream().toSet().sort()
+        '''
+    }
 }