Skip to content

Commit

Permalink
Fix MiMa
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaychandran committed Sep 7, 2024
1 parent d3d565a commit 78bb19c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ trait CheckstyleModule extends JavaModule {
T.log.info(s"generating checkstyle $format report ...")
T.log.debug(s"running checkstyle with $args")

val errs = Jvm.callSubprocess(
val errs = Jvm.callSubprocessUnchecked(
mainClass = "com.puppycrawl.tools.checkstyle.Main",
classPath = classpath,
mainArgs = args,
workingDir = T.dest,
check = false
workingDir = T.dest
).exitCode

if (errs == 0) {
Expand Down
29 changes: 26 additions & 3 deletions main/util/src/mill/util/Jvm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ object Jvm extends CoursierSupport {
envArgs: Map[String, String] = Map.empty,
mainArgs: Seq[String] = Seq.empty,
workingDir: os.Path = null,
streamOut: Boolean = true,
check: Boolean = false
streamOut: Boolean = true
)(implicit ctx: Ctx): CommandResult = {

val commandArgs =
Expand All @@ -37,7 +36,31 @@ object Jvm extends CoursierSupport {
val workingDir1 = Option(workingDir).getOrElse(ctx.dest)
os.makeDir.all(workingDir1)

os.proc(commandArgs).call(cwd = workingDir1, env = envArgs, check = check)
os.proc(commandArgs).call(cwd = workingDir1, env = envArgs)
}

/**
* A version of [[Jvm.callSubprocess]] that does not raise an exception on a non-zero exit.
*/
def callSubprocessUnchecked(
mainClass: String,
classPath: Agg[os.Path],
jvmArgs: Seq[String] = Seq.empty,
envArgs: Map[String, String] = Map.empty,
mainArgs: Seq[String] = Seq.empty,
workingDir: os.Path = null
)(implicit ctx: Ctx): CommandResult = {

val commandArgs =
Vector(javaExe) ++
jvmArgs ++
Vector("-cp", classPath.iterator.mkString(java.io.File.pathSeparator), mainClass) ++
mainArgs

val workingDir1 = Option(workingDir).getOrElse(ctx.dest)
os.makeDir.all(workingDir1)

os.proc(commandArgs).call(cwd = workingDir1, env = envArgs, check = false)
}

/**
Expand Down

0 comments on commit 78bb19c

Please sign in to comment.