Skip to content
Open
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
18 changes: 10 additions & 8 deletions libs/javalib/src/mill/javalib/RunModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,28 @@ trait RunModule extends WithJvmWorkerModule with RunModuleApi {
/**
* Runs this module's code in a subprocess and waits for it to finish
*/
def run(args: Task[Args] = Task.Anon(Args())): Task.Command[Unit] = Task.Command {
runForkedTask(finalMainClass, args)()
}
def run(args: Task[Args] = Task.Anon(Args())): Task.Command[Unit] =
Task.Command(exclusive = true) {
runForkedTask(finalMainClass, args)()
}

/**
* Runs this module's code in-process within an isolated classloader. This is
* faster than `run`, but in exchange you have less isolation between runs
* since the code can dirty the parent Mill process and potentially leave it
* in a bad state.
*/
def runLocal(args: Task[Args] = Task.Anon(Args())): Task.Command[Unit] = Task.Command {
runLocalTask(finalMainClass, args)()
}
def runLocal(args: Task[Args] = Task.Anon(Args())): Task.Command[Unit] =
Task.Command(exclusive = true) {
runLocalTask(finalMainClass, args)()
}

/**
* Same as `run`, but lets you specify a main class to run
*/
def runMain(@arg(positional = true) mainClass: String, args: String*): Task.Command[Unit] = {
val task = runForkedTask(Task.Anon { mainClass }, Task.Anon { Args(args) })
Task.Command { task() }
Task.Command(exclusive = true) { task() }
}

/**
Expand All @@ -152,7 +154,7 @@ trait RunModule extends WithJvmWorkerModule with RunModuleApi {
*/
def runMainLocal(@arg(positional = true) mainClass: String, args: String*): Task.Command[Unit] = {
val task = runLocalTask(Task.Anon { mainClass }, Task.Anon { Args(args) })
Task.Command { task() }
Task.Command(exclusive = true) { task() }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libs/javalib/src/mill/javalib/bsp/BspRunModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private[mill] object BspRunModule extends ExternalModule {
object internalBspRunModule extends mill.api.Module with BspRunModuleApi {

override private[mill] def bspRun(args: Seq[String]): Task[Unit] = Task.Anon {
runModule.run(Task.Anon(Args(args)))()
runModule.runForkedTask(runModule.finalMainClass, Task.Anon(Args(args)))()
}

override private[mill] def bspJvmRunEnvironment: Task.Simple[(
Expand Down
Loading