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/04/22 01:13:48 UTC

groovy git commit: Revert "Enable the new parser Parrot by default" because some tests were not covered before.

Repository: groovy
Updated Branches:
  refs/heads/master 3caf3a458 -> 09fab0626


Revert "Enable the new parser Parrot by default" because some tests were not covered before.


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

Branch: refs/heads/master
Commit: 09fab0626db700a23e82f7a7695e278ab18bad92
Parents: 3caf3a4
Author: sunlan <su...@apache.org>
Authored: Sat Apr 22 09:13:39 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Sat Apr 22 09:13:39 2017 +0800

----------------------------------------------------------------------
 .travis.yml                                     |  2 +-
 .../groovy/control/CompilerConfiguration.java   | 74 +++++++++-----------
 subprojects/groovy-console/build.gradle         |  4 +-
 subprojects/groovy-parser-antlr4/build.gradle   | 13 +++-
 4 files changed, 48 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/09fab062/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9bf1700..e4f512c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,7 +27,7 @@ matrix:
 
 install: true
 
-script: travis_wait 60 ./gradlew test
+script: travis_wait 60 ./gradlew -PuseAntlr4=true test
 
 before_cache:
   - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

http://git-wip-us.apache.org/repos/asf/groovy/blob/09fab062/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
index a3107ac..c0f2815 100644
--- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -74,7 +74,6 @@ public class CompilerConfiguration {
      *  default context, then you probably just want <code>new CompilerConfiguration()</code>. 
      */
     public static final CompilerConfiguration DEFAULT = new CompilerConfiguration();
-    public static final String GROOVY_ANTLR4_OPT = "groovy.antlr4";
 
     /**
      * See {@link WarningMessage} for levels.
@@ -85,11 +84,11 @@ public class CompilerConfiguration {
      * Encoding for source files
      */
     private String sourceEncoding;
-    
+
     /**
-      * The <code>PrintWriter</code> does nothing.
-      */
-     private PrintWriter output;
+     * The <code>PrintWriter</code> does nothing.
+     */
+    private PrintWriter output;
 
     /**
      * Directory into which to write classes
@@ -132,17 +131,17 @@ public class CompilerConfiguration {
      * extension used to find a groovy file
      */
     private String defaultScriptExtension;
-    
+
     /**
      * extensions used to find a groovy files
      */
     private Set<String> scriptExtensions = new LinkedHashSet<String>();
-    
+
     /**
      * if set to true recompilation is enabled
      */
     private boolean recompileGroovySource;
-    
+
     /**
      * sets the minimum of time after a script can be recompiled.
      */
@@ -157,7 +156,7 @@ public class CompilerConfiguration {
      * options for joint compilation (null by default == no joint compilation)
      */
     private Map<String, Object> jointCompilationOptions;
-    
+
     /**
      * options for optimizations (empty map by default)
      */
@@ -176,12 +175,9 @@ public class CompilerConfiguration {
 
     /**
      * defines if antlr2 parser should be used or the antlr4 one if
-     * no factory is set yet.
-     *
-     * The antlr4 parser Parrot is enabled by default
-     *
+     * no factory is set yet
      */
-    private boolean antlr2Parser = false;
+    private boolean antlr2Parser = true;
 
     /**
      * Sets the Flags to defaults.
@@ -237,11 +233,7 @@ public class CompilerConfiguration {
         setOptimizationOptions(options);
 
         try {
-            String groovyAntlr4Opt = System.getProperty(GROOVY_ANTLR4_OPT);
-
-            if (null != groovyAntlr4Opt) {
-                antlr2Parser = !Boolean.valueOf(groovyAntlr4Opt);
-            }
+            antlr2Parser = !"true".equals(System.getProperty("groovy.antlr4"));
         } catch (Exception e) {
             // IGNORE
         }
@@ -391,9 +383,9 @@ public class CompilerConfiguration {
      */
     public static boolean isPostJDK5(String bytecodeVersion) {
         return JDK5.equals(bytecodeVersion)
-            || JDK6.equals(bytecodeVersion)
-            || JDK7.equals(bytecodeVersion)
-            || JDK8.equals(bytecodeVersion);
+                || JDK6.equals(bytecodeVersion)
+                || JDK7.equals(bytecodeVersion)
+                || JDK8.equals(bytecodeVersion);
     }
 
     /**
@@ -404,7 +396,7 @@ public class CompilerConfiguration {
      */
     public static boolean isPostJDK7(String bytecodeVersion) {
         return JDK7.equals(bytecodeVersion)
-            || JDK8.equals(bytecodeVersion);
+                || JDK8.equals(bytecodeVersion);
     }
 
     /**
@@ -457,10 +449,10 @@ public class CompilerConfiguration {
         //
         text = configuration.getProperty("groovy.target.directory");
         if (text != null) setTargetDirectory(text);
-        
+
         text = configuration.getProperty("groovy.target.bytecode");
         if (text != null) setTargetBytecode(text);
-        
+
         //
         // Classpath
         //
@@ -501,7 +493,7 @@ public class CompilerConfiguration {
         //
         text = configuration.getProperty("groovy.script.base");
         if (text!=null) setScriptBaseClass(text);
-        
+
         //
         // recompilation options
         //
@@ -509,7 +501,7 @@ public class CompilerConfiguration {
         if (text != null) {
             setRecompileGroovySource(text.equalsIgnoreCase("true"));
         }
-        
+
         numeric = 100;
         try {
             text = configuration.getProperty("groovy.recompile.minimumIntervall");
@@ -572,7 +564,7 @@ public class CompilerConfiguration {
      * Gets the currently configured output writer.
      * @deprecated not used anymore
      */
-    @Deprecated 
+    @Deprecated
     public PrintWriter getOutput() {
         return this.output;
     }
@@ -633,7 +625,7 @@ public class CompilerConfiguration {
             this.classpath.add(tokenizer.nextToken());
         }
     }
-    
+
     /**
      * sets the classpath using a list of Strings
      * @param parts list of strings containing the classpath parts
@@ -735,7 +727,7 @@ public class CompilerConfiguration {
         if(scriptExtensions == null) scriptExtensions = new LinkedHashSet<String>();
         this.scriptExtensions = scriptExtensions;
     }
-    
+
     public Set<String> getScriptExtensions() {
         if(scriptExtensions == null || scriptExtensions.isEmpty()) {
             /*
@@ -749,7 +741,7 @@ public class CompilerConfiguration {
         }
         return scriptExtensions;
     }
-    
+
     public String getDefaultScriptExtension() {
         return defaultScriptExtension;
     }
@@ -758,19 +750,19 @@ public class CompilerConfiguration {
     public void setDefaultScriptExtension(String defaultScriptExtension) {
         this.defaultScriptExtension = defaultScriptExtension;
     }
-    
+
     public void setRecompileGroovySource(boolean recompile) {
         recompileGroovySource = recompile;
     }
-    
+
     public boolean getRecompileGroovySource(){
         return recompileGroovySource;
     }
-    
+
     public void setMinimumRecompilationInterval(int time) {
         minimumRecompilationInterval = Math.max(0,time);
     }
-    
+
     public int getMinimumRecompilationInterval() {
         return minimumRecompilationInterval;
     }
@@ -779,7 +771,7 @@ public class CompilerConfiguration {
      * Allow setting the bytecode compatibility. The parameter can take
      * one of the values <tt>1.7</tt>, <tt>1.6</tt>, <tt>1.5</tt> or <tt>1.4</tt>.
      * If wrong parameter then the value will default to VM determined version.
-     * 
+     *
      * @param version the bytecode compatibility mode
      */
     public void setTargetBytecode(String version) {
@@ -792,13 +784,13 @@ public class CompilerConfiguration {
 
     /**
      * Retrieves the compiler bytecode compatibility mode.
-     * 
+     *
      * @return bytecode compatibility mode. Can be either <tt>1.5</tt> or <tt>1.4</tt>.
      */
     public String getTargetBytecode() {
         return this.targetBytecode;
     }
-    
+
     private static String getVMVersion() {
         try {
             Class.forName(JDK5_CLASSNAME_CHECK);
@@ -808,7 +800,7 @@ public class CompilerConfiguration {
         }
         return PRE_JDK5;
     }
-    
+
     /**
      * Gets the joint compilation options for this configuration.
      * @return the options
@@ -816,7 +808,7 @@ public class CompilerConfiguration {
     public Map<String, Object> getJointCompilationOptions() {
         return jointCompilationOptions;
     }
-    
+
     /**
      * Sets the joint compilation options for this configuration. 
      * Using null will disable joint compilation.
@@ -833,7 +825,7 @@ public class CompilerConfiguration {
     public Map<String, Boolean> getOptimizationOptions() {
         return optimizationOptions;
     }
-    
+
     /**
      * Sets the optimization options for this configuration. 
      * No entry or a true for that entry means to enable that optimization, 

http://git-wip-us.apache.org/repos/asf/groovy/blob/09fab062/subprojects/groovy-console/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/groovy-console/build.gradle b/subprojects/groovy-console/build.gradle
index 8b61c95..e40766e 100644
--- a/subprojects/groovy-console/build.gradle
+++ b/subprojects/groovy-console/build.gradle
@@ -27,7 +27,9 @@ dependencies {
 }
 
 task console(type: JavaExec, dependsOn:classes) {
-    jvmArgs += ["-Dgroovy.extract.doc.comment=true"]
+    if (rootProject.hasProperty('useAntlr4')) {
+        jvmArgs += ["-Dgroovy.antlr4=true", "-Dgroovy.extract.doc.comment=true"]
+    }
 
     main = 'groovy.ui.Console'
     classpath = sourceSets.main.runtimeClasspath

http://git-wip-us.apache.org/repos/asf/groovy/blob/09fab062/subprojects/groovy-parser-antlr4/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/build.gradle b/subprojects/groovy-parser-antlr4/build.gradle
index 54d07a4..4197a2a 100644
--- a/subprojects/groovy-parser-antlr4/build.gradle
+++ b/subprojects/groovy-parser-antlr4/build.gradle
@@ -1,3 +1,5 @@
+if (!rootProject.hasProperty('useAntlr4')) return
+
 apply plugin: 'me.champeau.gradle.antlr4'
 
 def srcBase = "subprojects/groovy-parser-antlr4/src"
@@ -19,7 +21,7 @@ compileJava.dependsOn antlr4
 
 // add antlr4 to classpath
 configurations {
-   compile.extendsFrom antlr4
+    compile.extendsFrom antlr4
 }
 
 dependencies {
@@ -45,6 +47,13 @@ sourceSets.test.java.srcDirs += file("$srcTest/java");
 sourceSets.test.groovy.srcDirs += file("$srcTest/groovy");
 sourceSets.test.resources.srcDirs += file("$srcTest/resources");
 
+
+allprojects {
+    tasks.withType(GroovyCompile) {
+        groovyOptions.forkOptions.jvmArgs += ["-Dgroovy.antlr4=true"]
+    }
+}
+
 test {
     jvmArgs "-Dgroovy.extract.doc.comment=true", "-Dgroovy.antlr4.cache.threshold=100"
-}
+}
\ No newline at end of file