Skip to content

Commit

Permalink
Fixes sbt#1345 - do not buffer logging for native-image output
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaylagutko committed Apr 6, 2023
1 parent 5216d42 commit ecf74b5
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.typesafe.sbt.packager.graalvmnativeimage

import java.io.ByteArrayInputStream

import java.io.{ByteArrayInputStream, PrintStream, PrintWriter}
import sbt._
import sbt.Keys.{mainClass, name, _}
import com.typesafe.sbt.packager.{MappingsHelper, Stager}
Expand Down Expand Up @@ -73,7 +72,7 @@ object GraalVMNativeImagePlugin extends AutoPlugin {
className,
classpathJars.map(_._1),
extraOptions,
streams.log
UnbufferedProcessLogger(streams.log)
)

case Some(image) =>
Expand Down Expand Up @@ -152,7 +151,7 @@ object GraalVMNativeImagePlugin extends AutoPlugin {
s"-H:Name=$binaryName"
) ++ extraOptions ++ Seq(className)

sys.process.Process(command) ! streams.log match {
sys.process.Process(command) ! UnbufferedProcessLogger(streams.log) match {
case 0 => targetDirectory / binaryName
case x => sys.error(s"Failed to run $command, exit status: " + x)
}
Expand Down Expand Up @@ -218,3 +217,11 @@ object GraalVMNativeImagePlugin extends AutoPlugin {
Stager.stage(GraalVMBaseImage)(streams, stageDir, mappings)
}
}

private case class UnbufferedProcessLogger(logger: Logger) extends ProcessLogger {
override def out(s: => String): Unit = logger.out(s)

override def err(s: => String): Unit = logger.err(s)

override def buffer[T](f: => T): T = f
}

0 comments on commit ecf74b5

Please sign in to comment.