The other day I wrote an article Run-app with grails and it doesn't boot, but I had a chance to build it with gradle, so I referred to the pathing Jar. I tried it with a pattern that puts it in and moves it, but apparently it does not work well if the classpath contains spaces. My PC was set up by a company employee in advance when I joined the company, but the full name is blank. So there is a space in the path to your home directory. orz
The classpath to be embedded in the jar is separated by spaces. Whitespace in the path seems to escape with% 20. Where you are collecting the paths of the pathingJar jar file, replace the spaces.
build.gradle
...Omission...
task pathingJar(type: Jar) {
dependsOn configurations.runtime
appendix = 'pathing'
doFirst {
manifest {
attributes "Class-Path": configurations.runtime.files.collect {
it.toURL().toString().replaceFirst(/file:\/+/, '/').replace(' ', '%20')
}.join(' ')
}
}
}
...Omission...
Grails has a trick called pathingJar = true, but I also encountered a mysterious situation where it does not start. Therefore, write as follows. If I write a task with pathingJar as it is, I get angry that it already exists, so I chose the pathingJarEx task.
build.gradle
...Omission...
// grails {
// pathingJar = true
// }
task pathingJarEx(type: Jar) {
dependsOn configurations.runtime
appendix = 'pathing'
doFirst {
manifest {
// Build the Class-Path for absolute paths based on runtime dependencies.
attributes(
'Class-Path': configurations.runtime.files.collect {
it.toURL().toString().replaceFirst(/file:\/+/, '/').replace(' ', '%20')
}.join(' ')
)
}
}
exclude { it.file.absolutePath.contains('assetCompile') }
}
...Omission...
bootRun {
...Omission...
dependsOn pathingJarEx
doFirst {
classpath = files("$buildDir/classes/main", "$buildDir/resources/main", "$projectDir/gsp-classes", pathingJarEx.archivePath)
}
}
...Omission...