Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Drop Scala 2.12 + add Scala 3 (but not use it) #176

Merged
merged 6 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main/scala/interplay/PlayBuildBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ object PlayBuildBase extends AutoPlugin {
val playBuildExtraTests = taskKey[Unit]("Run extra tests during the release")
val playBuildExtraPublish = taskKey[Unit]("Publish extract non aggregated projects during the release")
val playBuildRepoName = settingKey[String]("The name of the repository in the playframework GitHub organization")
val playCrossBuildRootProject = settingKey[Boolean]("Whether the root project should be cross built or not")
Copy link
Member

Choose a reason for hiding this comment

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

🙌🏼


// This is not using sbt-git because we need a more stable way to set
// the current branch in a more stable way, for example, we may want to
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/interplay/PlayLibraryBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import interplay.Omnidoc.autoImport.omnidocTagPrefix
omnidocTagPrefix := "",
compile / javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
doc / javacOptions := Seq("-source", "1.8"),
crossScalaVersions := Seq(scalaVersion.value, ScalaVersions.scala212),
crossScalaVersions := Seq(scalaVersion.value), // TODO: Add ScalaVersions.scala3
scalaVersion := sys.props.get("scala.version").getOrElse(ScalaVersions.scala213),
ThisBuild / playCrossBuildRootProject := true
)
}
13 changes: 1 addition & 12 deletions src/main/scala/interplay/PlayRootProjectBase.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package interplay

import sbt._
import sbt.Keys._

import interplay.PlayBuildBase.autoImport._

