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

Add Scala 3 support #101

Merged
merged 4 commits into from
Oct 13, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: ['8', '17']
java: ['11', '17']

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
18 changes: 18 additions & 0 deletions .scalafix3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rules = [
DisableSyntax,
OrganizeImports,
NoValInForComprehension,
]

OrganizeImports {
removeUnused = false
expandRelative = true
groupedImports = Explode
groups = [
"re:javax?\\."
"scala."
"ch.epfl"
"bloop"
"*"
]
}
32 changes: 26 additions & 6 deletions build.sc
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -17,17 +18,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",
Expand All @@ -47,9 +47,14 @@ 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 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"
Expand All @@ -72,11 +77,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")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought: I didn't spend too much time on it, hoping someone with more Mill experience can provide a better understanding and maybe a proper fix. This seems like something that only affects us until we publish the 3.x support.

// 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
Expand Down
12 changes: 12 additions & 0 deletions config/src-2/bloop/config/SourceGeneratorCompanionPlatform.scala
Original file line number Diff line number Diff line change
@@ -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
] {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package bloop.config

trait SourceGeneratorCompanionPlatform {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thought: extends AbstractFunction3 was causing a "missing apply method" in Scala 3. Adding that apply was conflicting with the other apply - hence, version-specific sources.

12 changes: 2 additions & 10 deletions config/src/bloop/config/Config.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -364,7 +356,7 @@ object Config {
val platformJS = {
Platform.Js(
JsConfig(
"1.16.0",
"1.17.0",
LinkerMode.Release,
ModuleKindJS.ESModule,
false,
Expand Down