From f4d8344400ecbae2b9bca87defb894e3de663df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Sat, 5 Oct 2024 15:38:54 +0200 Subject: [PATCH 1/4] Add Scala 3 support --- build.sc | 26 ++++++++++++++----- .../SourceGeneratorCompanionPlatform.scala | 12 +++++++++ .../SourceGeneratorCompanionPlatform.scala | 3 +++ config/src/bloop/config/Config.scala | 12 ++------- 4 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 config/src-2/bloop/config/SourceGeneratorCompanionPlatform.scala create mode 100644 config/src-3/bloop/config/SourceGeneratorCompanionPlatform.scala diff --git a/build.sc b/build.sc index 4c4c1a3..73ccef7 100644 --- a/build.sc +++ b/build.sc @@ -17,17 +17,16 @@ import io.kipp.mill.ci.release.CiReleaseModule val scala212 = "2.12.19" val scala213 = "2.13.14" +val scala3 = "3.3.4" -val scalaJS1 = "1.16.0" +val scalaJS1 = "1.17.0" -val scalaVersions = List(scala212, scala213) +val scalaVersions = List(scala212, scala213, scala3) trait CommonPublish extends CiReleaseModule with Mima { override def artifactName = "bloop-config" - override def mimaPreviousVersions = Seq("2.0.2") - override def pomSettings = PomSettings( description = "Bloop configuration library.", organization = "ch.epfl.scala", @@ -47,7 +46,7 @@ trait CommonPublish extends CiReleaseModule with Mima { trait Common extends CrossScalaModule with ScalafmtModule with ScalafixModule { - val jsoniterVersion = "2.4.0" + val jsoniterVersion = "2.30.14" val unrollVersion = "0.1.12" override def ivyDeps = Agg( @@ -72,11 +71,26 @@ trait CommonTest extends ScalaModule with TestModule.Munit { } object config extends Cross[ConfigModule](scalaVersions) + trait ConfigModule extends CrossPlatform { trait Shared extends CrossPlatformCrossScalaModule with Common - with CommonPublish + with CommonPublish { + + // note: somehow, this doesn't work (causes "Please override mimaPreviousVersions or mimaPreviousArtifacts") + // override def mimaPreviousVersions: Target[Seq[String]] = + // T { + // if (scalaVersion() == scala3) Seq.empty[String] else Seq("2.0.2") + // } + // so we have to override mimaPreviousArtifacts fully: + // at least until the Scala 3 release is published. + + override def mimaPreviousArtifacts: Target[Agg[Dep]] = T { + if (scalaVersion() == scala3) Agg.empty[Dep] + else Agg(ivy"ch.epfl.scala::bloop-config::2.0.2") + } + } object jvm extends Shared { object test extends CrossPlatformSources with ScalaTests with CommonTest diff --git a/config/src-2/bloop/config/SourceGeneratorCompanionPlatform.scala b/config/src-2/bloop/config/SourceGeneratorCompanionPlatform.scala new file mode 100644 index 0000000..8f6fb21 --- /dev/null +++ b/config/src-2/bloop/config/SourceGeneratorCompanionPlatform.scala @@ -0,0 +1,12 @@ +package bloop.config + +import scala.runtime.AbstractFunction3 + +// needed for binary compat with 2.0.2 +trait SourceGeneratorCompanionPlatform + extends AbstractFunction3[ + List[Config.SourcesGlobs], + PlatformFiles.Path, + List[String], + Config.SourceGenerator + ] {} diff --git a/config/src-3/bloop/config/SourceGeneratorCompanionPlatform.scala b/config/src-3/bloop/config/SourceGeneratorCompanionPlatform.scala new file mode 100644 index 0000000..25b8378 --- /dev/null +++ b/config/src-3/bloop/config/SourceGeneratorCompanionPlatform.scala @@ -0,0 +1,3 @@ +package bloop.config + +trait SourceGeneratorCompanionPlatform {} diff --git a/config/src/bloop/config/Config.scala b/config/src/bloop/config/Config.scala index 5d90c08..eff3a15 100644 --- a/config/src/bloop/config/Config.scala +++ b/config/src/bloop/config/Config.scala @@ -1,7 +1,6 @@ package bloop.config import scala.annotation.unroll -import scala.runtime.AbstractFunction3 import bloop.config.PlatformFiles.Path import bloop.config.PlatformFiles.emptyPath @@ -284,14 +283,7 @@ object Config { @unroll unmanagedInputs: List[Path] = Nil ) - object SourceGenerator - // needed for binary compat with 2.0.2 - extends AbstractFunction3[ - List[SourcesGlobs], - Path, - List[String], - SourceGenerator - ] + object SourceGenerator extends SourceGeneratorCompanionPlatform case class Project( name: String, @@ -364,7 +356,7 @@ object Config { val platformJS = { Platform.Js( JsConfig( - "1.16.0", + "1.17.0", LinkerMode.Release, ModuleKindJS.ESModule, false, From 11743749397fe7132f579caf595310c1c893fc4f Mon Sep 17 00:00:00 2001 From: tgodzik Date: Sun, 13 Oct 2024 17:25:33 +0200 Subject: [PATCH 2/4] chore: Use separate scalafix config for Scala 3 --- .scalafix3.conf | 18 ++++++++++++++++++ build.sc | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 .scalafix3.conf diff --git a/.scalafix3.conf b/.scalafix3.conf new file mode 100644 index 0000000..46931ae --- /dev/null +++ b/.scalafix3.conf @@ -0,0 +1,18 @@ +rules = [ + DisableSyntax, + OrganizeImports, + NoValInForComprehension, +] + +OrganizeImports { + removeUnused = false + expandRelative = true + groupedImports = Explode + groups = [ + "re:javax?\\." + "scala." + "ch.epfl" + "bloop" + "*" + ] +} diff --git a/build.sc b/build.sc index 73ccef7..a2dc7c5 100644 --- a/build.sc +++ b/build.sc @@ -1,3 +1,4 @@ +import os.Path import $ivy.`com.github.lolgab::mill-mima::0.1.1` import $ivy.`com.github.lolgab::mill-crossplatform::0.2.4` import $ivy.`com.goyeau::mill-scalafix::0.4.0` @@ -49,6 +50,11 @@ trait Common extends CrossScalaModule with ScalafmtModule with ScalafixModule { val jsoniterVersion = "2.30.14" val unrollVersion = "0.1.12" + override def scalafixConfig: T[Option[Path]] = T { + if (scalaVersion() == scala3) Some(os.pwd / ".scalafix3.conf") + else Some(os.pwd / ".scalafix.conf") + } + override def ivyDeps = Agg( ivy"com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-core::$jsoniterVersion", ivy"com.lihaoyi::unroll-annotation:$unrollVersion" From 95d077a4c1ebc65c51f24ccd00b8a338da837dbd Mon Sep 17 00:00:00 2001 From: tgodzik Date: Sun, 13 Oct 2024 17:26:49 +0200 Subject: [PATCH 3/4] improvement: Switch to using JDK 11 a minimum --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ea7678..3ed4636 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: strategy: fail-fast: false matrix: - java: ['8', '17'] + java: ['11', '17'] steps: - uses: actions/checkout@v4 From 7269542c22423af34f27308c6d1d4888721632f5 Mon Sep 17 00:00:00 2001 From: tgodzik Date: Sun, 13 Oct 2024 17:28:47 +0200 Subject: [PATCH 4/4] chore: Actually release on JDK 11 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26c4d43..5ee4496 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '17' + java-version: '11' - run: ./mill io.kipp.mill.ci.release.ReleaseModule/publishAll env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}