Skip to content
Advertisement

Gradle – Customize Classpath in Manifest

I want to create a more general Classpath, than what is generated from this snippet of my build.gradle file:

jar {
manifest {
    attributes (
        "Main-Class": "x.y.z.main",
        "Specification-Title" : "Oh how specific!",
        "Specification-Vendor" : "Super Secret",
        "Specification-Version" : "1.0", 
        "Implementation-Title" : "Top Notch Software",
        "Implementation-Version" : "1.0 Build Nr. 1",
        "Implementation-Vendor" : "Super Secret",
        "Implementation-Vendor-Id" : "x.y.z.com",
        "Implementation-Url" : "http://www.x.y.z.com",
        "Class-Path": configurations.runtimeClasspath.files.collect { it.absolutePath }.join(' ')
    )
}

This yields something like this:

...Class-Path: C:UsersYouWouldLikeToKnow.gradlecachesmodules-2files-2.1org.springframework.cloudspring-cloud-starter-gateway3.1.3d008ce51415d0507a1806bd0a518a21860ee0f63spring-cloud-starter-gateway-3.1.3.jar...

Instead i want to configure it to be like so:

...Class-Path: libsexternalspring-cloud-starter-gateway-3.1.3.jar...

Something like:

configurations.runtimeClasspath.files.collect {"libsexternal" + it.fileName}.join(' ')

Advertisement

Answer

Could you try:

'Class-Path': configurations.runtime.files.collect{ "lib/external/" + it.getName() }.join(' ')
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement