com-lihaoyi / mill

Mill is a fast JVM build tool that supports Java and Scala. 2-3x faster than Gradle and 5-10x faster than Maven for common workflows, Mill aims to make your project’s build process performant, maintainable, and flexible
https://mill-build.org/
MIT License
2.04k stars 331 forks source link

feat: adding sonatype central support #3130

Closed Andrapyre closed 4 months ago

Andrapyre commented 5 months ago

Description

This PR adds support for the new Sonatype Central publishing api, documented here and here. To use, ensure that your environment variables contain the appropriate credentials and configure your module like so in build.sc:

import $ivy.`com.lihaoyi::mill-contrib-sonatypecentral:`
import mill.contrib.sonatypecentral.SonatypeCentralPublishModule

object mymodule extends SonatypeCentralPublishModule {
  ...
}

New Dependencies

This PR introduces the following new dependency:

ivy"com.lumidion::sonatype-central-client-requests:0.2.0" 
Andrapyre commented 5 months ago

@lihaoyi , could you take a look at this? A few open questions:

  1. What's the best way to make these changes accessible to the user? By altering the current PublishModule or by creating a new SonatypeCentralPublishModule or something like it?
  2. There are a number of changes to the PublishModule affecting binary compat. Basically, I refactored as many publish options as possible into two case classes (one for legacy publishing and one for central publishing) that the user can configure, instead of having the user pass them directly into the publish function. Is breaking binary compat acceptable here, since mill still hasn't hit version 1.0.0?
  3. The current implementation outputs publishable jar files to ./out/central-publish. Let me know if that should change (I don't think the older Sonatype implementation outputted any jar files, unless I'm mistaken) or if the directory should be configurable.
Andrapyre commented 5 months ago

I've updated with requested changes and documentation. Before I go on to add tests, could you review and approve the current implementation?

Andrapyre commented 5 months ago

@lefou and @nightscape , just making sure this doesn't get lost.

nightscape commented 5 months ago

@lefou how would the separate PublishModule work with e.g. mill-ci-release which extends PublishModule and provides additional functionality on top?

nightscape commented 4 months ago

@lefou ping 😉

Andrapyre commented 4 months ago

@nightscape , mill-ci-release would need a new module that extends SonatypeCentralPublishModule. The two publishing processes (standard and Sonatype Central) are different enough that @lefou is probably right that these should live in separate modules.

lefou commented 4 months ago

I can't say much about mill-ci-release, which I don't use. (I think publishing with Mill built-in support is already straight forward, given that you have a properly setup pgp/gpg key.) If mill-ci-release needs to be aware of any additional target not already provided by PublishModule (which you could mix-in), then it most likely also needs extra customizations.

Andrapyre commented 4 months ago

@lefou , this PR is ready to be reviewed. I have made all requested changes (e.g. this is now a contrib module, no changes to bincompat, removed case classes, etc). Could you explain why this PR was changed to draft with a reference to your previous comment?

lefou commented 4 months ago

@Andrapyre I somehow missed, that you already changed to PR. Sorry for that.

Andrapyre commented 4 months ago

Can you please update the PR description to reflect the current state?

Done.