Publish several artifacts with different poms

(Sergey Sheypak) #1

Hi, I’m trying to build two artifacts:

  1. regular jar my-module-name.jar with pom where all dependecines are listed
  2. fat jar using shadowPlugin. Fat jar has differnet classifier: ‘all’. fatJat should have EMPTY pom since it has all required stuff onboard.

Here is my code:

   shadowJar {
        zip64 true
        classifier =  'all'
        relocate 'com.fasterxml',   ''
        relocate 'org.joda',        ''
        relocate 'com.sun.jersey',  ''

        configurations = [project.configurations.distrib]

publication {
    artifact distTargz
    artifact jar

artifacts {
    distTargzConfig distTargz
    archives shadowJar
    archives jar

publication 'shadow', {
    artifact shadowJar

I get two jars published:

  • my-module-name.jar
    I get only single pom without ANY dependencies and this pom describes my-module-name.jar

What do I do wrong?

(Chris Doré) #2

Maven publications only have one pom per identifier (group, name, and version combination), so you cannot do what you’d like. Classifiers only distinguish additional artifacts of a publication, but are not part of the publication’s identifier. In order to have a different pom for the fat jar, you’ll have to create a second publication with a change in at least one of group, name, or version.