Reputation: 41
I`m trying to publish mutliple artifacts per project.
How to upload an existing collection of 3rd-party Jars to a Maven server in Gradle?
I have tried to apply this solution -
My build.gradle looks like: https://gist.github.com/anonymous/01b31c26eca7a507c14f
I tried to follow the documentation: http://www.gradle.org/docs/current/us...
What I`m getting is:
What went wrong: Execution failed for task ':install'. Could not publish configuration 'archives' > A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact my:jar:jar:null, trying to add MavenArtifact my:jar:jar:null.
My env: Gradle 2.2.1
Build time: 2014-11-24 09:45:35 UTC Build number: none Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
Groovy: 2.3.6 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 JVM: 1.7.0_71 (Oracle Corporation 24.71-b01) OS: Windows 8.1 6.3 amd64
Thanks for your help.
Upvotes: 4
Views: 13428
Reputation: 159
Hi currently i've same problem, but in different context. I'm using proguard in my java project, and i would like have two different artifacts using obiuvsly gradle. I've made a Proguard task which is producing an obfuscated .jar :
task proguard(type: proguard.gradle.ProGuardTask)
{
injars 'build/libs/foundation.jar'
outjars 'build/libs/foundationObfuscated.jar'
}
In a second time we need to add our new artifact to the default one :
artifacts
{
archives(file: file("$projectDir/build/libs/foundationObfuscated.jar"),
builtBy: proguard)
{
classifier = 'obfuscated'
}
}
The most important thing you need to add a new 'classifier' different from the default one. In this configuration i also specify my archive depends on the previous task ('proguard'). Finally we can upload the two artifacts :
uploadArchives {
repositories.mavenDeployer {
pom.groupId = 'com.groupid'
pom.artifactId = 'artifactid'
pom.version = "${versionMajorDevelop}.${buildTime()}"
repository(url: "file://${workingLocalDirArtifact()}")
}
}
Here i'm specifiy i would like to publish the two different artifacts (the generic one and the '${versionMajorDevelop}.${buildTime()}-obfuscated' in a local repository 'workingLocalDirArifact' but you can use another configuration. By default Gradle will run proguard task, and you will have published the multiple artifacts.
Upvotes: 4
Reputation: 4612
I cannot access gist.github.com as my employer kindly blocked it. Thus I don't know what exactly would you like to achieve. Publish 3rd party jars as in the link you posted or rather your own additional artifact built from the project.
If the latter don't bother with nasty scripting, that's fully supported by Gradle. Error you posted says everything.
A POM cannot have multiple artifacts with the same type and classifier.
You need to specify classifier for any additional artifact.
Let say you are about to upload a zip with deployment bundle (your jar plus libs). It would look like:
task('applicationBundle', type: Zip) {
classifier = 'distro'
// ... code for zipping appropriate files
}
artifacts {
archives applicationBundle
}
I haven't tested the above example but that should do it.
A word of explanation - classifier going to be appended to the artifact file name as a suffix.
EDIT: if you are using new incubating API of maven-publish plugin for interacting with Maven here is relevant example for you (publishing additional jar with sources): http://www.gradle.org/docs/current/dsl/org.gradle.api.publish.maven.MavenPublication.html
Upvotes: 1