I would like my Gradle build script to add the complete Classpath to the manifest file contained in JAR file created after the build.
Example:
Manife
I know this is likely trivial for the groovy people here, but in my case, I wanted to change the location of the Class-Path
in the manifest file depending on whether I was going to run in the production environment or local environment. I did this by making my build.gradle
's jar section look like this:
jar {
from configurations.runtime
manifest {
attributes ('Main-Class': 'com.me.Main',
'Class-Path': configurations.runtime.files.collect { jarDir+"/$it.name" }.join(' ')
)
}
}
In this case, the argument to gradle build
is passed like so:
$ gradle build -PjarDir="/opt/silly/path/"