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

build.mill files compiled by Scala 3 #3369

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0eded58
FIX METALS - mill-build/build.sc -> mill-build/build.mill
bishabosha Sep 12, 2024
3a19851
Part 1 - fix compilation errors and stub macros
bishabosha Aug 5, 2024
3c75dcb
Part 2 - reimplement discover macro
bishabosha Oct 12, 2024
6509bca
Part 3 - move implementation of Caller.generate to Module
bishabosha Aug 9, 2024
9300acd
Part 4 - reimplement Applicative and Target macros
bishabosha Aug 12, 2024
d8bc295
Part 6 - implement EnclosingClass, pass specific integration tests
bishabosha Aug 13, 2024
28f82ae
Part 7 - implement Cross.Factory macro (TODO split shims out)
bishabosha Sep 5, 2024
89bf556
Part 8 - adjust Zinc reporter instead of linenumbers plugin
bishabosha Sep 9, 2024
82f5a45
Part 9 - fix CodeGen integration tests for Scala 3
bishabosha Sep 11, 2024
49e2dc2
Part 10 - fix GenIdea
bishabosha Sep 15, 2024
18302af
Part 12 - rework contrib.scoverage.api to be java based.
bishabosha Sep 16, 2024
8ab1d80
TEMP: skip integration.feature[plugin-classpath].local.test
bishabosha Sep 17, 2024
f179432
Part 13 - fix contrib.playlib resolution of twirl and router worker
bishabosha Sep 19, 2024
8e76ffb
Part 14 - fix contrib.proguard default options to filter scala.AnyKind
bishabosha Sep 20, 2024
3c0ed75
TEMP: skip scalafix ExplicitResultType for scala 3, fix binary to 2.13
bishabosha Sep 20, 2024
0a56c0c
Fix resolution of Mima previous artifacts
bishabosha Sep 20, 2024
c64535b
TEMP: skip mima checking because scala 3 introduces too many errors
bishabosha Sep 20, 2024
c91fe8f
Add .zed to .gitignore
bishabosha Sep 21, 2024
43d7f7a
Part NN - Implement Scala 3 syntax support
bishabosha Sep 21, 2024
dd88778
generate patch diff for bootstrap
bishabosha Sep 20, 2024
27612d1
Adjust DocAnnotationsTests: elide line number and extra interfaces
bishabosha Oct 10, 2024
c466f2f
fix integration.feature[bsp-server] tests
bishabosha Oct 11, 2024
39da1a5
TEMP: Zinc invalidation difference
bishabosha Oct 19, 2024
93cb8a3
scala 3 syntax uses Scala 3 enum, improve error message
bishabosha Oct 19, 2024
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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ output/
.idea_modules
.idea
.vscode/
.zed/
out/
/.bloop/
/.metals/
Expand Down
5 changes: 5 additions & 0 deletions .scalafix-3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rules = [
RemoveUnused,
NoAutoTupling
# ExplicitResultTypes
]
3 changes: 1 addition & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ newlines.source = keep

project.git = true

runner.dialect = scala213

runner.dialect = scala3
2 changes: 1 addition & 1 deletion bsp/src/mill/bsp/BSP.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mill.bsp

import mill.api.{Ctx, PathRef}
import mill.{Agg, T, Task}
import mill.{Agg, T, Task, given}
import mill.define.{Command, Discover, ExternalModule}
import mill.main.BuildInfo
import mill.eval.Evaluator
Expand Down
5 changes: 5 additions & 0 deletions bsp/src/mill/bsp/BspServerResult.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package mill.bsp

import mill.api.internal
import mill.api.Mirrors
import mill.api.Mirrors.autoMirror

@internal
sealed trait BspServerResult
Expand Down Expand Up @@ -28,4 +30,7 @@ object BspServerResult {

implicit val jsonify: upickle.default.ReadWriter[BspServerResult] =
upickle.default.macroRW

private given Root_BspServerResult: Mirrors.Root[BspServerResult] =
Mirrors.autoRoot[BspServerResult]
}
1 change: 1 addition & 0 deletions bsp/worker/src/mill/bsp/worker/MillBuildServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import mill.runner.MillBuildRootModule
import mill.scalalib.bsp.{BspModule, JvmBuildTarget, ScalaBuildTarget}
import mill.scalalib.{JavaModule, SemanticDbJavaModule, TestModule}
import mill.util.ColorLogger
import mill.given

