Skip to content

Instantly share code, notes, and snippets.

@jlmelville
Created October 27, 2015 17:17
Show Gist options
  • Save jlmelville/2bfe9277e9e2c0ff79b6 to your computer and use it in GitHub Desktop.
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
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
}
}
@kovzol
Copy link

kovzol commented Apr 7, 2020

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]}*" })

@james-d-brown
Copy link

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