GradleUp / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
https://www.gradleup.com/shadow/
Apache License 2.0
3.69k stars 389 forks source link

Clarification on maven publishing #563

Open thokuest opened 4 years ago

thokuest commented 4 years ago

With regards to Maven publishing, the documentation states the following at the time of writing:

publishing {
  publications {
    shadow(MavenPublication) { publication ->
      project.shadow.component(publication)
    }
  }
  // ....
}

If I understood Maven publishing correctly, this will produce a POM and a JAR for the shadow artifact.

Since I have additional artifacts to upload and all publications share the same artifact ID and version but with different classifiers, I get the following warning from Gradle:

Multiple publications with coordinates 'group:artifact:version' are published to repository 'maven'. The publications will overwrite each other!

And in fact, maven-metadata.xml gets overwritten. Since the shadow jar is just a secondary artifact for my project, I changed the publishing configuration to

publishing {
  publications {
    mavenJava(MavenPublication) {
      from components.java

      artifact sourcesJar
      artifact shadowJar
    }
  }
  // ....
}

It works, but I wonder, is this the way to go?

martinda commented 3 years ago

@thokuest I just found that ShadowExtension.groovy automatically adds the shadowJar as a publication.