I have a gradle build script that retrieves a number of common dependencies and creates a "fat jar" with them all combined.
gradle fatJar uploadArchives
However the uploadArchives step afterwards does not use the jar generated and instead overwrites it with a default jar that has none of the dependencies.
How can I specify the publish step to use the "fat jar" and not overwrite the jar created?
apply plugin: 'java'
apply plugin: 'maven'
version '1.2.3'
sourceSets {
main {
resources.srcDirs = ["resources"]
}
}
repositories {
mavenCentral()
}
dependencies {
runtime 'commons-cli:commons-cli:1.3.1'
....
runtime 'xerces:xercesImpl:2.11.0'
}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Some common jars',
'Implementation-Version': version
}
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "http://localhost:8081/artifactory/org-sandbox") {
authentication(userName: "admin", password:"password")
}
pom.groupId = 'org.something'
}
}
}
Following RaGe's suggestion, I switched to maven-publish which allows specifying the artifact ( by task name).. This worked.
publishing {
publications {
maven(MavenPublication) {
groupId 'org.something'
artifact fatJar
}
}
repositories {
maven {
url "http://localhost:8081/artifactory/sandbox"
credentials {
username 'admin'
password 'password'
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With