shadow: uploadX task fails if both shadow 2.0.x and application plugin are applied.
Shadow Version
1.2.4 vs. 2.0.0/2.0.1
Gradle Version
4.3.1/4.4-rc1
Expected Behavior
This example project (build.gradle is also provided below) should work with 2.0.x since it worked with 1.2.4.
Execute gradlew to run the default tasks.
Actual Behavior
Execution failed for task ':uploadPublished'.
> Could not publish configuration 'published'
> A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact gradle-shadow2:zip:zip:null, trying to add MavenArtifact gradle-shadow2:zip:zip:null.
If you remove the following two lines, the build will work.
apply plugin: 'application'
mainClassName = 'foo.Main'
If you instead switch back from 2.0.1 to 1.2.4, the build will work. If you use Gradle 4.4-rc1, neither will work. See https://github.com/gradle/gradle/issues/3589
Gradle Build Script(s)
buildscript {
repositories {
jcenter()
}
dependencies {
//classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
}
}
wrapper {
gradleVersion = '4.3.1'
// gradleVersion = '4.4-rc1'
}
description = 'some description'
version = '1.0.0-SNAPSHOT'
def localReleaseRepoFile = new File("${System.properties.'user.home'}/local-gradle-repository/release")
def localSnapshotRepoFile = new File("${System.properties.'user.home'}/local-gradle-repository/snapshot")
def localReleaseRepo = localReleaseRepoFile.toURL().toString()
def localSnapshotRepo = localSnapshotRepoFile.toURL().toString()
repositories {
maven {
url localReleaseRepo
}
maven {
url localSnapshotRepo
}
mavenCentral()
mavenLocal()
}
apply plugin: 'application'
mainClassName = 'foo.Main'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
def deployer = null
configurations {
published.extendsFrom archives
}
uploadPublished {
deployer = repositories.mavenDeployer {
repository(url: localReleaseRepo)
snapshotRepository(url: localSnapshotRepo)
}
}
def defaultProject= {
url 'http://foobar.com'
name project.name
description project.description
}
def installer = install.repositories.mavenInstaller
installer.pom.project defaultProject
deployer.pom.project defaultProject
defaultTasks 'build', 'shadowJar', 'uploadPublished'
Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)
n/a, content of the JAR is not the problem.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 6
- Comments: 16
Commits related to this issue
- Added link to issue preventing shadow upgrade. https://github.com/johnrengelman/shadow/issues/347 — committed to huxi/lilith by huxi 8 years ago
- shadow plugin 4.0.0 See https://github.com/johnrengelman/shadow/issues/347 — committed to huxi/lilith by huxi 8 years ago
- fix buid issues Summary: https://github.com/johnrengelman/shadow/issues/347 > Task :release FAILED Release process failed, reverting back any changes made by Release Plugin. Release process failed, ... — committed to uber/uber-graph-benchmark by chrislusf 8 years ago
Thanks a lot for your effort. Your suggested workaround works. Just tried it. 👍
Ok, I believe I see what’s happening. According to https://docs.gradle.org/current/userguide/distribution_plugin.html#sec:publishing_distributions_upload ALL distributions are automatically added to the default
archiveconfiguration. This means that the outputs fromshadowDistZipandshadowDistTarare automatically added toarchivesand since we don’t do any special configuration of those tasks, they have the defaultclassifierwhich isnull.You can work around this in your build by adding the following: