You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2017/08/29 22:42:00 UTC

[jira] [Commented] (GROOVY-8295) Groovyc ant task can overflow Windows command line if classpath is large

    [ https://issues.apache.org/jira/browse/GROOVY-8295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16146275#comment-16146275 ] 

Eric Milles commented on GROOVY-8295:
-------------------------------------

I did a little digging on this one.  It appears that the {{@file.txt}} command line option of Groovyc (aka {{org.codehaus.groovy.tools.FileSystemCompiler}}) is for the list of source files only.  So I took another approach to the problem.  Since the classpath is the bit that is so very long (and is listed 2 times when running in forked mode), I tried replacing the absolute path of the executable's working directory.  

The change is actually quite small.  Replace the 2 occurrences of {{commandLineList.add(classpath.toString());}} with {{commandLineList.add(classpath.toString().replace(getProject().getBaseDir().getAbsolutePath(), "."));}}.


This can reduce a classpath like:
{code}
C:\Users\user.home\project.directory\build\JavaClasses;C:\Users\user.home\project.directory\build\IvyLibraries\master\commons-codec-1.10.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\commons-collections4-4.1.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\commons-lang3-3.6.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\db-5.1.19.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\groovy-all-2.4.12.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\guava-22.0.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\infra-berkeleyloader-28.5.0.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\infra-logging-31.1.0.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\joda-time-2.9.9.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\json-20080701.jar;C:\Users\user.home\project.directory\build\IvyLibraries\master\log4j-1.2.17.jar
{code}
to
{code}
.\build\JavaClasses;;.\build\IvyLibraries\master\commons-codec-1.10.jar;.\build\IvyLibraries\master\commons-collections4-4.1.jar;.\build\IvyLibraries\master\commons-lang3-3.6.jar;.\build\IvyLibraries\master\db-5.1.19.jar;.\build\IvyLibraries\master\groovy-all-2.4.12.jar;.\build\IvyLibraries\master\guava-22.0.jar;.\build\IvyLibraries\master\infra-berkeleyloader-28.5.0.jar;.\build\IvyLibraries\master\infra-logging-31.1.0.jar;.\build\IvyLibraries\master\joda-time-2.9.9.jar;.\build\IvyLibraries\master\json-20080701.jar;.\build\IvyLibraries\master\log4j-1.2.17.jar
{code}

The effect is quite significant for a project with dozens of dependencies that is built in a deeply nested directory on the file system.

> Groovyc ant task can overflow Windows command line if classpath is large
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-8295
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8295
>             Project: Groovy
>          Issue Type: Bug
>          Components: Ant integration
>         Environment: Windows
>            Reporter: Eric Milles
>
> The groovyc ant adapter tries to account for the 32K command line length limit on windows in its addSourceFiles method.  However, if the command line gets long for other reasons -- we include a number of libraries in our compiled projects -- the command line can still be overflown.
> This results in:
> {code}
> CompileAntScript.xml:129: Error running forked groovyc.
> 	at org.codehaus.groovy.ant.Groovyc.runForked(Groovyc.java:1121)
> 	at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:1214)
> 	at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:831)
> Caused by: java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.8.0_60\jre\bin\java": CreateProcess error=206, The filename or extension is too long
> 	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
> 	at java.lang.Runtime.exec(Runtime.java:620)
> 	at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:862)
> 	at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
> 	at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495)
> 	at org.codehaus.groovy.ant.Groovyc.runForked(Groovyc.java:1119)
> 	... 31 more
> Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
> 	at java.lang.ProcessImpl.create(Native Method)
> 	at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
> 	at java.lang.ProcessImpl.start(ProcessImpl.java:137)
> 	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
> 	... 36 more
> {code}
> Would it be possible to add command line length checking to {{runForked}} instead of {{addSourceFiles}} and use a command file for groovyc to prevent command line overflow?  Without this, we are having to use a lot of verbose workarounds in Ant.
> https://github.com/apache/groovy/blob/master/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)