Skip to content

[POC] sbt 1.5.0 validation #11568

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

Closed
wants to merge 10 commits into from
Closed

[POC] sbt 1.5.0 validation #11568

wants to merge 10 commits into from

Conversation

adpi2
Copy link
Member

@adpi2 adpi2 commented Mar 1, 2021

The purpose of this PR is not to be merged. It is a peek in the future to check that sbt 1.5 will be able to replace sbt-dotty.

sbt/sbt#6342 (comment)

For this purpose:

  1. sbt is bumped to 1.5.0-bin-20210302T081602
  2. the use of sbt-dotty in the main build is removed
  3. sbt-dotty is removed from all scripted tests:
    Including the scripted tests of the sbt-dotty project itself to show that sbt-dotty is not needed anymore. All the tests passed with no trouble.
  4. sbt-dotty is removed from almost all the community sbt projects (46 out of 52), except the 6 ones below
- cats-effect-2
- cats-effect-3
- cats-mtl
- coop
- scodec-bits
- scodec

These projects use the SpiewakPlugin which requires the DottyPlugin (see here) and it was too much of a hassle for me to make things work without the SpiewakPlugin.

As an alternative, I bumped the version of sbt-dotty to 0.5.3 explicity in each one of them. So it shows that sbt-dotty is still compatible with sbt 1.5 when it comes to compiling, running and testing. However it appears that sbt-dotty doc task is not compatible with sbt 1.5.

I temporarily removed the doc checking of cats-effects and scodecs projects.

What I have learned during the process:

Most often than not, removing sbt-dotty is straightforward:

  • replace isDotty.value with one of the alternatives
isScala.value.startsWith("3")
VersionNumber(scalaVersion.value).matchesSemVer(SemanticSelector(">= 3.0.0-M1"))
  • replace .withDottyCompat(scalaVersion.value) with .cross(CrossVersion.for3Use2_13)
  • remove occurences of useScaladoc := true

There are 2 small difficulties:

1. libraryDependencies.map(_.withDottyCompat(scalaVersion.value))

This pattern cannot be naively rewritten into

libraryDependencies.map(_.cross(CrossVersion.for3Use2_13))

because:

  • sbt 1.5.0 adds the scala3-library to the libraryDependencies
  • CrossVersion.for3Use2_13 cannot be used on java dependencies:
("org.scala-sbt" % "test-interface" % "1.0").cross(CrossVersion.for3Use2_13) // incorrect, try to resolve test-interface_2.13
"org.scala-sbt" % "test-interface" % "1.0" // correct

One general solution is

libraryDependencies.value.map { module =>
  if (module.name != ScalaArtifacts.Scala3LibraryID && module.crossVersion == CrossVersion.binary)
    module.cross(CrossVersion.for3Use2_13)
  else module
}

2. dottyLatestNightlyBuild

The code is here.

This feature is obviously not supported by sbt 1.5. It may deserve to be published as an independent library.

@adpi2 adpi2 changed the title [WIP] sbt 1.5.0-M2 validation [WIP] sbt 1.5.0 validation Mar 1, 2021
@adpi2 adpi2 force-pushed the sbt-1.5 branch 9 times, most recently from 23516f7 to a3dcb26 Compare March 4, 2021 20:11
@griggt
Copy link
Contributor

griggt commented Mar 4, 2021

@adpi2 FYI the community_build_a failures are due to #11604 (there is a race condition in the scalatest build)

@adpi2 adpi2 force-pushed the sbt-1.5 branch 2 times, most recently from 18076dc to f5fa041 Compare March 5, 2021 11:08
@adpi2 adpi2 changed the title [WIP] sbt 1.5.0 validation [POC] sbt 1.5.0 validation Mar 5, 2021
@adpi2 adpi2 force-pushed the sbt-1.5 branch 2 times, most recently from e5b932f to b9692b0 Compare March 11, 2021 08:32
@adpi2 adpi2 requested review from smarter and removed request for smarter March 11, 2021 09:14
@adpi2 adpi2 self-assigned this Mar 11, 2021
@adpi2 adpi2 force-pushed the sbt-1.5 branch 2 times, most recently from 36d29d9 to 460556c Compare March 11, 2021 10:20
import sbt.internal.inc.ScalaInstance

object Bootstrap {
// copied from https://github.com/sbt/sbt/blob/33e2bfe2810246c8e4e1b37ec110d15e588a4fce/main/src/main/scala/sbt/Defaults.scala#L1120-L1165
Copy link
Member

Choose a reason for hiding this comment

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

Could this method be made public upstream?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think that's worth it. It's only useful for works on the Scala compilers and we probably don't want to maintain compatibility just in case other people use it.

Copy link
Member

Choose a reason for hiding this comment

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

Your call, but It seems better than having to deal with the complicated classloader caching logic API directly. And does this need to be in package sbt?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does because the ScalaInstance constructor is package private. But we could as well create our own ScalaInstance implementation.

This code is a quick and dirty copy-paste, it can be made simpler.

Copy link
Member

Choose a reason for hiding this comment

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

It does because the ScalaInstance constructor is package private.

It looks public to me (https://github.com/sbt/zinc/blob/13ddb10938237263f706174439d8ed055e8e4ac2/internal/zinc-classpath/src/main/scala/sbt/internal/inc/ScalaInstance.scala#L34-L43), and weren't we already using it before this PR?

@adpi2 adpi2 force-pushed the sbt-1.5 branch 3 times, most recently from 041207a to 0bc5818 Compare March 24, 2021 09:07
@smarter
Copy link
Member

smarter commented Mar 24, 2021

This PR has a commit which adds the pdbp submodule directory (which was removed from the dotty repo in a previous PR) without adding it to .gitmodules, the result is that git explodes with "fatal: No url found for submodule path 'community-build/community-projects/pdbp' in .gitmodules" and because 1) the git repo is not cleaned up afterwards and 2) the git checkout action runs "git submodule foreach ..." before it pulls the current git branch, this affected other PRs hence why the CI exploded: https://github.com/lampepfl/dotty/commits/master

The pdbp submodule has been restored on master so if you rebase things should work out.

adpi2 added 9 commits March 30, 2021 15:10
These projects depends on the SpiewakPlugin plugin which transitively
depends on DottyPlugin. Removing DottyPlugin from these projects
would require altering SpiewakPlugin, wich is out of scope here.

Alternatively we force the version of sbt-dotty to be 0.5.3, checking
that sbt 1.5.0 will be compatible with sbt-dotty.
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