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:
plugins { id 'java' id "io.swagger.core.v3.swagger-gradle-plugin" version "2.1.9" } // I have sections in order: repo, dependencies, test after this and then - jar { manifest { attributes( "Main-Class": "com.cloudian.hfs.StartHFS", 'Class-Path': configurations.runtime.files.collect { it.name }.join(' ') ) } } resolve { outputFileName = 'HFS-API' outputFormat = 'YAML' prettyPrint = 'TRUE' buildclasspath = 'Class-Path' resourcePackages = ['io.test'] outputDir = file('test') }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.ResolveTaskerror. Anyone has any idea how can I resolve it?