Skip to content

Commit

Permalink
Update to Scala 3 toolchain
Browse files Browse the repository at this point in the history
Co-Authored-By: Alexandre Archambault <alexandre.archambault@gmail.com>
  • Loading branch information
lolgab and alexarchambault committed May 9, 2024
1 parent 1a72247 commit a7b6264
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 222 deletions.
217 changes: 65 additions & 152 deletions build.sc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class KernelTestsTwoStepStartupDefinitions extends AlmondFunSuite {
|val sv = scala.util.Properties.versionNumberString
|""".stripMargin,
"import scala.compiletime.ops.*" + ls + ls +
"""sv: String = "2.13.11""""
"""sv: String = "2.13.10""""
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import almond.kernel.MessageFile
import almond.kernel.install.{Options => InstallOptions}
import almond.protocol.KernelInfo
import caseapp._
import caseapp.core.Scala3Helpers._
import caseapp.core.help.Help
import com.github.plokhotnyuk.jsoniter_scala.core.readFromArray
import coursierapi.{Dependency, Module}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,13 @@ object Tests {
"zipAll",
"zipWithIndex"
)
else
else {
// not sure why we get different results here
val twoStepRunnerExtra =
if (runner.differedStartUp)
Nil
else
Seq("Maximized")
Seq(
"!=",
"++",
Expand All @@ -1214,8 +1220,10 @@ object Tests {
":::",
":\\",
"==",
"CombinationsItr",
"Maximized",
"CombinationsItr"
) ++
twoStepRunnerExtra ++
Seq(
"PermutationsItr",
"addString",
"aggregate",
Expand Down Expand Up @@ -1379,6 +1387,7 @@ object Tests {
"zipAll",
"zipWithIndex"
)
}
val matches = res.flatMap(_.matches)
if (matches != expectedMatches) {
pprint.err.log(expectedMatches)
Expand Down Expand Up @@ -1702,7 +1711,13 @@ object Tests {
("zipAll", "Method"),
("zipWithIndex", "Method")
)
else
else {
// not sure why we get different results here
val twoStepRunnerExtra =
if (runner.differedStartUp)
Nil
else
Seq(("Maximized", "Object"))
Seq(
("!=", "Method"),
("++", "Method"),
Expand All @@ -1715,8 +1730,10 @@ object Tests {
(":::", "Method"),
(":\\", "Method"),
("==", "Method"),
("CombinationsItr", "Object"),
("Maximized", "Object"),
("CombinationsItr", "Object")
) ++
twoStepRunnerExtra ++
Seq(
("PermutationsItr", "Object"),
("addString", "Method"),
("addString", "Method"),
Expand Down Expand Up @@ -1900,6 +1917,7 @@ object Tests {
("zipAll", "Method"),
("zipWithIndex", "Method")
)
}

val metadata = ujson.read(res.head.metadata.value)
val types = metadata.obj("_jupyter_types_experimental")
Expand Down
10 changes: 0 additions & 10 deletions modules/shared/logger/src/main/scala-3/almond/logger/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@ package almond.logger

import almond.logger.internal._

import scala.language.experimental.macros
import scala.quoted._

final case class Logger(underlying: ActualLogger) {

def prefix(prefix: String): Logger =
Logger(underlying.prefix(prefix))

def error(message: String): Unit = macro LoggerMacros.error
def error(message: String, throwable: Throwable): Unit = macro LoggerMacros.errorEx
def warn(message: String): Unit = macro LoggerMacros.warn
def warn(message: String, throwable: Throwable): Unit = macro LoggerMacros.warnEx
def info(message: String): Unit = macro LoggerMacros.info
def info(message: String, throwable: Throwable): Unit = macro LoggerMacros.infoEx
def debug(message: String): Unit = macro LoggerMacros.debug
def debug(message: String, throwable: Throwable): Unit = macro LoggerMacros.debugEx

inline def error(inline message: String): Unit =
${ Logger.errorImpl('underlying, 'message, 'null) }
inline def error(inline message: String, inline throwable: Throwable): Unit =
Expand Down
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.7
39 changes: 14 additions & 25 deletions project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import mill._
import mill.scalalib._

object Versions {
def ammonite = "3.0.0-M0-56-1bcbe7f6"
def ammonite = "3.0.0-M0-58-9ccdff7c"
def caseApp = "2.1.0-M26"
def coursier = "2.1.9"
def jsoniterScala = "2.13.5"
Expand Down Expand Up @@ -31,16 +31,9 @@ implicit class DepOps(private val dep: Dep) {
}

object Deps {
def ammoniteCompiler(sv: String) =
ivy"com.lihaoyi:ammonite-compiler_$sv:${Versions.ammonite}"
def ammoniteRepl(sv: String) =
if (sv.startsWith("2.")) ivy"com.lihaoyi:ammonite-repl_$sv:${Versions.ammonite}"
else
ivy"com.lihaoyi:ammonite-cross-$sv-repl_${ScalaVersions.cross2_3Version(sv)}:${Versions.ammonite}"
def ammoniteReplApi(sv: String) =
if (sv.startsWith("2.")) ivy"com.lihaoyi:ammonite-repl-api_$sv:${Versions.ammonite}"
else
ivy"com.lihaoyi:ammonite-cross-$sv-repl-api_${ScalaVersions.cross2_3Version(sv)}:${Versions.ammonite}"
def ammoniteCompiler = ivy"com.lihaoyi:::ammonite-compiler:${Versions.ammonite}"
def ammoniteRepl = ivy"com.lihaoyi:::ammonite-repl:${Versions.ammonite}"
def ammoniteReplApi = ivy"com.lihaoyi:::ammonite-repl-api:${Versions.ammonite}"
def ammoniteSpark = ivy"sh.almond::ammonite-spark:0.14.0-RC8"
def caseAppAnnotations = ivy"com.github.alexarchambault::case-app-annotations:${Versions.caseApp}"
def caseApp = ivy"com.github.alexarchambault::case-app:${Versions.caseApp}"
Expand All @@ -53,10 +46,9 @@ object Deps {
def directiveHandler = ivy"io.github.alexarchambault.scala-cli::directive-handler:0.1.4"
def expecty = ivy"com.eed3si9n.expecty::expecty:0.16.0"
def fansi = ivy"com.lihaoyi::fansi:0.5.0"
def fs2(sv: String) =
if (sv.startsWith("2.")) ivy"co.fs2::fs2-core:3.9.4" else ivy"co.fs2:fs2-core_2.13:3.9.4"
def jansi = ivy"org.fusesource.jansi:jansi:2.4.1"
def jeromq = ivy"org.zeromq:jeromq:0.5.4"
def fs2 = ivy"co.fs2::fs2-core:3.9.4"
def jansi = ivy"org.fusesource.jansi:jansi:2.4.1"
def jeromq = ivy"org.zeromq:jeromq:0.5.4"
def jsoniterScalaCore =
ivy"com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-core:${Versions.jsoniterScala}"
def jsoniterScalaMacros =
Expand All @@ -79,20 +71,16 @@ object Deps {
def testUtil = ivy"io.github.alexarchambault::test-util:0.1.3"
def upickle =
ivy"com.lihaoyi::upickle:3.1.4" // trying to use the same version as Ammonite, to avoid bin compat issues
def upickleCompat(sv: String) =
// also using the 2.13 version in Scala 3, as that's the one that Ammonite pulls (the Scala 3 one creates bin compat issues too)
if (sv.startsWith("2.")) ivy"com.lihaoyi::upickle:3.1.4"
else ivy"com.lihaoyi:upickle_2.13:3.1.4"
def utest = ivy"com.lihaoyi::utest:0.8.3"
}

object ScalaVersions {
def scala3Latest = "3.3.1"
def scala3Compat = "3.3.0"
def cross2_3Version(sv: String) = "2.13.11"
def scala213 = "2.13.12"
def scala212 = "2.12.18"
val binaries = Seq(scala3Compat, scala213, scala212)
def scala3Latest = "3.3.1"
def scala3Compat = "3.3.0"
def scala213 = "2.13.12"
def scala212 = "2.12.18"
val binaries = Seq(scala3Compat, scala213, scala212)
val scala2Binaries = Seq(scala213, scala212)
val all = Seq(
scala3Latest,
scala3Compat,
Expand All @@ -110,4 +98,5 @@ object ScalaVersions {
if (sv.startsWith("2.12.")) scala212
else if (sv.startsWith("2.13.")) scala213
else scala3Compat

}
28 changes: 0 additions & 28 deletions project/settings.sc
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,6 @@ trait AlmondArtifactName extends SbtModule {
.mkString("-")
}

trait AlmondScala2Or3Module extends CrossSbtModule {
def crossScalaVersion: String
def supports3: Boolean = false
private def actualScalaVersion =
if (crossScalaVersion.startsWith("3.") && !supports3)
ScalaVersions.cross2_3Version(crossScalaVersion)
else crossScalaVersion
def scalaVersion = T(actualScalaVersion)
def useCrossSuffix = T {
crossScalaVersion.startsWith("3.") && !scalaVersion().startsWith("3.")
}
def artifactName = T {
val suffix = if (useCrossSuffix()) s"-cross-$crossScalaVersion" else ""
super.artifactName() + suffix
}
def scalacOptions = T {
val tastyReaderOptions =
if (crossScalaVersion.startsWith("3.") && !supports3) Seq("-Ytasty-reader")
else Nil
tastyReaderOptions
}
override def scalaVersionDirectoryNames =
ZincWorkerUtil.matchingVersions(actualScalaVersion)
}

trait AlmondScalacOptions extends ScalaModule {
def scalacOptions = T {
// see http://tpolecat.github.io/2017/04/25/scalac-flags.html
Expand Down Expand Up @@ -214,7 +189,6 @@ trait AlmondUnpublishedModule
with AlmondRepositories
with TransitiveSources
with AlmondArtifactName
with AlmondScala2Or3Module
with AlmondScalacOptions

trait AlmondModule
Expand All @@ -223,7 +197,6 @@ trait AlmondModule
with AlmondPublishModule
with TransitiveSources
with AlmondArtifactName
with AlmondScala2Or3Module
with PublishLocalNoFluff
with AlmondScalacOptions {

Expand Down Expand Up @@ -267,7 +240,6 @@ trait AlmondTestModule
with TestModule
with AlmondRepositories
with AlmondScalacOptions {
// with AlmondScala2Or3Module {

// originally based on https://github.com/com-lihaoyi/mill/blob/3335d2a2f7f33766a680e30df6a7d0dc0fbe08b3/scalalib/src/mill/scalalib/TestModule.scala#L80-L146
// goal here is to use a coursier bootstrap rather than a manifest JAR when testUseArgsFile is true
Expand Down

0 comments on commit a7b6264

Please sign in to comment.