import java.io.PrintStream
import java.util.concurrent.CompletableFuture
Expand Down
145 changes: 101 additions & 44 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object Deps {
// The Scala version to use
// When updating, run "Publish Bridges" Github Actions for the new version
// and then add to it `bridgeScalaVersions`
val scalaVersion = "2.13.14"
val scalaVersion = "3.5.0"
val scala2Version = "2.13.14"
// The Scala 2.12.x version to use for some workers
val workerScalaVersion212 = "2.12.19"
Expand All @@ -69,14 +69,14 @@ object Deps {

object Scalajs_1 {
val scalaJsVersion = "1.16.0"
val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0"
val scalajsEnvExoegoJsdomNodejs = ivy"net.exoego::scalajs-env-jsdom-nodejs:2.1.0"
val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.4.0"
val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0"
val scalajsEnvSelenium = ivy"org.scala-js::scalajs-env-selenium:1.1.1"
val scalajsSbtTestAdapter = ivy"org.scala-js::scalajs-sbt-test-adapter:${scalaJsVersion}"
val scalajsLinker = ivy"org.scala-js::scalajs-linker:${scalaJsVersion}"
val scalajsImportMap = ivy"com.armanbilge::scalajs-importmap:0.1.1"
val scalajsEnvJsdomNodejs = ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0".withDottyCompat(scalaVersion)
val scalajsEnvExoegoJsdomNodejs = ivy"net.exoego::scalajs-env-jsdom-nodejs:2.1.0".withDottyCompat(scalaVersion)
val scalajsEnvNodejs = ivy"org.scala-js::scalajs-env-nodejs:1.4.0".withDottyCompat(scalaVersion)
val scalajsEnvPhantomjs = ivy"org.scala-js::scalajs-env-phantomjs:1.0.0".withDottyCompat(scalaVersion)
val scalajsEnvSelenium = ivy"org.scala-js::scalajs-env-selenium:1.1.1".withDottyCompat(scalaVersion)
val scalajsSbtTestAdapter = ivy"org.scala-js:scalajs-sbt-test-adapter_2.13:${scalaJsVersion}"
val scalajsLinker = ivy"org.scala-js:scalajs-linker_2.13:${scalaJsVersion}"
val scalajsImportMap = ivy"com.armanbilge::scalajs-importmap:0.1.1".withDottyCompat(scalaVersion)
}

object Scalanative_0_5 {
Expand All @@ -103,9 +103,11 @@ object Deps {
}
object Play_2_7 extends Play {
val playVersion = "2.7.9"
override def scalaVersion: String = Deps.scala2Version
}
object Play_2_8 extends Play {
val playVersion = "2.8.22"
override def scalaVersion: String = Deps.scala2Version
}
object Play_2_9 extends Play {
val playVersion = "2.9.5"
Expand All @@ -119,9 +121,9 @@ object Deps {
val acyclic = ivy"com.lihaoyi:::acyclic:0.3.12"
val ammoniteVersion = "3.0.0-2-6342755f"
val asmTree = ivy"org.ow2.asm:asm-tree:9.7.1"
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5"
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5".withDottyCompat(scalaVersion)

val coursier = ivy"io.get-coursier::coursier:2.1.14"
val coursier = ivy"io.get-coursier::coursier:2.1.14".withDottyCompat(scalaVersion)
val coursierInterface = ivy"io.get-coursier:interface:1.0.19"

val cask = ivy"com.lihaoyi::cask:0.9.4"
Expand Down Expand Up @@ -161,29 +163,34 @@ object Deps {
// can't use newer versions, as these need higher Java versions
val testng = ivy"org.testng:testng:7.5.1"
val sbtTestInterface = ivy"org.scala-sbt:test-interface:1.0"
def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:${scalaVersion}"
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.8.3"
def scalaCompiler(scalaVersion: String) = {
if (ZincWorkerUtil.isScala3(scalaVersion)) ivy"org.scala-lang:scala3-compiler_3:${scalaVersion}"
else ivy"org.scala-lang:scala-compiler:${scalaVersion}"
}
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.8.3".withDottyCompat(scalaVersion)
def scalap(scalaVersion: String) = ivy"org.scala-lang:scalap:${scalaVersion}"
def scalaReflect(scalaVersion: String) = ivy"org.scala-lang:scala-reflect:${scalaVersion}"
def scalaReflect(scalaVersion: String) =
if (ZincWorkerUtil.isScala3(scalaVersion)) ivy"org.scala-lang:scala-reflect:${Deps.scala2Version}"
else ivy"org.scala-lang:scala-reflect:${scalaVersion}"
val scoverage2Version = "2.1.1"
val scalacScoverage2Plugin = ivy"org.scoverage:::scalac-scoverage-plugin:${scoverage2Version}"
val scalacScoverage2Reporter = ivy"org.scoverage::scalac-scoverage-reporter:${scoverage2Version}"
val scalacScoverage2Domain = ivy"org.scoverage::scalac-scoverage-domain:${scoverage2Version}"
val scalacScoverage2Serializer = ivy"org.scoverage::scalac-scoverage-serializer:${scoverage2Version}"
val scalaparse = ivy"com.lihaoyi::scalaparse:${fastparse.version}"
val scalatags = ivy"com.lihaoyi::scalatags:0.12.0"
val scalatags = ivy"com.lihaoyi::scalatags:0.12.0".withDottyCompat(scalaVersion)
def scalaXml = ivy"org.scala-lang.modules::scala-xml:2.3.0"
// keep in sync with doc/antora/antory.yml
val semanticDBscala = ivy"org.scalameta:::semanticdb-scalac:4.9.9"
val semanticDbJava = ivy"com.sourcegraph:semanticdb-java:0.10.3"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.3.1"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.4.3-M1"
val upickle = ivy"com.lihaoyi::upickle:3.3.1"
val windowsAnsi = ivy"io.github.alexarchambault.windows-ansi:windows-ansi:0.0.5"
val zinc = ivy"org.scala-sbt::zinc:1.10.2"
val zinc = ivy"org.scala-sbt::zinc:1.10.2".withDottyCompat(scalaVersion)
// keep in sync with doc/antora/antory.yml
val bsp4j = ivy"ch.epfl.scala:bsp4j:2.2.0-M2"
val fansi = ivy"com.lihaoyi::fansi:0.5.0"
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.14.0"
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.14.0".withDottyCompat(scalaVersion)
val requests = ivy"com.lihaoyi::requests:0.9.0"
val logback = ivy"ch.qos.logback:logback-classic:1.5.7"
val sonatypeCentralClient = ivy"com.lumidion::sonatype-central-client-requests:0.3.0"
Expand Down Expand Up @@ -270,7 +277,7 @@ def millBinPlatform: T[String] = Task {
def baseDir = build.millSourcePath

val essentialBridgeScalaVersions =
Seq(Deps.scalaVersion, Deps.workerScalaVersion212)
Seq(Deps.scalaVersion, Deps.scala2Version, Deps.workerScalaVersion212)
// published compiler bridges
val bridgeScalaVersions = Seq(
// Our version of Zinc doesn't work with Scala 2.12.0 and 2.12.4 compiler
Expand Down Expand Up @@ -407,30 +414,60 @@ trait MillPublishJavaModule extends MillJavaModule with PublishModule {
*/
trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModule { outer =>
def scalaVersion = Deps.scalaVersion
def scalafixScalaBinaryVersion = ZincWorkerUtil.scalaBinaryVersion(scalaVersion())
def scalapVersion: T[String] = Deps.scala2Version
def scalafixScalaBinaryVersion = T {
def sv = scalaVersion()
if (ZincWorkerUtil.isScala3(sv)) "2.13"
else ZincWorkerUtil.scalaBinaryVersion(sv)
}

def scalafixConfig = T {
if (ZincWorkerUtil.isScala3(scalaVersion())) Some(T.workspace / ".scalafix-3.conf") else None
}
def semanticDbVersion = Deps.semanticDBscala.version
def scalacOptions =
super.scalacOptions() ++ Seq(
"-deprecation",
"-P:acyclic:force",
"-feature",
"-Xlint:unused",
"-Xlint:adapted-args",
"-Xsource:3",
"-Wconf:msg=inferred type changes:silent",
"-Wconf:msg=case companions no longer extend FunctionN:silent",
"-Wconf:msg=access modifiers for:silent",
"-Wconf:msg=found in a package prefix of the required type:silent"
"-feature"
) ++ (
if (ZincWorkerUtil.isScala3(scalaVersion())) Seq(
// "-Werror",
"-Wunused:all",
// "-no-indent",
// "-Wvalue-discard",
// "-Wshadow:all",
// "-Wsafe-init",
// "-Wnonunit-statement",
// "-Wimplausible-patterns",
)
else Seq(
"-P:acyclic:force",
"-Xlint:unused",
"-Xlint:adapted-args",
"-Xsource:3",
"-Wconf:msg=inferred type changes:silent",
"-Wconf:msg=case companions no longer extend FunctionN:silent",
"-Wconf:msg=access modifiers for:silent",
"-Wconf:msg=found in a package prefix of the required type:silent"
)
)

def scalacPluginIvyDeps =
def scalacPluginIvyDeps = T {
val sv = scalaVersion()
val binaryVersion = ZincWorkerUtil.scalaBinaryVersion(sv)
val hasModuleDefs = binaryVersion == "2.13" || binaryVersion == "3"
super.scalacPluginIvyDeps() ++
Agg(Deps.acyclic) ++
Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefsPlugin)
Agg.when(binaryVersion != "3")(Deps.acyclic) ++
Agg.when(hasModuleDefs)(Deps.millModuledefsPlugin)
}

def mandatoryIvyDeps =
def mandatoryIvyDeps = T {
val sv = scalaVersion()
val binaryVersion = ZincWorkerUtil.scalaBinaryVersion(sv)
val hasModuleDefs = binaryVersion == "2.13" || binaryVersion == "3"
super.mandatoryIvyDeps() ++
Agg.when(scalaVersion().startsWith("2.13."))(Deps.millModuledefs)
Agg.when(hasModuleDefs)(Deps.millModuledefs)
}

/** Default tests module. */
lazy val test: MillScalaTests = new MillScalaTests {}
Expand All @@ -446,7 +483,8 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
trait MillBaseTestsModule extends TestModule {
def forkArgs = Task {
Seq(
s"-DMILL_SCALA_2_13_VERSION=${Deps.scalaVersion}",
s"-DMILL_SCALA_3_NEXT_VERSION=${Deps.scalaVersion}",
s"-DMILL_SCALA_2_13_VERSION=${Deps.scala2Version}",
s"-DMILL_SCALA_2_12_VERSION=${Deps.workerScalaVersion212}",
s"-DTEST_SCALA_2_13_VERSION=${Deps.testScala213Version}",
s"-DTEST_SCALA_2_13_VERSION_FOR_SCALANATIVE_4_2=${Deps.testScala213VersionForScalaNative42}",
Expand Down Expand Up @@ -569,15 +607,31 @@ trait MillStableScalaModule extends MillPublishScalaModule with Mima {
Agg.from(
Settings.mimaBaseVersions
.filter(v => !skipPreviousVersions().contains(v))
.map(version =>
ivy"${pomSettings().organization}:${artifactId()}:${version}"
)
.map({ version =>
val patchedSuffix = {
val base = artifactSuffix()
version match {
case s"0.$minor.$_" if minor.toIntOption.exists(_ < 12) =>
base match {
case "_3" => "_2.13"
case s"_3_$suffix" => s"_2.13_$suffix"
case _ => base
}
case _ => base
}
}
val patchedId = artifactName() + patchedSuffix
ivy"${pomSettings().organization}:${patchedId}:${version}"
})
)
}

def mimaExcludeAnnotations = Seq("mill.api.internal", "mill.api.experimental")
def mimaCheckDirection = CheckDirection.Backward
def skipPreviousVersions: T[Seq[String]] = T(Seq.empty[String])
def skipPreviousVersions: T[Seq[String]] = T {
T.log.info("Skipping mima for previous versions (!!1000s of errors due to Scala 3)")
mimaPreviousVersions() // T(Seq.empty[String])
}
}

object bridge extends Cross[BridgeModule](compilerBridgeScalaVersions)
Expand All @@ -590,7 +644,9 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
def ivyDeps = Agg(
ivy"org.scala-sbt:compiler-interface:${Deps.zinc.version}",
ivy"org.scala-sbt:util-interface:${Deps.zinc.version}",
ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
) ++ Agg(
if (ZincWorkerUtil.isScala3(crossScalaVersion)) ivy"org.scala-lang::scala3-compiler:${crossScalaVersion}"
else ivy"org.scala-lang:scala-compiler:${crossScalaVersion}"
)

def resources = Task.Sources {
Expand All @@ -599,7 +655,8 @@ trait BridgeModule extends MillPublishJavaModule with CrossScalaModule {
}

def compilerBridgeIvyDeps: T[Agg[Dep]] = Agg(
ivy"org.scala-sbt::compiler-bridge:${Deps.zinc.version}".exclude("*" -> "*")
(if (ZincWorkerUtil.isScala3(crossScalaVersion)) ivy"org.scala-lang:scala3-sbt-bridge:${crossScalaVersion}"
else ivy"org.scala-sbt::compiler-bridge:${Deps.zinc.version}").exclude("*" -> "*")
)

def compilerBridgeSourceJars: T[Agg[PathRef]] = Task {
Expand Down Expand Up @@ -761,7 +818,6 @@ object dist0 extends MillPublishJavaModule {

def testTransitiveDeps = build.runner.testTransitiveDeps() ++ Seq(
build.main.graphviz.testDep(),
build.runner.linenumbers.testDep(),
build.scalalib.backgroundwrapper.testDep(),
build.contrib.bloop.testDep(),
build.contrib.buildinfo.testDep(),
Expand All @@ -771,7 +827,8 @@ object dist0 extends MillPublishJavaModule {
build.contrib.playlib.testDep(),
build.contrib.playlib.worker("2.8").testDep(),
build.bsp.worker.testDep(),
build.testkit.testDep()
build.testkit.testDep(),
build.runner.worker.testDep(),
)
}

Expand Down Expand Up @@ -1064,6 +1121,6 @@ implicit object DepSegment extends Cross.ToSegments[Dep]({ dep =>
*/
object dummy extends Cross[DependencyFetchDummy](dummyDeps)
trait DependencyFetchDummy extends ScalaModule with Cross.Module[Dep] {
def scalaVersion = Deps.scalaVersion
def scalaVersion = Deps.scala2Version
def compileIvyDeps = Agg(crossValue)
}
Loading
Loading