Maven-plublish: multiple artifacts with the identical extension and classifier

Hi everyone,

I’m wondering what’s behind the decision that project can’t publish mutliple artifacts with different artifactId but the same classfier and extension. Is this a bug or feature?

task zip1(type: Zip) {
  from {...}
  baseName = 'zip1'
  classifier = 'c1'
}

task zip2(type: Zip) {
  from {...}
  baseName = 'zip2'
  classifier = 'c1'
}

publishing {
    publications {
        main(MavenPublication) {
            ...
            artifact zip1
            artifact zip2
        }
    }
}

This ends up with

> Failed to publish publication 'main' to repository 'mavenLocal'
   > Invalid publication 'main': multiple artifacts with the identical extension and classifier ('zip', 'c1').

Thanks for any info.

Gradle Version: 3.1
Operating System and JVM version: 1.8.0_92 (Oracle Corporation 25.92-b14), Fedora 24
Is this a regression? No

Publishing under different artifactIDs means you want to have multiple publications. Try something like:

publishing {
    publications {
        main( MavenPublication ) {
            artifact zip1
        }
        someOtherName( MavenPublication ) {
            artifact zip2
        }
    }
}
2 Likes

I tried that too, but there is another limitation:

> Exception thrown while executing model rule: PublishingPlugin.Rules#publishing(ExtensionContainer) 
   > Publishing is not yet able to resolve a dependency on a project with multiple different publications

That’s why I use the first solution, which works quite well, but only if you don’t have multiple artifacts with identical extension and classifier.

Interesting, none of my projects have had a mix of multiple publications with project dependencies, so I guess I’ve been lucky.

Perhaps the workaround in this issue helps?
https://issues.gradle.org/browse/GRADLE-2966