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 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 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
4bfeb89
first pass resolving conflicts
lihaoyi Nov 26, 2024
36964b8
wip
lihaoyi Nov 26, 2024
fcfec9f
__.compile passes
lihaoyi Nov 26, 2024
f1ecfc3
test fixes
lihaoyi Nov 26, 2024
a98e4ba
downgrade os-lib for now
lihaoyi Nov 26, 2024
b9e6aa8
fixe
lihaoyi Nov 26, 2024
b6fbb75
.
lihaoyi Nov 26, 2024
4b5ef73
.
lihaoyi Nov 26, 2024
c4205b9
bump to java 11 in CI
lihaoyi Nov 26, 2024
9378f18
.
lihaoyi Nov 26, 2024
afe359a
.
lihaoyi Nov 27, 2024
5f3b8e4
enable testForkGrouping in integration tests
lihaoyi Nov 27, 2024
e4e1241
.
lihaoyi Nov 27, 2024
ad14453
hack around dotty scaladoc not working
lihaoyi Nov 27, 2024
2b70bb1
autofix
lihaoyi Nov 27, 2024
21f3fc8
.
lihaoyi Nov 27, 2024
0aa74aa
fix-external-module-alias
lihaoyi Nov 27, 2024
2e36503
update-bootstrap-patch
lihaoyi Nov 27, 2024
9d036c4
fix-mill-bootstrap-patch
lihaoyi Nov 27, 2024
587cd05
fix-mill-bootstrap-patch
lihaoyi Nov 27, 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
]
4 changes: 2 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ newlines.source = keep

project.git = true

runner.dialect = scala213
runner.dialect = scala3

project {
excludePaths = [
Expand All @@ -36,4 +36,4 @@ fileOverride {
docstrings.style = keep
}
"glob:**/example/scalalib/native/**/*.scala" = 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
149 changes: 103 additions & 46 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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.15"
val scalaVersion = "3.5.2"
val scala2Version = "2.13.15"
// The Scala 2.12.x version to use for some workers
val workerScalaVersion212 = "2.12.19"
Expand All @@ -64,14 +64,14 @@ object Deps {

object Scalajs_1 {
val scalaJsVersion = "1.17.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:${scalaJsVersion}".withDottyCompat(scalaVersion)
val scalajsLinker = ivy"org.scala-js::scalajs-linker:${scalaJsVersion}".withDottyCompat(scalaVersion)
val scalajsImportMap = ivy"com.armanbilge::scalajs-importmap:0.1.1".withDottyCompat(scalaVersion)
}

object Scalanative_0_5 {
Expand All @@ -98,9 +98,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 @@ -114,12 +116,12 @@ object Deps {
val acyclic = ivy"com.lihaoyi:::acyclic:0.3.15"
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 coursierVersion = "2.1.18"
val coursier = ivy"io.get-coursier::coursier:$coursierVersion"
val coursier = ivy"io.get-coursier::coursier:$coursierVersion".withDottyCompat(scalaVersion)
val coursierInterface = ivy"io.get-coursier:interface:1.0.24"
val coursierJvm = ivy"io.get-coursier::coursier-jvm:$coursierVersion"
val coursierJvm = ivy"io.get-coursier::coursier-jvm:$coursierVersion".withDottyCompat(scalaVersion)

val cask = ivy"com.lihaoyi::cask:0.9.4"
val castor = ivy"com.lihaoyi::castor:0.3.0"
Expand All @@ -146,40 +148,45 @@ object Deps {
val junitInterface = ivy"com.github.sbt:junit-interface:0.13.3"
val commonsIo = ivy"commons-io:commons-io:2.17.0"
val log4j2Core = ivy"org.apache.logging.log4j:log4j-core:2.24.1"
val osLib = ivy"com.lihaoyi::os-lib:0.11.4-M2"
val osLib = ivy"com.lihaoyi::os-lib:0.11.3"
val pprint = ivy"com.lihaoyi::pprint:0.9.0"
val mainargs = ivy"com.lihaoyi::mainargs:0.7.6"
val millModuledefsVersion = "0.11.1"
val millModuledefsVersion = "0.11.3-M1"
val millModuledefsString = s"com.lihaoyi::mill-moduledefs:${millModuledefsVersion}"
val millModuledefs = ivy"${millModuledefsString}"
val millModuledefsPlugin =
ivy"com.lihaoyi:::scalac-mill-moduledefs-plugin:${millModuledefsVersion}"
// 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.2.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.11.0"
val semanticDbJava = ivy"com.sourcegraph:semanticdb-java:0.10.3"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.4.2"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.4.3-M5"
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.4"
val zinc = ivy"org.scala-sbt::zinc:1.10.4".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.11"
val sonatypeCentralClient = ivy"com.lumidion::sonatype-central-client-requests:0.3.0"
Expand Down Expand Up @@ -277,7 +284,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 @@ -415,30 +422,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 @@ -454,7 +491,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 All @@ -473,6 +511,7 @@ trait MillBaseTestsModule extends TestModule {
}

def testFramework = "mill.UTestFramework"
def testForkGrouping = discoveredTestClasses().grouped(1).toSeq
}

/** Published module which does not contain strictly handled API. */
Expand Down Expand Up @@ -584,15 +623,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 @@ -605,7 +660,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 @@ -614,7 +671,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 @@ -646,7 +704,6 @@ object idea extends MillPublishScalaModule {
def moduleDeps = Seq(build.scalalib, build.runner)
}


private def resolveTasks[T](taskNames: String*): Seq[NamedTask[T]] = {
mill.resolve.Resolve.Tasks.resolve(
build,
Expand Down Expand Up @@ -689,6 +746,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