I’m building an ejb library that produces a .jar file that should be published to a maven repository with a pomfile that specify packaging=ejb
When upgrading from gradle version 5.5.1 to 5.6 the artifact extension is changed during publication.
group = "mygroup"
version = "1.0.0"
pom.packaging = "ejb"
When building with 5.5.1 the resulting files are:
When building with 5.6, the resulting files are:
In both cases the generated pomfile is correct with
Is it the expected behaviour (the publication is changing the extension) or is it a bug?
If it is the expected behaivour, how do I preserve the “.jar”-extension?
I’m not sure if this is expected behavior or not… but you could likely fix it by
archiveExtension = 'jar'
Thanks for the answer. Unfortunately that does not work with gradle 5.6+. It seems that the publication takes precedence over the archiveExtension. The extension is correct in $buildDir/libs, but when the publishing task (publish or publishToMavenLocal) is executed, the extension is changed on the published artifact.
Perhaps this documentation can help.
it.extension == "ejb"
it.extension = "jar"
Unfortunately that did not work either. The “artifact object” has the correct file and desired extension, but when setting the publication.package = “ejb” the uploaded extension is changed.
The only solution I’ve have now is to modify the pom with “withXml”. But it feels like a hack.
Thanks for reporting this @hazze. This clearly is a regression. I opened: https://github.com/gradle/gradle/issues/10555
It is caused by these changes https://github.com/gradle/gradle/pull/9445 which re-implemented part of the publishing process. There clearly was some test coverage for this missing.
I am afraid the “withXml” workaround is the only thing you can do at the moment.