Reputation: 1037
I'm using the Gradle publishing mechanism that is is still in incubation using the publishing
DSL.
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom.withXml {
def parentNode = asNode().appendNode('parent')
parentNode.appendNode('groupId', 'org.springframework.boot')
parentNode.appendNode('artifactId', 'spring-boot-starter-parent')
parentNode.appendNode('version', springBootVersion)
}
// BEGIN sourcejar
artifact sourceJar {
classifier "sources"
}
// END sourcejar
artifact sharedTestJar {
classifier "sharedtest"
}
}
}
This basically works but as soon as as I'm adding a classifier the repackaged artifact is not deployed anymore. So what configuration do I have to refer to for registering the repackaged artifact for publication?
bootRepackage {
classifier = 'exec'
}
Upvotes: 2
Views: 3222
Reputation: 1639
You can get the 'sourcesJar' task in order to attach its sources jar artifact for publication using the JavaPluginConvention
. It's a long line to achieve that but you end up not hardcoding the artifact filename.
publishing.publications.create('bootJava', MavenPublication).with {
...
artifact project.tasks.getByName(
project.getConvention().getPlugin(JavaPluginConvention)
.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME)
.getSourcesJarTaskName())
}
Upvotes: 0
Reputation: 13466
You'll have to add the jar file created by the bootRepackage
task as an additional artifact to publish. Unfortunately the bootRepackage
task doesn't seem to expose this as a property.
artifact(file("$buildDir/$project.name-$project.version-${bootRepackage.classifier}.jar")) {
classifier 'exec'
}
Upvotes: 2