Skip to content
Merged
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
6 changes: 3 additions & 3 deletions contrib/jmh/src/mill/contrib/jmh/JmhModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ trait JmhModule extends JavaModule {
Jvm.callProcess(
mainClass = "org.openjdk.jmh.Main",
classPath = (runClasspath() ++ generatorDeps()).map(_.path) ++
Seq(compileGeneratedSources().path, resources),
Seq(compileGeneratedSources().path, resources.path),
mainArgs = args,
cwd = Task.ctx().dest,
javaHome = jvmWorker().javaHome().map(_.path),
Expand All @@ -58,7 +58,7 @@ trait JmhModule extends JavaModule {
Task {
val dest = Task.ctx().dest
val (sourcesDir, _) = generateBenchmarkSources()
val sources = os.walk(sourcesDir).filter(os.isFile)
val sources = os.walk(sourcesDir.path).filter(os.isFile)

os.proc(
Jvm.jdkTool("javac"),
Expand Down Expand Up @@ -101,7 +101,7 @@ trait JmhModule extends JavaModule {
stdout = os.Inherit
)

(sourcesDir, resourcesDir)
(PathRef(sourcesDir), PathRef(resourcesDir))
}

def generatorDeps = Task {
Expand Down
1 change: 0 additions & 1 deletion core/constants/src/mill/constants/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public static String interpolateEnvVars(
matcher.appendReplacement(result, "\\$");
} else {
String envVarValue;
mill.constants.DebugLog.println("MATCH " + match);
envVarValue = env.containsKey(match) ? env.get(match) : onMissing.apply(match);
matcher.appendReplacement(result, envVarValue);
}
Expand Down
8 changes: 7 additions & 1 deletion core/define/src/mill/define/internal/ResolveChecker.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package mill.define.internal

class ResolveChecker(workspace: os.Path) extends os.Checker {
def onRead(path: os.ReadablePath): Unit = ()
def onRead(path: os.ReadablePath): Unit = {
path match {
case path: os.Path =>
sys.error(s"Reading from ${path.relativeTo(workspace)} not allowed during resolution phase")
case _ =>
}
}

def onWrite(path: os.Path): Unit = {
sys.error(s"Writing to ${path.relativeTo(workspace)} not allowed during resolution phase")
Expand Down
9 changes: 5 additions & 4 deletions core/util/src/mill/util/Jvm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,11 @@ object Jvm {
artifactTypes,
resolutionParams
).map { res =>
res.files
.map(os.Path(_))
.map(PathRef(_, quick = true))
os.checker.withValue(os.Checker.Nop) {
res.files
.map(os.Path(_))
.map(PathRef(_, quick = true))
}
}

def jvmIndex(
Expand Down Expand Up @@ -682,7 +684,6 @@ object Jvm {
case cp =>
cp.split(';').map { s =>
val url = os.Path(s).toNIO.toUri.toURL
mill.constants.DebugLog.println("MILL_LOCAL_TEST_OVERRIDE_CLASSPATH " + url)
new java.net.URLClassLoader(Array(url))
}.toList
}
Expand Down
13 changes: 12 additions & 1 deletion integration/failure/os-checker/src/OsCheckerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ object OsCheckerTests extends UtestIntegrationTestSuite {
import tester._
val res = tester.eval("foo.bar")

val sep = if (mill.constants.Util.isWindows) "\\" else "/"
assert(res.isSuccess == false)
assert(res.err.contains(
s"Writing to foo not allowed during resolution phase"
Expand All @@ -31,6 +30,18 @@ object OsCheckerTests extends UtestIntegrationTestSuite {
s"Writing to not allowed during resolution phase"
))

tester.modifyFile(workspacePath / "build.mill", _.replace("if (true)", "if (false)"))
tester.modifyFile(
workspacePath / "build.mill",
_ + "\nprintln(os.read(mill.define.WorkspaceRoot.workspaceRoot / \"build.mill\"))"
)
val res4 = tester.eval("baz")

assert(res4.isSuccess == false)
assert(res4.err.contains(
s"Reading from build.mill not allowed during resolution phase"
))

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def writeCompletionMarker(name: String) = {
}

writeCompletionMarker("initialized")

if (os.read(moduleDir / "watchValue.txt").contains("exit")) {
Thread.sleep(1000)
System.exit(0)
os.checker.withValue(os.Checker.Nop) {
if (os.read(moduleDir / "watchValue.txt").contains("exit")) {
Thread.sleep(1000)
System.exit(0)
}
}
28 changes: 14 additions & 14 deletions libs/javascriptlib/src/mill/javascriptlib/TypeScriptModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,21 @@ trait TypeScriptModule extends Module { outer =>
if (!os.exists(T.dest)) os.makeDir.all(T.dest)

// Copy everything except "build.mill" and the "/out" directory from Task.workspace
os.walk(moduleDir, skip = _.last == "out")
.filter(_.last != "build.mill")
.filter(_.last != "mill")
.filter(_.last != "package.json")
.filter(_.last != "package-lock.json")
.filter(_.last != "tsconfig.json")
.foreach { path =>
val relativePath = path.relativeTo(moduleDir)
val destination = T.dest / relativePath

if (os.isDir(path)) os.makeDir.all(destination)
else os.checker.withValue(os.Checker.Nop) {
os.copy.over(path, destination)
os.checker.withValue(os.Checker.Nop) {
os.walk(moduleDir, skip = _.last == "out")
.filter(_.last != "build.mill")
.filter(_.last != "mill")
.filter(_.last != "package.json")
.filter(_.last != "package-lock.json")
.filter(_.last != "tsconfig.json")
.foreach { path =>
val relativePath = path.relativeTo(moduleDir)
val destination = T.dest / relativePath

if (os.isDir(path)) os.makeDir.all(destination)
else os.copy.over(path, destination)
}
}
}

object IsSrcDirectory {
def unapply(path: Path): Option[Path] =
Expand Down
18 changes: 10 additions & 8 deletions libs/main/src/mill/main/MainModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ trait MainModule extends BaseModule with MainModuleApi {
protected[mill] val evalWatchedValues: mutable.Buffer[Watchable] = mutable.Buffer.empty[Watchable]
object interp {
def watchValue[T](v0: => T)(implicit fn: sourcecode.FileName, ln: sourcecode.Line): T = {
val v = v0
val watchable = Watchable.Value(
() => v0.hashCode,
v.hashCode(),
fn.value + ":" + ln.value
)
watchedValues.append(watchable)
v
os.checker.withValue(os.Checker.Nop) {
val v = v0
val watchable = Watchable.Value(
() => v0.hashCode,
v.hashCode(),
fn.value + ":" + ln.value
)
watchedValues.append(watchable)
v
}
}

def watch(p: os.Path): os.Path = {
Expand Down
12 changes: 8 additions & 4 deletions runner/meta/src/mill/runner/meta/MillBuildRootModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ class MillBuildRootModule()(implicit

override def scalaVersion: T[String] = BuildInfo.scalaVersion

val scriptSourcesPaths = FileImportGraph
.walkBuildFiles(rootModuleInfo.projectRoot / os.up, rootModuleInfo.output)
.sorted
val scriptSourcesPaths = os.checker.withValue(os.Checker.Nop) {
FileImportGraph
.walkBuildFiles(rootModuleInfo.projectRoot / os.up, rootModuleInfo.output)
.sorted
}

/**
* All script files (that will get wrapped later)
Expand All @@ -52,7 +54,9 @@ class MillBuildRootModule()(implicit

def parseBuildFiles: T[FileImportGraph] = Task {
scriptSources()
MillBuildRootModule.parseBuildFiles(compilerWorker(), rootModuleInfo)
os.checker.withValue(os.Checker.Nop) {
MillBuildRootModule.parseBuildFiles(compilerWorker(), rootModuleInfo)
}
}

private[runner] def compilerWorker: Worker[ScalaCompilerWorkerApi] = Task.Worker {
Expand Down