Skip to content

Commit

Permalink
DockerBuildTask: Report Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Oct 17, 2023
1 parent f7e3737 commit 380f04b
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.TaskAction
import java.util.concurrent.TimeUnit

abstract class DockerBuildTask : DefaultTask() {

Expand All @@ -27,7 +26,17 @@ abstract class DockerBuildTask : DefaultTask() {
processBuilder.redirectErrorStream(true)
val process = processBuilder.start()

val isSuccess = process.waitFor(2, TimeUnit.MINUTES) && process.exitValue() == 0
// Report Progress
process.inputStream
.bufferedReader()
.use { bufferedReader ->
while (true) {
val line = bufferedReader.readLine() ?: return@use
println(line)
}
}

val isSuccess = process.waitFor() == 0
if (!isSuccess) {
throw IllegalStateException("Couldn't build docker image.")
}
Expand Down

0 comments on commit 380f04b

Please sign in to comment.