groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] branch master updated: GROOVY-9105: Fix trying to compile properties files and anything that doesn't end with java
Date Sat, 04 May 2019 05:02:34 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new fd206f4  GROOVY-9105: Fix trying to compile properties files and anything that doesn't
end with java
fd206f4 is described below

commit fd206f4771d243ebb700e734bc688a568272d1ae
Author: Graeme Rocher <graeme.rocher@gmail.com>
AuthorDate: Sat May 4 12:56:56 2019 +0800

    GROOVY-9105: Fix trying to compile properties files and anything that doesn't end with
java
    
    See https://github.com/jeffbrown/grailsnolib/blob/master/grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/GenerateStubsTask.java
---
 .../java/org/codehaus/groovy/ant/GenerateStubsTask.java    | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/GenerateStubsTask.java
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/GenerateStubsTask.java
index 89dcdee..8ae2096 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/GenerateStubsTask.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/GenerateStubsTask.java
@@ -21,6 +21,7 @@ package org.codehaus.groovy.ant;
 import groovy.lang.GroovyClassLoader;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
+import org.codehaus.groovy.control.Phases;
 import org.codehaus.groovy.tools.javac.JavaStubCompilationUnit;
 
 import java.io.File;
@@ -50,10 +51,13 @@ public class GenerateStubsTask extends CompileTaskSupport {
                 log.debug("    " + includeName);
 
                 File file = new File(srcDir, includeName);
-                cu.addSource(file);
+
+                if (isSource(includeName)) {
+                    cu.addSource(file);
+                }
 
                 // Increment the count for each non/java src we found
-                if (!includeName.endsWith(".java")) {
+                if (includeName.endsWith(".groovy")) {
                     count++;
                 }
             }
@@ -61,10 +65,14 @@ public class GenerateStubsTask extends CompileTaskSupport {
 
         if (count > 0) {
             log.info("Generating " + count + " Java stub" + (count > 1 ? "s" : "") + "
to " + destdir);
-            cu.compile();
+            cu.compile(Phases.CONVERSION); // Generate the stubs
             log.info("Generated " + cu.getStubCount() + " Java stub(s)");
         } else {
             log.info("No sources found for stub generation");
         }
     }
+
+    private boolean isSource(String includeName) {
+        return includeName.endsWith(".groovy") || includeName.endsWith(".java");
+    }
 }


Mime
View raw message