Spring-boot: Gradle plugin should add the repackaged jar to the project's components and possibly expose it as a separate artifact

Created on 6 Oct 2014  路  3Comments  路  Source: spring-projects/spring-boot

Without it, using the maven-publish plugin is harder than it needs to be.

enhancement

Most helpful comment

Currently, I'm able to work around this in a rather haphazard manner:

// make sure bootRepackage is included in task graph
project.tasks.findAll { it.name.startsWith("publish") } .each { it.dependsOn assemble }

// so we can maintain both "normal" and "boot" jars
springBoot {
    classifier = 'boot'
}

publishing {
    publications {
        maven(MavenPublication) {
            // "normal" jar    
            from components.java

            // "boot" jar
            artifact ("$buildDir/libs/$project.name-$version-boot.jar") {
                classifier = 'boot'
            }
        }
    }
}

I'm sure there must be a more elegant way to get the output file from the bootRepackage task, but it doesn't seem to declare its outputs (ie, bootRepackage.outputs is empty).

All 3 comments

Currently, I'm able to work around this in a rather haphazard manner:

// make sure bootRepackage is included in task graph
project.tasks.findAll { it.name.startsWith("publish") } .each { it.dependsOn assemble }

// so we can maintain both "normal" and "boot" jars
springBoot {
    classifier = 'boot'
}

publishing {
    publications {
        maven(MavenPublication) {
            // "normal" jar    
            from components.java

            // "boot" jar
            artifact ("$buildDir/libs/$project.name-$version-boot.jar") {
                classifier = 'boot'
            }
        }
    }
}

I'm sure there must be a more elegant way to get the output file from the bootRepackage task, but it doesn't seem to declare its outputs (ie, bootRepackage.outputs is empty).

You also can't sign the jar generated by bootRepackage.

+1. Would be useful to have access to the produced outputs so they can used in combination with other plugins, such as creating a Docker image.

Was this page helpful?
0 / 5 - 0 ratings