Skip to content

Commit

Permalink
Merge pull request #101 from kubukoz/add-scala3
Browse files Browse the repository at this point in the history
Add Scala 3 support
  • Loading branch information
tgodzik authored Oct 13, 2024
2 parents 539cf38 + 7269542 commit eeb76eb
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 18 deletions.
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")
// 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 {}
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

0 comments on commit eeb76eb

Please sign in to comment.