arktekk / sbt-aether-deploy

Deploy SBT artifacts using Maven Artifact Resolver (formerly Eclipse Aether)
Other
84 stars 31 forks source link

Generated maven-metadata.xml for sbt plugins is rejected by Nexus #64

Closed ptab closed 3 years ago

ptab commented 3 years ago

At my organization we use this plugin to publish SBT projects to our internal Nexus instance, and it works great for regular projects. However, when publishing our internal SBT plugins, we receive a 400 Bad Request back from Nexus when uploading the maven-metadata.xml file (all other uploads work well).

After quite a bit of investigation, we have found that Nexus rejects the maven-metadata.xml file if either groupId or artifactId does not match the upload path (see https://issues.sonatype.org/browse/NEXUS-16853). When we try to publish an SBT plugin:

[info]  Uploading: https://<nexus-host>/nexus/repository/releases/nl/marktplaats/sbt/sbt-library-settings_2.12_1.0/maven-metadata.xml
[info]  Deploying nl.marktplaats.sbt:sbt-library-settings/maven-metadata.xml
[error] Could not transfer metadata nl.marktplaats.sbt:sbt-library-settings/maven-metadata.xml from/to releases (https://<nexus-host>/nexus/repository/releases/): Bad Request (400)

The generated file will contain:

<metadata>
    <groupId>nl.marktplaats.sbt</groupId>
    <artifactId>sbt-library-settings</artifactId>
    (...)
</metadata>

And since the value of artifactId in the file (sbt-library-settings) does not match the path (sbt-library-settings_2.12_1.0), this file is rejected.

I have forked this project and created a working solution (see https://github.com/arktekk/sbt-aether-deploy/compare/master...ptab:6ba41e9), but since it requires a change to internal Maven classes (see https://github.com/ptab/sbt-aether-deploy/commit/6ba41e9f88707a995079bd85fc244670529c7d02#diff-802d937d4289a6fa48eea5b6ee27325158590172ede247ca94c74dd76b433eeeR60-R63) I was forced to copy over a few Java classes which is not great.

Is there a better way to fix this issue? And if not, would you accept a PR that includes copies of these internal Maven classes?

hamnis commented 3 years ago

Sbt plugins are published to incorrect paths. that is correct. This is well-known, and no fix is possible :(

ptab commented 3 years ago

My fork is able to publish the maven-metadata.xml file with the correct artifactId, but in order to achieve that it copies plain Java classes directly from the Maven sources (which is not ideal). If you'd like to check it out I can create a PR.

hamnis commented 3 years ago

Does SBT resolve the plugin again correctly?

ptab commented 3 years ago

Yes, I'm able to use the published plugin in other SBT projects; and I'm also able to find the latest available version of this plugin using the maven-metadata.xml file.

hamnis commented 3 years ago

If you are willing to create a PR, then its interesting.