/**
* Base Plugin for a root project that doesn't get published.
Expand All @@ -13,13 +10,5 @@ import interplay.PlayBuildBase.autoImport._
object PlayRootProjectBase extends AutoPlugin {
override def trigger = noTrigger
override def requires = PlayBuildBase && PlaySonatypeBase && PlayReleaseBase
override def projectSettings = PlayNoPublishBase.projectSettings ++ Seq(
crossScalaVersions := {
if ((ThisBuild / playCrossBuildRootProject).?.value.exists(identity)) {
Seq(ScalaVersions.scala212, ScalaVersions.scala213)
Copy link
Member

Choose a reason for hiding this comment

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

Remove this if-else entirely?

Copy link
Member

Choose a reason for hiding this comment

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

And maybe even remove playCrossBuildRootProject and let other projects set crossScalaVersions explicitly if they need to.

Copy link
Member Author

Choose a reason for hiding this comment

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

Remove this if-else entirely?

Yes, I was thinking the same yesterday, but wasn't 100% sure. Actually since this is about root projects, which usually don't get published, I think its ok if we remove the default.

And maybe even remove playCrossBuildRootProject and let other projects set crossScalaVersions explicitly if they need to.

Done. I set crossScalaVersions in the scripted tests explicitely. The projects that I mentioned in this thread will not be affected, because like written they already set the cross version explicitely anyway.

} else {
Seq(ScalaVersions.scala212)
}
}
)
override def projectSettings = PlayNoPublishBase.projectSettings
}
1 change: 1 addition & 0 deletions src/main/scala/interplay/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package interplay
object ScalaVersions {
val scala212 = "2.12.14"
val scala213 = "2.13.6"
val scala3 = "3.0.1"
}

object SbtVersions {
Expand Down
4 changes: 3 additions & 1 deletion src/sbt-test/interplay/library-with-plugin/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import interplay.ScalaVersions._

lazy val common: Seq[Setting[_]] = Seq(
PgpKeys.publishSigned := {
IO.write(crossTarget.value / "publish-version", s"${publishTo.value.get.name}:${version.value}")
Expand All @@ -10,7 +12,7 @@ lazy val common: Seq[Setting[_]] = Seq(
lazy val `mock-root` = (project in file("."))
.settings(
common,
ThisBuild / playCrossBuildRootProject := true // activates cross build for Scala 2.12 and 2.13
crossScalaVersions := Seq(scala212, scala213)
)
.enablePlugins(PlayRootProject)
.aggregate(`mock-library`, `mock-sbt-plugin`) // has a sbt plugin that will be built together with root project
Expand Down
6 changes: 4 additions & 2 deletions src/sbt-test/interplay/library-with-plugin/test
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ $ exec git branch -u origin/main
$ exists mock-sbt-plugin/target/scripted-ran

# Make sure publishSigned ran on every project with the right publish settings
> contains target/scala-2.12/publish-version no-publish:1.2.3
#TODO:
#> contains target/scala-3/publish-version no-publish:1.2.3
> contains target/scala-2.13/publish-version no-publish:1.2.3
> contains mock-sbt-plugin/target/scala-2.12/sbt-1.0/publish-version sonatype-local-bundle:1.2.3
> contains mock-library/target/scala-2.12/publish-version sonatype-local-bundle:1.2.3
#TODO:
#> contains mock-library/target/scala-3/publish-version sonatype-local-bundle:1.2.3
> contains mock-library/target/scala-2.13/publish-version sonatype-local-bundle:1.2.3
> contains mock-sbt-library/target/scala-2.12/publish-version sonatype-local-bundle:1.2.3

Expand Down
7 changes: 6 additions & 1 deletion src/sbt-test/interplay/library-with-root/build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import interplay.ScalaVersions._

// What an actual project would look like
lazy val `mock-root` = (project in file("."))
.enablePlugins(PlayRootProject)
.aggregate(`mock-library`)
.settings(common)
.settings(
common,
crossScalaVersions := Seq(scala212, scala213)
)

lazy val `mock-library` = (project in file("mock-library"))
.enablePlugins(PlayLibrary)
Expand Down
6 changes: 4 additions & 2 deletions src/sbt-test/interplay/library-with-root/test
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ $ exec git branch -u origin/main
> release with-defaults

# Make sure publishSigned ran on every project with the right publish settings
> contains target/scala-2.12/publish-version no-publish:1.2.3
#TODO:
#> contains target/scala-3/publish-version no-publish:1.2.3
> contains target/scala-2.13/publish-version no-publish:1.2.3
> contains mock-library/target/scala-2.12/publish-version sonatype-local-bundle:1.2.3
#TODO:
#> contains mock-library/target/scala-3/publish-version sonatype-local-bundle:1.2.3
> contains mock-library/target/scala-2.13/publish-version sonatype-local-bundle:1.2.3

# Make sure sonatypeRelease ran only in the root project
Expand Down
3 changes: 2 additions & 1 deletion src/sbt-test/interplay/library/test
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ $ exec git diff
> release with-defaults

# Make sure publishSigned ran
> contains target/scala-2.12/publish-version sonatype-local-bundle:1.2.3
#TODO:
#> contains target/scala-3/publish-version sonatype-local-bundle:1.2.3
> contains target/scala-2.13/publish-version sonatype-local-bundle:1.2.3

# Make sure sonatypeRelease ran
Expand Down
7 changes: 6 additions & 1 deletion src/sbt-test/interplay/plugin-with-root/build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import interplay.ScalaVersions._

// What an actual project would look like
lazy val `mock-root` = (project in file("."))
.enablePlugins(PlayRootProject)
.aggregate(`mock-sbt-plugin`)
.settings(common)
.settings(
common,
crossScalaVersions := Seq(scala212, scala213)
)

lazy val `mock-sbt-plugin` = (project in file("mock-sbt-plugin"))
.enablePlugins(PlaySbtPlugin)
Expand Down
6 changes: 3 additions & 3 deletions src/sbt-test/interplay/plugin-with-root/test
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ $ exec git branch -u origin/main
# However, that initial state does not contain the above created .git folder (created via git init) yet.
> reload

> release cross with-defaults
Copy link
Member Author

@mkurz mkurz Aug 21, 2021

Choose a reason for hiding this comment

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

The reason why I removed cross here is because IMHO this is not a real life use case. This test here, as its name plugin-with-root tells us, tests a sbt plugin that activates the PlayRootProject plugin (see PlayRootProjectBase.scala above). As you can see above, the PlayRootProject did set crossScalaVersion to 2.12 until now. Now, I changed that to 2.13, which makes the scripted test here fail because it can not resolve .../org/scala-sbt/scripted-sbt_2.13/1.5.5/...
That is, as we know, because sbt plugins for sbt 1 need to be published with scala 2.12.
I had a look at the projects that still use interplay (#150) and which, from these projects, make use of the PlayRootProject plugin. That are

Now it turns out that all of these projects explicitly set crossScalaVersions anyway, overriding the value set by PlayRootProject:

Now... scalatestplus-play and slick are not sbt-plugins anyway but, in interplay terms, libraries and therefore set their cross versions to 2.12 and 2.13. Play just sets it to empty list for the root project.

The conclusion for me is that PlayRootProject was meant to be used for "libraries" rather than sbt plugins and you don't really want to enable PlayRootProject if your project is an sbt plugin, but if you do, you want to set cross version explicitly.

> release with-defaults

# Make sure scripted tests ran
$ exists mock-sbt-plugin/target/scripted-ran

# Make sure publishSigned ran on every project with the right publish settings
$ exists target/scala-2.12/publish-version
> contains target/scala-2.12/publish-version no-publish:1.2.3
$ exists target/scala-2.13/publish-version
> contains target/scala-2.13/publish-version no-publish:1.2.3
> contains mock-sbt-plugin/target/scala-2.12/sbt-1.0/publish-version sonatype-local-bundle:1.2.3

# Make sure bintrayRelease ran only in the root project
Expand Down