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

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

commit c4051ca47f95f8d6a16cc695aed0028abf834261
Author: Eric Milles <[email protected]>
AuthorDate: Sat Apr 12 11:05:54 2025 -0500

    GROOVY-11607: `groovyc`: fileset lists files
---
 .../main/java/org/codehaus/groovy/ant/Groovyc.java | 25 +++++++++++-----------
 .../org/codehaus/groovy/ant/GroovycTest.xml        | 10 ++++++---
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git 
a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java 
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
index dcd7573414..37fdc4aaa0 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
@@ -37,7 +37,6 @@ import org.codehaus.groovy.GroovyBugError;
 import org.codehaus.groovy.control.CompilationUnit;
 import org.codehaus.groovy.control.CompilerConfiguration;
 import org.codehaus.groovy.control.SourceExtensionHandler;
-import org.codehaus.groovy.runtime.DefaultGroovyMethods;
 import org.codehaus.groovy.runtime.DefaultGroovyStaticMethods;
 import org.codehaus.groovy.tools.ErrorReporter;
 import org.codehaus.groovy.tools.FileSystemCompiler;
@@ -178,7 +177,6 @@ import java.util.StringTokenizer;
 public class Groovyc extends MatchingTask {
 
     private static final File[] EMPTY_FILE_ARRAY = new File[0];
-    private static final String[] EMPTY_STRING_ARRAY = new String[0];
 
     private final LoggingHelper log = new LoggingHelper(this);
 
@@ -865,17 +863,19 @@ public class Groovyc extends MatchingTask {
 
         if (javac != null) jointCompilation = true;
 
-        // scan source directories and dest directory to build up
-        // compile lists
-        String[] list = src.list();
-        for (String filename : list) {
+        // scan source directories and dest directory to build up compile lists
+        for (String filename : src.list()) {
             File file = getProject().resolveFile(filename);
             if (!file.exists()) {
                 throw new BuildException("srcdir \"" + file.getPath() + "\" 
does not exist!", getLocation());
             }
-            DirectoryScanner ds = this.getDirectoryScanner(file);
-            String[] files = ds.getIncludedFiles();
-            scanDir(file, destDir != null ? destDir : file, files);
+            if (file.isDirectory()) {
+                DirectoryScanner ds = getDirectoryScanner(file);
+                scanDir(file, destDir != null ? destDir : file, 
ds.getIncludedFiles());
+            } else { // GROOVY-11607: fileset lists files
+                compileList = Arrays.copyOf(compileList, compileList.length + 
1);
+                compileList[compileList.length - 1] = file;
+            }
         }
 
         compile();
@@ -887,7 +887,7 @@ public class Groovyc extends MatchingTask {
     }
 
     /**
-     * Clear the list of files to be compiled and copied.
+     * Clears the list of files to be compiled and copied.
      */
     protected void resetFileLists() {
         compileList = EMPTY_FILE_ARRAY;
@@ -1254,8 +1254,9 @@ public class Groovyc extends MatchingTask {
     }
 
     private String[] makeCommandLine(List<String> commandLineList) {
-        log.info("Compilation arguments:\n" + 
DefaultGroovyMethods.join((Iterable<String>) commandLineList, "\n"));
-        return commandLineList.toArray(EMPTY_STRING_ARRAY);
+        String[] commandLine = commandLineList.toArray(String[]::new);
+        log.info("Compilation arguments:\n" + String.join("\n", commandLine));
+        return commandLine;
     }
 
     private void runForked(String[] commandLine) {
diff --git 
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
 
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
index 7d5f41d017..450003f999 100644
--- 
a/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
+++ 
b/subprojects/groovy-ant/src/test-resources/org/codehaus/groovy/ant/GroovycTest.xml
@@ -189,9 +189,13 @@
     <!-- GROOVY-11607 -->
     <target name="plainForkedCompilation_NestingSrcElementCheck">
         <groovyc destdir="${destPath}" fork="true">
-            <src path="${srcPath}"/>
-            <include name="GroovycTest*.*"/>
-            <exclude name="GroovycTest2.java"/>
+            <src>
+                <fileset dir="${srcPath}">
+                    <include name="GroovycTest*.*"/>
+                    <exclude name="GroovycTest.xml"/>
+                    <exclude name="GroovycTest2.java"/>
+                </fileset>
+            </src>
         </groovyc>
         <java classname="org.codehaus.groovy.ant.GroovycTest1"/>
     </target>

Reply via email to