Created
October 27, 2015 17:17
-
-
Save jlmelville/2bfe9277e9e2c0ff79b6 to your computer and use it in GitHub Desktop.
Workaround for gradle application plugin 'the input line is too long' error on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks.withType(CreateStartScripts).each { task -> | |
task.doLast { | |
String text = task.windowsScript.text | |
text = text.replaceFirst(/(set CLASSPATH=%APP_HOME%\\lib\\).*/, { "${it[1]}*" }) | |
task.windowsScript.write text | |
} | |
} |
Thanks! @barrybecker4: Unfortunately, the line
task.unixScript.write task.unixScript.text.replaceFirst(/(CLASSPATH=.APP_HOME\/lib\/).*/, { "CLASSPATH=\$(echo \$APP_HOME/lib/*.jar | tr ' ' ':')" })
does not work properly when the folder names contain a space character in Unix. Instead, the same idea as for Windows may be used:
task.unixScript.write task.unixScript.text.replaceFirst(/(CLASSPATH=.APP_HOME\/lib\/).*/, { "${it[1]}*" })
Helpful workaround. A slightly cleaner approach in the same vein is to override the classpath property in the startScripts, which is the pre-configured task of type CreateStartScripts added by the "application" plugin.
startScripts {
classpath = files( '$APP_HOME/lib/*' )
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. This helped a lot. I was not having a problem with a classpath that was too long, but I did want everything that was in the /lib directory included on may classpath. Here is what I found worked for both linux and windows.