Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions integration/ide/gen-idea/src/GenIdeaExtendedTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import mill.testkit.UtestIntegrationTestSuite
import utest._

import scala.util.Try
import os.Path

object GenIdeaExtendedTests extends UtestIntegrationTestSuite {
Expand All @@ -11,23 +10,21 @@
override def workspaceSourcePath: Path = super.workspaceSourcePath / "extended"

def tests: Tests = Tests {
test("genIdeaTests") - integrationTest { tester =>

Check failure on line 13 in integration/ide/gen-idea/src/GenIdeaExtendedTests.scala

View workflow job for this annotation

GitHub Actions / linux (17, 'integration.{failure,feature,ide}.__.packaged.server.test', false) / run

GenIdeaExtendedTests.genIdeaTests

assert(context != null && found == expected) context: String = libraries/SBT_ org_scalameta_munit_2_13_0_7_29_jar.xml found: String = <component name="libraryTable"> <library name="SBT: org.scalameta:munit_2.13:0.7.29:jar"> <CLASSES> <root url="jar://$USER_HOME$/COURSIER_CACHE/v1/https/repo1.maven.org/maven2/org/scalameta/munit_2.13/0.7.29/munit_2.13-0.7.29.jar!/"/> </CLASSES> </library> </component> expected: String = <component name="libraryTable"> <library name="SBT: org.scalameta:munit_2.13:0.7.29:jar"> <CLASSES> <root url="jar://$USER_HOME$/COURSIER_CACHE/v1/https/repo1.maven.org/maven2/org/scalameta/munit_2.13/0.7.29/munit_2.13-0.7.29.jar!/"/> </CLASSES> <SOURCES> <root url="jar://$USER_HOME$/COURSIER_CACHE/v1/https/repo1.maven.org/maven2/org/scalameta/munit_2.13/0.7.29/munit_2.13-0.7.29-sources.jar!/"/> </SOURCES> </library> </component>
import tester._
val expectedBase = workspacePath / "idea"
val resources = os.walk(expectedBase).filter(os.isFile).map(_.subRelativeTo(expectedBase))

eval("mill.idea.GenIdea/")

val checks = resources.map { resource =>
Try {
resources.map { resource =>
for (resource <- resources) {
GenIdeaUtils.assertIdeaXmlResourceMatchesFile(
workspacePath,
resource
)
}
}
assert(checks.forall(_.isSuccess))
}
}

}
24 changes: 9 additions & 15 deletions integration/ide/gen-idea/src/GenIdeaUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,15 @@ object GenIdeaUtils {
val expectedResourcePath = workspacePath / "idea" / resource
val actualResourcePath = workspacePath / ".idea" / resource

val check = Try {
val expectedResourceString = os.read.lines(expectedResourcePath).mkString("\n")
val actualResourceString = normaliseLibraryPaths(os.read(actualResourcePath), workspacePath)

assertPartialContentMatches(
found = actualResourceString,
expected = expectedResourceString,
resource.toString()
)
}
println(
s"Checking ${expectedResourcePath.relativeTo(workspacePath)} ... ${if (check.isSuccess) "OK"
else "FAILED"}"
println(s"Checking ${expectedResourcePath.relativeTo(workspacePath)} ...")
val expectedResourceString = os.read.lines(expectedResourcePath).mkString("\n")
val actualResourceString = normaliseLibraryPaths(os.read(actualResourcePath), workspacePath)

assertPartialContentMatches(
found = actualResourceString,
expected = expectedResourceString,
resource.toString()
)
check.get
}

def assertPartialContentMatches(found: String, expected: String, context: String = ""): Unit = {
Expand All @@ -41,7 +35,7 @@ object GenIdeaUtils {

val pattern =
"(?s)^\\Q" + expected.replaceAll(Pattern.quote(ignoreString), "\\\\E.*\\\\Q") + "\\E$"
assert(Pattern.compile(pattern).matcher(found).matches())
scala.Predef.assert(Pattern.compile(pattern).matcher(found).matches(), found)
}

private def normaliseLibraryPaths(in: String, workspacePath: os.Path): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ object CodeSigHelloTests extends UtestIntegrationTestSuite {
modifyFile(workspacePath / "build.mill", _.replace("running foo", "running foo2"))
val mangledFoo = eval("foo")

assert(mangledFoo.out.linesIterator.toSeq == Seq("running foo2", "running helperFoo"))
val out1 = mangledFoo.out.linesIterator.toSeq
assert(out1 == Seq("running foo2", "running helperFoo"))

val cached2 = eval("foo")
assert(cached2.out == "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ object CodeSigScalaModuleTests extends UtestIntegrationTestSuite {
)

// Adding newlines in various places doesn't invalidate anything
// (preserving the indentation to avoid warnings in Scala 3).
modifyFile(
workspacePath / "build.mill",
s =>
"\n\n\n" +
s.replace("def scalaVersion", "\ndef scalaVersion\n")
.replace("def sources", "\ndef sources\n")
.replace("def compile", "\ndef compile\n")
.replace("def run", "\ndef run\n")
s.replace("\n def scalaVersion", "\n\n def scalaVersion")
.replace("\n def sources = T{\n", "\n\n def sources = T{\n\n")
.replace("\n def compile = T {\n", "\n\n def compile = T {\n\n")
.replace(
"\n def run(args: Task[Args] = T.task(Args())) = T.command {\n",
"\n\n def run(args: Task[Args] = T.task(Args())) = T.command {\n\n"
)
)
val mangledFoo6 = eval("foo.run")
assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ trait ReactScriptsModule extends TypeScriptModule {
}

override def forkEnv =
Task.Anon {
Task {
Map("NODE_PATH" -> Seq(
".",
compile()._1.path,
Expand Down
2 changes: 1 addition & 1 deletion main/src/mill/main/SelectiveExecutionModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ trait SelectiveExecutionModule extends mill.define.Module {
} match {
case Left(err) => Result.Failure(err)
case Right((watched, Left(err))) => Result.Failure(err)
case Right((watched, Right(res))) => Result.Success(res)
case Right((watched, Right(res))) => Result.Success(())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion main/src/mill/main/TokenReaders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ trait TokenReaders0 {
case t: TokensReader.Leftover[_, _] => new LeftoverTaskTokenReader[T](t)
}

def given = () // dummy for scala 2/3 compat
def `given` = () // dummy for scala 2/3 compat
}
9 changes: 5 additions & 4 deletions main/util/src/mill/util/SpanningForest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ private[mill] object SpanningForest {

while (queued.nonEmpty) {
val current = queued.dequeue()
seen.add(current)
seenList.append(current)

for (next <- edges(current).iterator) {
if (!seen.contains(next)) queued.enqueue(next)
for (next <- edges(current)) {
if (!seen.contains(next)) {
seen.add(next)
queued.enqueue(next)
}
}
}
seenList.toSeq
Expand Down
4 changes: 2 additions & 2 deletions main/util/test/src/mill/util/SpanningForestTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ object SpanningForestTests extends TestSuite {
Array(1),
Array(2),
Array(3),
Array(),
Array()
Array[Int](),
Array[Int]()
),
Set(0),
limitToImportantVertices = false
Expand Down
2 changes: 1 addition & 1 deletion scalajslib/src/mill/scalajslib/worker/ScalaJSWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,6 @@ private[scalajslib] class ScalaJSWorker(jobs: Int)
private[scalajslib] object ScalaJSWorkerExternalModule extends mill.define.ExternalModule {

def scalaJSWorker: Worker[ScalaJSWorker] =
Task.Worker { new ScalaJSWorker(Task.ctx.asInstanceOf[mill.api.Ctx.Jobs].jobs) }
Task.Worker { new ScalaJSWorker(Task.ctx().asInstanceOf[mill.api.Ctx.Jobs].jobs) }
lazy val millDiscover: Discover = Discover[this.type]
}
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/CoursierModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait CoursierModule extends mill.Module {
* @return The [[BoundDep]]
*/
def bindDependency: Task[Dep => BoundDep] = Task.Anon { (dep: Dep) =>
BoundDep((resolveCoursierDependency(): @nowarn).apply(dep), dep.force)
BoundDep((resolveCoursierDependency.apply(): @nowarn).apply(dep), dep.force)
}

@deprecated("To be replaced by bindDependency", "Mill after 0.11.0-M0")
Expand Down
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/Dependency.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mill.scalalib

import mill.Task
import mill.{Task, given}
import mill.define.{Command, Discover, ExternalModule}
import mill.eval.Evaluator
import mill.scalalib.dependency.{DependencyUpdatesImpl, Format}
Expand Down
8 changes: 6 additions & 2 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scalalib

import coursier.{core => cs}
import coursier.core.{BomDependency, Configuration, DependencyManagement, Resolution}
import coursier.params.ResolutionParams
import coursier.parse.JavaOrScalaModule
import coursier.parse.ModuleParser
import coursier.util.{EitherT, ModuleMatcher, Monad}
Expand Down Expand Up @@ -942,7 +943,8 @@ trait JavaModule
BoundDep(coursierDependency, force = false)
),
artifactTypes = Some(artifactTypes()),
resolutionParamsMapOpt = Some(_.withDefaultConfiguration(coursier.core.Configuration.compile))
resolutionParamsMapOpt =
Some((_: ResolutionParams).withDefaultConfiguration(coursier.core.Configuration.compile))
)
}

Expand Down Expand Up @@ -1402,7 +1404,9 @@ trait JavaModule
),
sources = true,
resolutionParamsMapOpt =
Some(_.withDefaultConfiguration(coursier.core.Configuration.compile))
Some(
(_: ResolutionParams).withDefaultConfiguration(coursier.core.Configuration.compile)
)
)
},
Task.Anon {
Expand Down
10 changes: 5 additions & 5 deletions scalalib/src/mill/scalalib/Lib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,18 @@ object Lib {
resolutionParams: ResolutionParams = ResolutionParams()
): Result[Agg[PathRef]] = {
val depSeq = deps.iterator.toSeq
mill.util.Jvm.resolveDependencies(
val res = mill.util.Jvm.resolveDependencies(
repositories = repositories,
deps = depSeq.map(_.dep),
force = depSeq.filter(_.force).map(_.dep),
sources = sources,
artifactTypes = artifactTypes,
mapDependencies = mapDependencies,
customizer = customizer,
ctx = ctx,
coursierCacheCustomizer = coursierCacheCustomizer,
deprecatedResolveFilter = _ => true,
resolutionParams = resolutionParams
).map(_.map(_.withRevalidateOnce))
)

res.map(_.map(_.withRevalidateOnce))
}

// bin-compat shim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mill.scalalib.dependency.versions
import mill.define.{BaseModule, Task}
import mill.eval.Evaluator
import mill.scalalib.dependency.metadata.{MetadataLoader, MetadataLoaderFactory}
import mill.scalalib.{JavaModule, Lib}
import mill.scalalib.{BoundDep, JavaModule, Lib}
import mill.api.Ctx.{Home, Log}
import mill.T

Expand Down Expand Up @@ -66,14 +66,19 @@ private[dependency] object VersionsFinder {
.map(bindDependency)
.iterator
.toSeq
Lib.resolveDependenciesMetadataSafe(

val x = Lib.resolveDependenciesMetadataSafe(
repositories = repos,
deps = dependencies,
mapDependencies = Some(mapDeps),
deps = dependencies: IterableOnce[BoundDep],
mapDependencies = Option(mapDeps),
customizer = custom,
ctx = Option(T.log),
coursierCacheCustomizer = cacheCustom,
ctx = Some(T.log)
).map { _ =>
resolutionParams = coursier.params.ResolutionParams(),
boms = Nil
)

x.map { _ =>
(javaModule, metadataLoaders, dependencies.map(_.dep))
}
}
Expand Down
18 changes: 9 additions & 9 deletions scalanativelib/src/mill/scalanativelib/ScalaNativeModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,20 @@ trait ScalaNativeModule extends ScalaModule { outer =>
}
}
}
private[scalanativelib] def withScalaNativeBridge[T] = Task.Anon {
private[scalanativelib] def withScalaNativeBridge = Task.Anon {
new ScalaNativeBridge(
ScalaNativeWorkerExternalModule.scalaNativeWorker(),
bridgeFullClassPath()
)
}
// Location of the clang compiler
def nativeClang = Task {
os.Path(withScalaNativeBridge().apply(_.discoverClang()))
os.Path(withScalaNativeBridge.apply().apply(_.discoverClang()))
}

// Location of the clang++ compiler
def nativeClangPP = Task {
os.Path(withScalaNativeBridge().apply(_.discoverClangPP()))
os.Path(withScalaNativeBridge.apply().apply(_.discoverClangPP()))
}

// GC choice, either "none", "boehm", "immix" or "commix"
Expand All @@ -172,19 +172,19 @@ trait ScalaNativeModule extends ScalaModule { outer =>
}

def nativeGC = Task {
nativeGCInput().getOrElse(withScalaNativeBridge().apply(_.defaultGarbageCollector()))
nativeGCInput().getOrElse(withScalaNativeBridge.apply().apply(_.defaultGarbageCollector()))
}

def nativeTarget: T[Option[String]] = Task { None }

// Options that are passed to clang during compilation
def nativeCompileOptions = Task {
withScalaNativeBridge().apply(_.discoverCompileOptions())
withScalaNativeBridge.apply().apply(_.discoverCompileOptions())
}

// Options that are passed to clang during linking
def nativeLinkingOptions = Task {
withScalaNativeBridge().apply(_.discoverLinkingOptions())
withScalaNativeBridge.apply().apply(_.discoverLinkingOptions())
}

// Whether to link `@stub` methods, or ignore them
Expand Down Expand Up @@ -230,7 +230,7 @@ trait ScalaNativeModule extends ScalaModule { outer =>

private def nativeConfig: Task[NativeConfig] = Task.Anon {
val classpath = runClasspath().map(_.path).filter(_.toIO.exists).toList
withScalaNativeBridge().apply(_.config(
withScalaNativeBridge.apply().apply(_.config(
finalMainClassOpt(),
classpath.map(_.toIO),
nativeWorkdir().toIO,
Expand Down Expand Up @@ -274,7 +274,7 @@ trait ScalaNativeModule extends ScalaModule { outer =>

// Generates native binary
def nativeLink = Task {
os.Path(withScalaNativeBridge().apply(_.nativeLink(
os.Path(withScalaNativeBridge.apply().apply(_.nativeLink(
nativeConfig().config,
T.dest.toIO
)))
Expand Down Expand Up @@ -376,7 +376,7 @@ trait TestScalaNativeModule extends ScalaNativeModule with TestModule {
globSelectors: Task[Seq[String]]
): Task[(String, Seq[TestResult])] = Task.Anon {

val (close, framework) = withScalaNativeBridge().apply(_.getFramework(
val (close, framework) = withScalaNativeBridge.apply().apply(_.getFramework(
nativeLink().toIO,
forkEnv() ++
Map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ private[scalanativelib] class ScalaNativeWorker(jobs: Int)

private[scalanativelib] object ScalaNativeWorkerExternalModule extends mill.define.ExternalModule {
def scalaNativeWorker: Worker[ScalaNativeWorker] =
Task.Worker { new ScalaNativeWorker(Task.ctx.asInstanceOf[mill.api.Ctx.Jobs].jobs) }
Task.Worker { new ScalaNativeWorker(Task.ctx().asInstanceOf[mill.api.Ctx.Jobs].jobs) }
lazy val millDiscover: Discover = Discover[this.type]
}
Loading