Open maniax89 opened 7 years ago
So here's my new configuration:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
}
}
apply plugin: 'com.github.johnrengelman.plugin-shadow'
apply plugin: 'java'
configurations {
shadowAndCompile
compile.extendsFrom(shadowAndCompile)
}
dependencies {
shadowAndCompile 'A'
compile 'B'
compile 'C'
}
configureRelocationShadowJar {
prefix = "somecustomprefix"
}
shadowJar {
configurations = [project.configurations.shadowAndCompile]
}
artifacts {
archives shadowJar
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: mavenLocal().url)
pom.whenConfigured {
p -> p.dependencies = p.dependencies.findAll {
dep -> dep.groupId != "A"
}
}
pom.groupId = "my.group"
pom.artifactId = "my-artifact"
pom.version = "1.0.0"
}
}
}
Does this look like the right way to go about this?
I wasn't sure how to make the uploadShadow
task to only remove the shadowed dependencies from the POM (and leave the rest of the compile
dependencies)
Your solution looks good for the compilation part.
You might not need the pom configuration if you change compile.extendsFrom(shadowCompile)
to compileClasspath.extendsFrom(shadowCompile)
Basically, I have been trying to figure out a way to create an partial "uber" jar. The documentation clearly states that by default it will create an "uber" jar from the
shadowJar
task, but I was interested in the proper way to only include one of the dependencies, say dependencyA
(as well asA
's dependencies) AND relocate all the packages of dependencyA
as well. I believe that http://imperceptiblethoughts.com/shadow/#using_shadow_to_package_gradle_plugins adds in theConfigureShadowRelocation
task which achieves my goal, but it seems to do it for ALL dependencies (not sure how to just pick one dependency, dependencyA
).See below for my configuration
Shadow Version
2.0.1
Gradle Version
Gradle 4.1
Gradle Build Script(s)