Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into albert-java-home
Browse files Browse the repository at this point in the history
  • Loading branch information
albertpchen committed Oct 11, 2024
2 parents eb92634 + 7221788 commit db513dd
Show file tree
Hide file tree
Showing 27 changed files with 286 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .config/mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.0-RC3-32-b4a0bf
0.12.0-RC3-46-80d164
6 changes: 3 additions & 3 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ object Deps {
val asmTree = ivy"org.ow2.asm:asm-tree:9.7"
val bloopConfig = ivy"ch.epfl.scala::bloop-config:1.5.5"

val coursier = ivy"io.get-coursier::coursier:2.1.13"
val coursier = ivy"io.get-coursier::coursier:2.1.14"
val coursierInterface = ivy"io.get-coursier:interface:1.0.19"

val cask = ivy"com.lihaoyi::cask:0.9.4"
Expand Down Expand Up @@ -151,8 +151,8 @@ object Deps {
val log4j2Core = ivy"org.apache.logging.log4j:log4j-core:2.23.1"
val osLib = ivy"com.lihaoyi::os-lib:0.11.1"
val pprint = ivy"com.lihaoyi::pprint:0.9.0"
val mainargs = ivy"com.lihaoyi::mainargs:0.7.4"
val millModuledefsVersion = "0.11.0"
val mainargs = ivy"com.lihaoyi::mainargs:0.7.6"
val millModuledefsVersion = "0.11.1"
val millModuledefsString = s"com.lihaoyi::mill-moduledefs:${millModuledefsVersion}"
val millModuledefs = ivy"${millModuledefsString}"
val millModuledefsPlugin =
Expand Down
14 changes: 2 additions & 12 deletions contrib/proguard/src/mill/contrib/proguard/Proguard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,8 @@ trait Proguard extends ScalaModule {
* Keep in sync with [[javaHome]].
*/
def java9RtJar: T[Seq[PathRef]] = Task {
if (mill.main.client.Util.isJava9OrAbove) {
val rt = T.dest / Export.rtJarName
if (!os.exists(rt)) {
T.log.outputStream.println(
s"Preparing Java runtime JAR; this may take a minute or two ..."
)
Export.rtTo(rt.toIO, false)
}
Seq(PathRef(rt))
} else {
Seq()
}
if (mill.main.client.Util.isJava9OrAbove) Seq(PathRef(T.home / Export.rtJarName))
else Seq()
}

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

Expand All @@ -14,6 +14,9 @@ object foo extends KotlinJSModule {
def moduleKind = ModuleKind.ESModule
def kotlinVersion = "1.9.25"
def kotlinJSRunTarget = Some(RunTarget.Node)
def ivyDeps = Agg(
ivy"org.jetbrains.kotlinx:kotlinx-html-js:0.11.0",
)
object test extends KotlinJSModule with KotlinJSKotlinXTests
}

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

> mill foo.run
Compiling 1 Kotlin sources to .../out/foo/compile.dest/classes...
Hello, world
<h1>Hello World</h1>
stringifiedJsObject: ["hello","world","!"]

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

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

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

> mill foo.test # passes after fixing test

Expand Down
9 changes: 7 additions & 2 deletions example/kotlinlib/web/3-hello-kotlinjs/foo/src/foo/Hello.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package foo

fun getString() = "Hello, world"
import kotlinx.html.*
import kotlinx.html.stream.createHTML

fun main() {
println(getString())
println(hello())

val parsedJsonStr: dynamic = JSON.parse("""{"helloworld": ["hello", "world", "!"]}""")
val stringifiedJsObject = JSON.stringify(parsedJsonStr.helloworld)
println("stringifiedJsObject: " + stringifiedJsObject)
}

fun hello(): String {
return createHTML().h1 { +"Hello World" }.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import kotlin.test.assertEquals
class HelloTests {

@Test
fun failure() {
assertEquals(getString(), "Not hello, world")
fun testHello() {
val result = hello()
assertEquals(result.trim(), "<h1>Hello World Wrong</h1>")
result
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object DocAnnotationsTests extends UtestIntegrationTestSuite {

assert(
globMatches(
"""core.ivyDepsTree(JavaModule.scala:884)
"""core.ivyDepsTree(JavaModule.scala:896)
| Command to print the transitive dependency tree to STDOUT.
|
| --inverse Invert the tree representation, so that the root is on the bottom val
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object OutputDirectoryLockTests extends UtestIntegrationTestSuite {
override def utestAfterAll(): Unit = {
pool.shutdown()
}
implicit val retryMax: RetryMax = RetryMax(30000.millis)
implicit val retryMax: RetryMax = RetryMax(60000.millis)
implicit val retryInterval: RetryInterval = RetryInterval(50.millis)
def tests: Tests = Tests {
test("basic") - integrationTest { tester =>
Expand Down
36 changes: 18 additions & 18 deletions kotlinlib/src/mill/kotlinlib/js/KotlinJSModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -453,60 +453,60 @@ trait KotlinJSModule extends KotlinModule { outer =>
sealed trait ModuleKind { def extension: String }

object ModuleKind {
object NoModule extends ModuleKind { val extension = "js" }
case object NoModule extends ModuleKind { val extension = "js" }
implicit val rwNoModule: RW[NoModule.type] = macroRW
object UMDModule extends ModuleKind { val extension = "js" }
case object UMDModule extends ModuleKind { val extension = "js" }
implicit val rwUMDModule: RW[UMDModule.type] = macroRW
object CommonJSModule extends ModuleKind { val extension = "js" }
case object CommonJSModule extends ModuleKind { val extension = "js" }
implicit val rwCommonJSModule: RW[CommonJSModule.type] = macroRW
object AMDModule extends ModuleKind { val extension = "js" }
case object AMDModule extends ModuleKind { val extension = "js" }
implicit val rwAMDModule: RW[AMDModule.type] = macroRW
object ESModule extends ModuleKind { val extension = "mjs" }
case object ESModule extends ModuleKind { val extension = "mjs" }
implicit val rwESModule: RW[ESModule.type] = macroRW
object PlainModule extends ModuleKind { val extension = "js" }
case object PlainModule extends ModuleKind { val extension = "js" }
implicit val rwPlainModule: RW[PlainModule.type] = macroRW
}

sealed trait SourceMapEmbedSourcesKind
object SourceMapEmbedSourcesKind {
object Always extends SourceMapEmbedSourcesKind
case object Always extends SourceMapEmbedSourcesKind
implicit val rwAlways: RW[Always.type] = macroRW
object Never extends SourceMapEmbedSourcesKind
case object Never extends SourceMapEmbedSourcesKind
implicit val rwNever: RW[Never.type] = macroRW
object Inlining extends SourceMapEmbedSourcesKind
case object Inlining extends SourceMapEmbedSourcesKind
implicit val rwInlining: RW[Inlining.type] = macroRW
}

sealed trait SourceMapNamesPolicy
object SourceMapNamesPolicy {
object SimpleNames extends SourceMapNamesPolicy
case object SimpleNames extends SourceMapNamesPolicy
implicit val rwSimpleNames: RW[SimpleNames.type] = macroRW
object FullyQualifiedNames extends SourceMapNamesPolicy
case object FullyQualifiedNames extends SourceMapNamesPolicy
implicit val rwFullyQualifiedNames: RW[FullyQualifiedNames.type] = macroRW
object No extends SourceMapNamesPolicy
case object No extends SourceMapNamesPolicy
implicit val rwNo: RW[No.type] = macroRW
}

sealed trait BinaryKind
object BinaryKind {
object Library extends BinaryKind
case object Library extends BinaryKind
implicit val rwLibrary: RW[Library.type] = macroRW
object Executable extends BinaryKind
case object Executable extends BinaryKind
implicit val rwExecutable: RW[Executable.type] = macroRW
implicit val rw: RW[BinaryKind] = macroRW
}

sealed trait RunTarget
object RunTarget {
// TODO rely on the node version installed in the env or fetch a specific one?
object Node extends RunTarget
case object Node extends RunTarget
implicit val rwNode: RW[Node.type] = macroRW
implicit val rw: RW[RunTarget] = macroRW
}

private[kotlinlib] sealed trait OutputMode
private[kotlinlib] object OutputMode {
object Js extends OutputMode
object KlibDir extends OutputMode
object KlibFile extends OutputMode
case object Js extends OutputMode
case object KlibDir extends OutputMode
case object KlibFile extends OutputMode
}
2 changes: 1 addition & 1 deletion main/api/src/mill/api/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ trait Logger extends AutoCloseable {
): Unit =
ticker(s"${key.mkString("-")} $message")
private[mill] def setPromptLine(): Unit = ()
private[mill] def setPromptLeftHeader(s: String): Unit = ()
private[mill] def setPromptHeaderPrefix(s: String): Unit = ()
private[mill] def clearPromptStatuses(): Unit = ()
private[mill] def removePromptLine(key: Seq[String]): Unit = ()
private[mill] def removePromptLine(): Unit = ()
Expand Down
11 changes: 10 additions & 1 deletion main/define/src/mill/define/Discover.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,20 @@ object Discover {
}
if overridesRoutes._1.nonEmpty || overridesRoutes._2.nonEmpty || overridesRoutes._3.nonEmpty
} yield {
val lhs0 = discoveredModuleType match {
// Explicitly do not de-alias type refs, so type aliases to deprecated
// types do not result in spurious deprecation warnings appearing
case tr: TypeRef => tr
// Other types are fine
case _ => discoveredModuleType.typeSymbol.asClass.toType
}

val lhs = q"classOf[$lhs0]"

// by wrapping the `overridesRoutes` in a lambda function we kind of work around
// the problem of generating a *huge* macro method body that finally exceeds the
// JVM's maximum allowed method size
val overridesLambda = q"(() => $overridesRoutes)()"
val lhs = q"classOf[${discoveredModuleType.typeSymbol.asClass}]"
q"$lhs -> $overridesLambda"
}

Expand Down
2 changes: 1 addition & 1 deletion main/eval/src/mill/eval/EvaluatorCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private[mill] trait EvaluatorCore extends GroupEvaluator {
)

val verboseKeySuffix = s"/${terminals0.size}"
logger.setPromptLeftHeader(s"$countMsg$verboseKeySuffix")
logger.setPromptHeaderPrefix(s"$countMsg$verboseKeySuffix")
if (failed.get()) None
else {
val upstreamResults = upstreamValues
Expand Down
32 changes: 29 additions & 3 deletions main/util/src/mill/util/CoursierSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import coursier.error.ResolutionError.CantDownloadModule
import coursier.params.ResolutionParams
import coursier.parse.RepositoryParser
import coursier.util.{Artifact, Task}
import coursier.{Artifacts, Classifier, Dependency, Repository, Resolution, Resolve}
import coursier.{Artifacts, Classifier, Dependency, Repository, Resolution, Resolve, Type}
import mill.api.Loose.Agg
import mill.api.{Ctx, PathRef, Result}

Expand Down Expand Up @@ -46,7 +46,8 @@ trait CoursierSupport {
customizer: Option[Resolution => Resolution] = None,
ctx: Option[mill.api.Ctx.Log] = None,
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
resolveFilter: os.Path => Boolean = _ => true
resolveFilter: os.Path => Boolean = _ => true,
artifactTypes: Option[Set[Type]] = None
): Result[Agg[PathRef]] = {
def isLocalTestDep(dep: Dependency): Option[Seq[PathRef]] = {
val org = dep.module.organization.value
Expand Down Expand Up @@ -88,6 +89,7 @@ trait CoursierSupport {
if (sources) Set(Classifier("sources"))
else Set.empty
)
.withArtifactTypesOpt(artifactTypes)
.eitherResult()

artifactsResultOrError match {
Expand All @@ -106,14 +108,38 @@ trait CoursierSupport {
Agg.from(
res.files
.map(os.Path(_))
.filter(path => path.ext == "jar" && resolveFilter(path))
.filter(resolveFilter)
.map(PathRef(_, quick = true))
) ++ localTestDeps.flatten
)
}
}
}

@deprecated("Use the override accepting artifactTypes", "Mill after 0.12.0-RC3")
def resolveDependencies(
repositories: Seq[Repository],
deps: IterableOnce[Dependency],
force: IterableOnce[Dependency],
sources: Boolean,
mapDependencies: Option[Dependency => Dependency],
customizer: Option[Resolution => Resolution],
ctx: Option[mill.api.Ctx.Log],
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]],
resolveFilter: os.Path => Boolean
): Result[Agg[PathRef]] =
resolveDependencies(
repositories,
deps,
force,
sources,
mapDependencies,
customizer,
ctx,
coursierCacheCustomizer,
resolveFilter
)

@deprecated(
"Prefer resolveDependenciesMetadataSafe instead, which returns a Result instead of throwing exceptions",
"0.12.0"
Expand Down
6 changes: 3 additions & 3 deletions main/util/src/mill/util/MultiLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class MultiLogger(
logger1.removePromptLine()
logger2.removePromptLine()
}
private[mill] override def setPromptLeftHeader(s: String): Unit = {
logger1.setPromptLeftHeader(s)
logger2.setPromptLeftHeader(s)
private[mill] override def setPromptHeaderPrefix(s: String): Unit = {
logger1.setPromptHeaderPrefix(s)
logger2.setPromptHeaderPrefix(s)
}

private[mill] override def withPromptPaused[T](t: => T): T = {
Expand Down
3 changes: 2 additions & 1 deletion main/util/src/mill/util/PrefixLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class PrefixLogger(
private[mill] override def removePromptLine(callKey: Seq[String]): Unit =
logger0.removePromptLine(callKey)
private[mill] override def removePromptLine(): Unit = removePromptLine(logPrefixKey)
private[mill] override def setPromptLeftHeader(s: String): Unit = logger0.setPromptLeftHeader(s)
private[mill] override def setPromptHeaderPrefix(s: String): Unit =
logger0.setPromptHeaderPrefix(s)
override def enableTicker = logger0.enableTicker

private[mill] override def subLogger(
Expand Down
Loading

0 comments on commit db513dd

Please sign in to comment.