I struggled with with the jar MANIFEST file built with Gradle containing an empty Class-Path
. I traced down the problem to the order of the dependencies
and jar
blocks in the build.gradle
file:
Wrong (jar
before dependencies
):
jar {
manifest.attributes(
// Class-Path won't contain "guava-15.0.jar"
'Class-Path': configurations.runtime.files.collect { it.name }.join(' ')
)
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '15.0'
}
Correct (jar
after dependencies
):
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '15.0'
}
jar {
manifest.attributes(
// results in "Class-Path: guava-15.0.jar"
'Class-Path': configurations.runtime.files.collect { it.name }.join(' ')
)
}
I need to use Class-Path variable into resolve as follows:
But when I run this, I am getting -
Caused by: groovy.lang.MissingPropertyException: Could not set unknown property 'buildclasspath' for task ':resolve' of type io.swagger.v3.plugins.gradle.tasks.ResolveTask
error. Anyone has any idea how can I resolve it?