Skip to content

Commit 6b3db70

Browse files
committed
Fix
1 parent a62ace5 commit 6b3db70

File tree

7 files changed

+35
-31
lines changed

7 files changed

+35
-31
lines changed

kotlinlib/src/mill/kotlinlib/android/AndroidAppKotlinModule.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ trait AndroidAppKotlinModule extends AndroidAppModule with KotlinModule { outer
251251
"-Dlayoutlib.thread.profile.timeoutms=10000",
252252
"-Djava.security.manager=allow"
253253
),
254-
mainArgs = Seq(composePreviewArgs().path.toString())
254+
mainArgs = Seq(composePreviewArgs().path.toString()),
255+
cwd = Task.dest
255256
)
256257
mill.util.ProcessUtil.toResult(processResult).getOrThrow
257258
val previewGenOut = processResult.out.lines()

main/util/src/mill/util/Jvm.scala

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ object Jvm extends CoursierSupport {
3535
* @param env Environment variables used when starting the forked JVM
3636
* @param propagateEnv If `true` then the current process' environment variables are propagated to subprocess
3737
* @param cwd The working directory to be used by the forked JVM
38-
* @param stdin Standard input override
39-
* @param stdout Standard output override
40-
* @param stderr Standard error override
38+
* @param stdin Standard input
39+
* @param stdout Standard output
40+
* @param stderr Standard error
4141
* @param mergeErrIntoOut If `true` then the error output is merged into standard output
4242
*/
4343
def call(
@@ -70,20 +70,20 @@ object Jvm extends CoursierSupport {
7070
classPath
7171
}
7272

73-
val commandArgs =
74-
Vector(javaExe(javaHome)) ++
73+
val commandArgs = (Vector(javaExe(javaHome)) ++
7574
jvmArgs ++
76-
Vector("-cp", cp.mkString(java.io.File.pathSeparator), mainClass) ++
75+
Option.when(cp.nonEmpty)(Vector("-cp", cp.mkString(java.io.File.pathSeparator))).getOrElse(Vector.empty) ++
76+
Vector(mainClass) ++
7777
mainArgs
78+
).filterNot(_.isBlank)
7879

79-
val workingDir1 = Option(cwd).getOrElse(ctx.dest)
80-
os.makeDir.all(workingDir1)
80+
if (cwd != null) os.makeDir.all(cwd)
8181

82-
ctx.log.debug(s"Run subprocess with args: ${commandArgs.map(a => s"'${a}'").mkString(" ")}")
82+
ctx.log.debug(s"Call subprocess with args: ${commandArgs.map(a => s"'${a}'").mkString(" ")}")
8383

8484
os.proc(commandArgs)
8585
.call(
86-
cwd = workingDir1,
86+
cwd = cwd,
8787
env = env,
8888
check = false,
8989
stdin = stdin,
@@ -148,22 +148,18 @@ object Jvm extends CoursierSupport {
148148
classPath
149149
}
150150

151-
val cpArgument = if (cp.nonEmpty) {
152-
Vector("-cp", cp.mkString(java.io.File.pathSeparator))
153-
} else Seq.empty
154-
val mainClassArgument = if (mainClass.nonEmpty) {
155-
Seq(mainClass)
156-
} else Seq.empty
157-
val args =
158-
Vector(javaExe(javaHome)) ++
159-
jvmArgs ++
160-
cpArgument ++
161-
mainClassArgument ++
162-
mainArgs
151+
val commandArgs = (Vector(javaExe(javaHome)) ++
152+
jvmArgs ++
153+
Option.when(cp.nonEmpty)(Vector("-cp", cp.mkString(java.io.File.pathSeparator))).getOrElse(Vector.empty) ++
154+
Vector(mainClass) ++
155+
mainArgs
156+
).filterNot(_.isBlank)
163157

164-
ctx.log.debug(s"Run subprocess with args: ${args.map(a => s"'${a}'").mkString(" ")}")
158+
if (cwd != null) os.makeDir.all(cwd)
159+
160+
ctx.log.debug(s"Spawn subprocess with args: ${commandArgs.map(a => s"'${a}'").mkString(" ")}")
165161

166-
val process = os.proc(args).spawn(
162+
val process = os.proc(commandArgs).spawn(
167163
cwd = cwd,
168164
env = env,
169165
stdin = stdin,

scalalib/src/mill/scalalib/JavaModule.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,8 @@ trait JavaModule
12061206
super.forkEnv()
12071207
}
12081208

1209+
def launcher: T[PathRef] = Task { launcher0() }
1210+
12091211
/**
12101212
* Task that print the transitive dependency tree to STDOUT.
12111213
* NOTE: that when `whatDependsOn` is used with `inverse` it will just

scalalib/src/mill/scalalib/RunModule.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ trait RunModule extends WithZincWorker {
5353
classPath = zincWorker().classpath().map(_.path).toVector,
5454
mainArgs = Seq(classpath.mkString(",")),
5555
javaHome = zincWorker().javaHome().map(_.path),
56-
stdout = os.Pipe
56+
stdout = os.Pipe,
57+
cwd = Task.dest
5758
)
5859
mill.util.ProcessUtil.toResult(processResult).getOrThrow
5960
processResult.out.lines()
@@ -340,7 +341,7 @@ object RunModule {
340341
env = env,
341342
mainArgs = mainArgs,
342343
cwd = cwd,
343-
stdin = ProcessInput.makeSourceInput(""): os.ProcessInput,
344+
stdin = "",
344345
stdout = stdout,
345346
stderr = stderr,
346347
useCpPassingJar = useClasspathPassingJar,

scalalib/src/mill/scalalib/ScalaModule.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ trait ScalaModule extends JavaModule with TestModule.ScalaModuleBase { outer =>
434434
} else {
435435
val useJavaCp = "-usejavacp"
436436

437-
Jvm.spawn(
437+
val processResult = Jvm.call(
438438
mainClass =
439439
if (ZincWorkerUtil.isDottyOrScala3(scalaVersion()))
440440
"dotty.tools.repl.Main"
@@ -448,6 +448,7 @@ trait ScalaModule extends JavaModule with TestModule.ScalaModuleBase { outer =>
448448
mainArgs = Seq(useJavaCp) ++ consoleScalacOptions().filterNot(Set(useJavaCp)),
449449
cwd = forkWorkingDir()
450450
)
451+
mill.util.ProcessUtil.toResult(processResult).getOrThrow
451452
Result.Success(())
452453
}
453454
}
@@ -509,14 +510,15 @@ trait ScalaModule extends JavaModule with TestModule.ScalaModuleBase { outer =>
509510
} else {
510511
val mainClass = ammoniteMainClass()
511512
Task.log.debug(s"Using ammonite main class: ${mainClass}")
512-
Jvm.spawn(
513+
val processResult = Jvm.call(
513514
mainClass = mainClass,
514515
classPath = ammoniteReplClasspath().map(_.path).toVector,
515516
jvmArgs = forkArgs(),
516517
env = forkEnv(),
517518
mainArgs = replOptions,
518519
cwd = forkWorkingDir()
519520
)
521+
mill.util.ProcessUtil.toResult(processResult).getOrThrow
520522
Result.Success(())
521523
}
522524

scalalib/src/mill/scalalib/TestModule.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ trait TestModule
5050
testClasspath().flatMap(p => Seq("--testCp", p.path.toString())) ++
5151
Seq("--framework", testFramework()),
5252
javaHome = zincWorker().javaHome().map(_.path),
53-
stdout = os.Pipe
53+
stdout = os.Pipe,
54+
cwd = Task.dest
5455
)
5556
mill.util.ProcessUtil.toResult(processResult).getOrThrow
5657
processResult.out.lines()

scalalib/src/mill/scalalib/TestModuleUtil.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ private[scalalib] object TestModuleUtil {
112112
selectors.flatMap(s => Seq("--selectors", s)) ++
113113
args.flatMap(s => Seq("--args", s)),
114114
javaHome = javaHome,
115-
stdout = os.Pipe
115+
stdout = os.Pipe,
116+
cwd = Task.dest
116117
)
117118
mill.util.ProcessUtil.toResult(processResult).getOrThrow
118119
processResult.out.lines().toSet

0 commit comments

Comments
 (0)