I am using shadowJar in my java project. I would like to push the outcome into artifactory.
My gradle script look like this, I am not sure how to connect the dots:
shadowJar {
baseName = 'com.mycompany.myapp'
manifest {
attributes 'Main-Class': 'myapp.starter'
}
}
]
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
// rep for the project
repositories {
mavenCentral()
maven {
url 'http://repo.company:8081/artifactory/libs-release'
credentials {
username = "${repo_user}"
password = "${repo_password}"
}
}
maven {
url 'http://repo.company:8081/artifactory/libs-snapshot'
credentials {
username = "${repo_user}"
password = "${repo_password}"
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
}
How do I code gradle to take the shadowjar file?
thanks, ray.
But if you want the plugin to be available to anyone in the world, i.e. public, then you should publish it to the Gradle Plugin Portal, a centralized, searchable repository dedicated to Gradle plugins.
Shaded jar (or shaded classes) - usually refers to a process of changing classes bytecode to change packages names of the classes, and also modify were it is used in the jar. It is used to link classes to a specific version of other classes and avoid versions collisions. It can be created by Maven Shade Plugin.
It's a bit late, but I'd like to show you how I got it to work. Maybe it helps someone stumbling across this question as I did:
build.gradle.kts:
plugins {
java
`maven-publish`
id("com.github.johnrengelman.shadow") version "5.1.0"
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(tasks["shadowJar"])
}
}
repositories {
maven {
/* ... */
}
}
}
The example above is written in Kotlin, if you prefer Groovy, you would need to write this instead:
build.gradle:
publishing {
publications {
shadow(MavenPublication) {
from components.java
artifact shadowJar
}
}
}
(found it here: https://libraries.io/github/johnrengelman/shadow)
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