Skip to content

Commit db513dd

Browse files
committed
Merge remote-tracking branch 'origin/main' into albert-java-home
2 parents eb92634 + 7221788 commit db513dd

File tree

27 files changed

+286
-157
lines changed

27 files changed

+286
-157
lines changed

.config/mill-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0-RC3-32-b4a0bf
1+
0.12.0-RC3-46-80d164

build.mill

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ object Deps {
120120
val asmTree = ivy"org.ow2.asm:asm-tree:9.7"
121121
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5"
122122

123-
val coursier = ivy"io.get-coursier::coursier:2.1.13"
123+
val coursier = ivy"io.get-coursier::coursier:2.1.14"
124124
val coursierInterface = ivy"io.get-coursier:interface:1.0.19"
125125

126126
val cask = ivy"com.lihaoyi::cask:0.9.4"
@@ -151,8 +151,8 @@ object Deps {
151151
val log4j2Core = ivy"org.apache.logging.log4j:log4j-core:2.23.1"
152152
val osLib = ivy"com.lihaoyi::os-lib:0.11.1"
153153
val pprint = ivy"com.lihaoyi::pprint:0.9.0"
154-
val mainargs = ivy"com.lihaoyi::mainargs:0.7.4"
155-
val millModuledefsVersion = "0.11.0"
154+
val mainargs = ivy"com.lihaoyi::mainargs:0.7.6"
155+
val millModuledefsVersion = "0.11.1"
156156
val millModuledefsString = s"com.lihaoyi::mill-moduledefs:${millModuledefsVersion}"
157157
val millModuledefs = ivy"${millModuledefsString}"
158158
val millModuledefsPlugin =

contrib/proguard/src/mill/contrib/proguard/Proguard.scala

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,8 @@ trait Proguard extends ScalaModule {
6565
* Keep in sync with [[javaHome]].
6666
*/
6767
def java9RtJar: T[Seq[PathRef]] = Task {
68-
if (mill.main.client.Util.isJava9OrAbove) {
69-
val rt = T.dest / Export.rtJarName
70-
if (!os.exists(rt)) {
71-
T.log.outputStream.println(
72-
s"Preparing Java runtime JAR; this may take a minute or two ..."
73-
)
74-
Export.rtTo(rt.toIO, false)
75-
}
76-
Seq(PathRef(rt))
77-
} else {
78-
Seq()
79-
}
68+
if (mill.main.client.Util.isJava9OrAbove) Seq(PathRef(T.home / Export.rtJarName))
69+
else Seq()
8070
}
8171

8272
/**

example/kotlinlib/web/3-hello-kotlinjs/build.mill

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// KotlinJS support on Mill is still Work In Progress (WIP). As of time of writing it
2-
// does not support third-party dependencies, Kotlin 2.x with KMP KLIB files, Node.js/Webpack
3-
// test runners and reporting, etc.
2+
// Node.js/Webpack test runners and reporting, etc.
43
//
5-
// The example below demonstrates only the minimal compilation, running, and testing of a single KotlinJS
6-
// module. For more details in fully developing KotlinJS support, see the following ticket:
4+
// The example below demonstrates only the minimal compilation, running, and testing of
5+
// a single KotlinJS module using a single third-party dependency. For more details in
6+
// fully developing KotlinJS support, see the following ticket:
77
//
88
// * https://github.com/com-lihaoyi/mill/issues/3611
99

@@ -14,6 +14,9 @@ object foo extends KotlinJSModule {
1414
def moduleKind = ModuleKind.ESModule
1515
def kotlinVersion = "1.9.25"
1616
def kotlinJSRunTarget = Some(RunTarget.Node)
17+
def ivyDeps = Agg(
18+
ivy"org.jetbrains.kotlinx:kotlinx-html-js:0.11.0",
19+
)
1720
object test extends KotlinJSModule with KotlinJSKotlinXTests
1821
}
1922

@@ -22,21 +25,21 @@ object foo extends KotlinJSModule {
2225

2326
> mill foo.run
2427
Compiling 1 Kotlin sources to .../out/foo/compile.dest/classes...
25-
Hello, world
28+
<h1>Hello World</h1>
2629
stringifiedJsObject: ["hello","world","!"]
2730

2831
> mill foo.test # Test is incorrect, `foo.test`` fails
2932
Compiling 1 Kotlin sources to .../out/foo/test/compile.dest/classes...
3033
Linking IR to .../out/foo/test/linkBinary.dest/binaries
3134
produce executable: .../out/foo/test/linkBinary.dest/binaries
3235
...
33-
error: AssertionError: Expected <Hello, world>, actual <Not hello, world>.
36+
error: AssertionError: Expected <<h1>Hello World</h1>>, actual <<h1>Hello World Wrong</h1>>.
3437

3538
> cat out/foo/test/linkBinary.dest/binaries/test.js # Generated javascript on disk
36-
...assertEquals_0(getString(), 'Not hello, world');...
39+
...assertEquals_0(..., '<h1>Hello World Wrong<\/h1>');...
3740
...
3841

39-
> sed -i.bak 's/Not hello, world/Hello, world/g' foo/test/src/foo/HelloTests.kt
42+
> sed -i.bak 's/Hello World Wrong/Hello World/g' foo/test/src/foo/HelloTests.kt
4043

4144
> mill foo.test # passes after fixing test
4245

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package foo
22

3-
fun getString() = "Hello, world"
3+
import kotlinx.html.*
4+
import kotlinx.html.stream.createHTML
45

56
fun main() {
6-
println(getString())
7+
println(hello())
78

89
val parsedJsonStr: dynamic = JSON.parse("""{"helloworld": ["hello", "world", "!"]}""")
910
val stringifiedJsObject = JSON.stringify(parsedJsonStr.helloworld)
1011
println("stringifiedJsObject: " + stringifiedJsObject)
1112
}
13+
14+
fun hello(): String {
15+
return createHTML().h1 { +"Hello World" }.toString()
16+
}

example/kotlinlib/web/3-hello-kotlinjs/foo/test/src/foo/HelloTests.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import kotlin.test.assertEquals
66
class HelloTests {
77

88
@Test
9-
fun failure() {
10-
assertEquals(getString(), "Not hello, world")
9+
fun testHello() {
10+
val result = hello()
11+
assertEquals(result.trim(), "<h1>Hello World Wrong</h1>")
12+
result
1113
}
1214
}
1315

integration/feature/docannotations/src/DocAnnotationsTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ object DocAnnotationsTests extends UtestIntegrationTestSuite {
9393

9494
assert(
9595
globMatches(
96-
"""core.ivyDepsTree(JavaModule.scala:884)
96+
"""core.ivyDepsTree(JavaModule.scala:896)
9797
| Command to print the transitive dependency tree to STDOUT.
9898
|
9999
| --inverse Invert the tree representation, so that the root is on the bottom val

integration/feature/output-directory/src/OutputDirectoryLockTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object OutputDirectoryLockTests extends UtestIntegrationTestSuite {
1616
override def utestAfterAll(): Unit = {
1717
pool.shutdown()
1818
}
19-
implicit val retryMax: RetryMax = RetryMax(30000.millis)
19+
implicit val retryMax: RetryMax = RetryMax(60000.millis)
2020
implicit val retryInterval: RetryInterval = RetryInterval(50.millis)
2121
def tests: Tests = Tests {
2222
test("basic") - integrationTest { tester =>

kotlinlib/src/mill/kotlinlib/js/KotlinJSModule.scala

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -453,60 +453,60 @@ trait KotlinJSModule extends KotlinModule { outer =>
453453
sealed trait ModuleKind { def extension: String }
454454

455455
object ModuleKind {
456-
object NoModule extends ModuleKind { val extension = "js" }
456+
case object NoModule extends ModuleKind { val extension = "js" }
457457
implicit val rwNoModule: RW[NoModule.type] = macroRW
458-
object UMDModule extends ModuleKind { val extension = "js" }
458+
case object UMDModule extends ModuleKind { val extension = "js" }
459459
implicit val rwUMDModule: RW[UMDModule.type] = macroRW
460-
object CommonJSModule extends ModuleKind { val extension = "js" }
460+
case object CommonJSModule extends ModuleKind { val extension = "js" }
461461
implicit val rwCommonJSModule: RW[CommonJSModule.type] = macroRW
462-
object AMDModule extends ModuleKind { val extension = "js" }
462+
case object AMDModule extends ModuleKind { val extension = "js" }
463463
implicit val rwAMDModule: RW[AMDModule.type] = macroRW
464-
object ESModule extends ModuleKind { val extension = "mjs" }
464+
case object ESModule extends ModuleKind { val extension = "mjs" }
465465
implicit val rwESModule: RW[ESModule.type] = macroRW
466-
object PlainModule extends ModuleKind { val extension = "js" }
466+
case object PlainModule extends ModuleKind { val extension = "js" }
467467
implicit val rwPlainModule: RW[PlainModule.type] = macroRW
468468
}
469469

470470
sealed trait SourceMapEmbedSourcesKind
471471
object SourceMapEmbedSourcesKind {
472-
object Always extends SourceMapEmbedSourcesKind
472+
case object Always extends SourceMapEmbedSourcesKind
473473
implicit val rwAlways: RW[Always.type] = macroRW
474-
object Never extends SourceMapEmbedSourcesKind
474+
case object Never extends SourceMapEmbedSourcesKind
475475
implicit val rwNever: RW[Never.type] = macroRW
476-
object Inlining extends SourceMapEmbedSourcesKind
476+
case object Inlining extends SourceMapEmbedSourcesKind
477477
implicit val rwInlining: RW[Inlining.type] = macroRW
478478
}
479479

480480
sealed trait SourceMapNamesPolicy
481481
object SourceMapNamesPolicy {
482-
object SimpleNames extends SourceMapNamesPolicy
482+
case object SimpleNames extends SourceMapNamesPolicy
483483
implicit val rwSimpleNames: RW[SimpleNames.type] = macroRW
484-
object FullyQualifiedNames extends SourceMapNamesPolicy
484+
case object FullyQualifiedNames extends SourceMapNamesPolicy
485485
implicit val rwFullyQualifiedNames: RW[FullyQualifiedNames.type] = macroRW
486-
object No extends SourceMapNamesPolicy
486+
case object No extends SourceMapNamesPolicy
487487
implicit val rwNo: RW[No.type] = macroRW
488488
}
489489

490490
sealed trait BinaryKind
491491
object BinaryKind {
492-
object Library extends BinaryKind
492+
case object Library extends BinaryKind
493493
implicit val rwLibrary: RW[Library.type] = macroRW
494-
object Executable extends BinaryKind
494+
case object Executable extends BinaryKind
495495
implicit val rwExecutable: RW[Executable.type] = macroRW
496496
implicit val rw: RW[BinaryKind] = macroRW
497497
}
498498

499499
sealed trait RunTarget
500500
object RunTarget {
501501
// TODO rely on the node version installed in the env or fetch a specific one?
502-
object Node extends RunTarget
502+
case object Node extends RunTarget
503503
implicit val rwNode: RW[Node.type] = macroRW
504504
implicit val rw: RW[RunTarget] = macroRW
505505
}
506506

507507
private[kotlinlib] sealed trait OutputMode
508508
private[kotlinlib] object OutputMode {
509-
object Js extends OutputMode
510-
object KlibDir extends OutputMode
511-
object KlibFile extends OutputMode
509+
case object Js extends OutputMode
510+
case object KlibDir extends OutputMode
511+
case object KlibFile extends OutputMode
512512
}

main/api/src/mill/api/Logger.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ trait Logger extends AutoCloseable {
5858
): Unit =
5959
ticker(s"${key.mkString("-")} $message")
6060
private[mill] def setPromptLine(): Unit = ()
61-
private[mill] def setPromptLeftHeader(s: String): Unit = ()
61+
private[mill] def setPromptHeaderPrefix(s: String): Unit = ()
6262
private[mill] def clearPromptStatuses(): Unit = ()
6363
private[mill] def removePromptLine(key: Seq[String]): Unit = ()
6464
private[mill] def removePromptLine(): Unit = ()

main/define/src/mill/define/Discover.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,20 @@ object Discover {
141141
}
142142
if overridesRoutes._1.nonEmpty || overridesRoutes._2.nonEmpty || overridesRoutes._3.nonEmpty
143143
} yield {
144+
val lhs0 = discoveredModuleType match {
145+
// Explicitly do not de-alias type refs, so type aliases to deprecated
146+
// types do not result in spurious deprecation warnings appearing
147+
case tr: TypeRef => tr
148+
// Other types are fine
149+
case _ => discoveredModuleType.typeSymbol.asClass.toType
150+
}
151+
152+
val lhs = q"classOf[$lhs0]"
153+
144154
// by wrapping the `overridesRoutes` in a lambda function we kind of work around
145155
// the problem of generating a *huge* macro method body that finally exceeds the
146156
// JVM's maximum allowed method size
147157
val overridesLambda = q"(() => $overridesRoutes)()"
148-
val lhs = q"classOf[${discoveredModuleType.typeSymbol.asClass}]"
149158
q"$lhs -> $overridesLambda"
150159
}
151160

main/eval/src/mill/eval/EvaluatorCore.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private[mill] trait EvaluatorCore extends GroupEvaluator {
111111
)
112112

113113
val verboseKeySuffix = s"/${terminals0.size}"
114-
logger.setPromptLeftHeader(s"$countMsg$verboseKeySuffix")
114+
logger.setPromptHeaderPrefix(s"$countMsg$verboseKeySuffix")
115115
if (failed.get()) None
116116
else {
117117
val upstreamResults = upstreamValues

main/util/src/mill/util/CoursierSupport.scala

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import coursier.error.ResolutionError.CantDownloadModule
66
import coursier.params.ResolutionParams
77
import coursier.parse.RepositoryParser
88
import coursier.util.{Artifact, Task}
9-
import coursier.{Artifacts, Classifier, Dependency, Repository, Resolution, Resolve}
9+
import coursier.{Artifacts, Classifier, Dependency, Repository, Resolution, Resolve, Type}
1010
import mill.api.Loose.Agg
1111
import mill.api.{Ctx, PathRef, Result}
1212

@@ -46,7 +46,8 @@ trait CoursierSupport {
4646
customizer: Option[Resolution => Resolution] = None,
4747
ctx: Option[mill.api.Ctx.Log] = None,
4848
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
49-
resolveFilter: os.Path => Boolean = _ => true
49+
resolveFilter: os.Path => Boolean = _ => true,
50+
artifactTypes: Option[Set[Type]] = None
5051
): Result[Agg[PathRef]] = {
5152
def isLocalTestDep(dep: Dependency): Option[Seq[PathRef]] = {
5253
val org = dep.module.organization.value
@@ -88,6 +89,7 @@ trait CoursierSupport {
8889
if (sources) Set(Classifier("sources"))
8990
else Set.empty
9091
)
92+
.withArtifactTypesOpt(artifactTypes)
9193
.eitherResult()
9294

9395
artifactsResultOrError match {
@@ -106,14 +108,38 @@ trait CoursierSupport {
106108
Agg.from(
107109
res.files
108110
.map(os.Path(_))
109-
.filter(path => path.ext == "jar" && resolveFilter(path))
111+
.filter(resolveFilter)
110112
.map(PathRef(_, quick = true))
111113
) ++ localTestDeps.flatten
112114
)
113115
}
114116
}
115117
}
116118

119+
@deprecated("Use the override accepting artifactTypes", "Mill after 0.12.0-RC3")
120+
def resolveDependencies(
121+
repositories: Seq[Repository],
122+
deps: IterableOnce[Dependency],
123+
force: IterableOnce[Dependency],
124+
sources: Boolean,
125+
mapDependencies: Option[Dependency => Dependency],
126+
customizer: Option[Resolution => Resolution],
127+
ctx: Option[mill.api.Ctx.Log],
128+
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]],
129+
resolveFilter: os.Path => Boolean
130+
): Result[Agg[PathRef]] =
131+
resolveDependencies(
132+
repositories,
133+
deps,
134+
force,
135+
sources,
136+
mapDependencies,
137+
customizer,
138+
ctx,
139+
coursierCacheCustomizer,
140+
resolveFilter
141+
)
142+
117143
@deprecated(
118144
"Prefer resolveDependenciesMetadataSafe instead, which returns a Result instead of throwing exceptions",
119145
"0.12.0"

main/util/src/mill/util/MultiLogger.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class MultiLogger(
8181
logger1.removePromptLine()
8282
logger2.removePromptLine()
8383
}
84-
private[mill] override def setPromptLeftHeader(s: String): Unit = {
85-
logger1.setPromptLeftHeader(s)
86-
logger2.setPromptLeftHeader(s)
84+
private[mill] override def setPromptHeaderPrefix(s: String): Unit = {
85+
logger1.setPromptHeaderPrefix(s)
86+
logger2.setPromptHeaderPrefix(s)
8787
}
8888

8989
private[mill] override def withPromptPaused[T](t: => T): T = {

main/util/src/mill/util/PrefixLogger.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class PrefixLogger(
107107
private[mill] override def removePromptLine(callKey: Seq[String]): Unit =
108108
logger0.removePromptLine(callKey)
109109
private[mill] override def removePromptLine(): Unit = removePromptLine(logPrefixKey)
110-
private[mill] override def setPromptLeftHeader(s: String): Unit = logger0.setPromptLeftHeader(s)
110+
private[mill] override def setPromptHeaderPrefix(s: String): Unit =
111+
logger0.setPromptHeaderPrefix(s)
111112
override def enableTicker = logger0.enableTicker
112113

113114
private[mill] override def subLogger(

0 commit comments

Comments
 (0)