Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support version scheme in pom #1629

Merged
merged 4 commits into from
Jan 8, 2022
Merged

Support version scheme in pom #1629

merged 4 commits into from
Jan 8, 2022

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Dec 16, 2021

Sbt recently added the possibility to state the versioning scheme in poms to allow precise binary compatibility checks.
https://scala-lang.org/blog/2021/02/16/preventing-version-conflicts-with-versionscheme.html

This PR implements some basic support to add the versionScheme to PublishModules.

All the naming and packages are arbitrary.
Suggestions accepted :) (as usual)

cc. @julienrf

@lolgab lolgab requested a review from lefou December 16, 2021 17:28
Copy link

@julienrf julienrf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was quick, thank you!

scalalib/src/PublishModule.scala Show resolved Hide resolved
scalalib/src/publish/VersionScheme.scala Outdated Show resolved Hide resolved
scalalib/src/PublishModule.scala Outdated Show resolved Hide resolved
scalalib/src/publish/Pom.scala Outdated Show resolved Hide resolved
scalalib/test/src/publish/PomTests.scala Outdated Show resolved Hide resolved
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. Can you tell, if coursier actually supports this info.versionScheme property, so that we also can benefit from it, or is this only used by sbt to filter coursier version resolutions by impact?

This PR effectively adds some property to the pom.xml, so I think the better implementation would be to add generic property support to mill.scalallib.publish.Pom, and then just derive the correct property from the selected version scheme. Also adding a properties or pomProperties setting to PublishModule would be nice, but can also be done later in a separate PR. I don't know, if the ivy file also support properties, but if, we should add the versionScheme property there too.

@julienrf
Copy link

julienrf commented Dec 17, 2021

Thanks for this contribution. Can you tell, if coursier actually supports this info.versionScheme property, so that we also can benefit from it, or is this only used by sbt to filter coursier version resolutions by impact?

As far as I know, the logic is implemented in sbt/librarymanagement: https://github.com/sbt/librarymanagement/blob/develop/core/src/main/scala/sbt/librarymanagement/EvictionError.scala

Here is Coursier documentation about versions handling: https://get-coursier.io/docs/other-version-handling

I believe it would make sense to move that logic upstream to coursier. Maybe @alexarchambault or @eed3si9n have an opinion?

I think the better implementation would be to add generic property support to mill.scalallib.publish.Pom

I agree. properties are also used to indicate the URL of the API documentation (via the info.apiURL element), which can be used by some tools. There are maybe other usages.

@lefou
Copy link
Member

lefou commented Dec 17, 2021

@julienrf Thanks for the pointers. I think properties are in general useful for interoperability with downstream consumers.

@lefou
Copy link
Member

lefou commented Jan 7, 2022

This PR needs to be rebased on latest main branch. The versionScheme target should then feed the publishProperties. The default scheme should be None so that (if nothing is configured) publishing works as previously and no extra property will be added. Some Scaladoc on publishProperties should denote, that some logic is already present and calling super is required to keep it.

@lolgab
Copy link
Member Author

lolgab commented Jan 8, 2022

Rebased the PR and applied the suggested change.
Do think it's better to exposed the Option with versionScheme being a Option[VersionScheme] or a VersionScheme as it was before where NoScheme was a special scheme containing None as value?

Defining a versionScheme in the previous way way was slightly nicer:

override def versionScheme = VersionScheme.EarlySemver

Instead of:

override def versionScheme = Some(VersionScheme.EarlySemver)

I took the idea from ScalaJSModule that defines the ModuleKind as NoModule.
It was my first contribution to Mill in 2018 :) #212

Anyway, @lefou let me know which one you prefer.

@lefou
Copy link
Member

lefou commented Jan 8, 2022

Do think it's better to exposed the Option with versionScheme being a Option[VersionScheme] or a VersionScheme as it was before where NoScheme was a special scheme containing None as value?

I think the use of an Option[VersionScheme] better transports the fact that no version scheme needs to be applied at all and also no property will be created from it when absent. With a VersionScheme.NoScheme this may be less obvious. A None can be understood without looking at VersionScheme and without studying all the provided cases.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you very much!

@lefou lefou merged commit 2440418 into main Jan 8, 2022
@lefou lefou deleted the support-version-scheme branch January 8, 2022 22:00
@lefou lefou added this to the after 0.10.0-M5 milestone Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants