Browse Source

Print notarization status (#406)

* Always write external tool output logs to files

Previous implementation always passed an empty string to `processStdout`,
when verbose mode was used.

* Print notarization status in non-verbose mode too
pull/417/head
Alexey Tsvetkov 4 years ago committed by GitHub
parent
commit
ff8de6a830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/MultiOutputStream.kt
  2. 7
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNotarizationStatusTask.kt
  3. 18
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractComposeDesktopTask.kt

40
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/MultiOutputStream.kt

@ -0,0 +1,40 @@
package org.jetbrains.compose.desktop.application.internal
import java.io.FilterOutputStream
import java.io.OutputStream
internal class MultiOutputStream(
mainStream: OutputStream,
private val secondaryStream: OutputStream
) : FilterOutputStream(mainStream) {
override fun write(b: ByteArray, off: Int, len: Int) {
super.write(b, off, len)
secondaryStream.write(b, off, len)
}
override fun write(b: ByteArray) {
super.write(b)
secondaryStream.write(b)
}
override fun write(b: Int) {
super.write(b)
secondaryStream.write(b)
}
override fun flush() {
super.flush()
secondaryStream.flush()
}
override fun close() {
try {
super.close()
} finally {
secondaryStream.close()
}
}
}
internal fun OutputStream.alsoOutputTo(secondaryStream: OutputStream): OutputStream =
MultiOutputStream(this, secondaryStream)

7
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractCheckNotarizationStatusTask.kt

@ -43,7 +43,12 @@ abstract class AbstractCheckNotarizationStatusTask : AbstractNotarizationTask()
"--notarization-info", request.uuid, "--notarization-info", request.uuid,
"--username", notarization.appleID, "--username", notarization.appleID,
"--password", notarization.password "--password", notarization.password
) ),
processStdout = { output ->
if (!verbose.get()) {
logger.quiet(output)
}
}
) )
} catch (e: Exception) { } catch (e: Exception) {
logger.error("Could not check notarization request '${request.uuid}'", e) logger.error("Could not check notarization request '${request.uuid}'", e)

18
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractComposeDesktopTask.kt

@ -12,12 +12,12 @@ import org.gradle.api.tasks.LocalState
import org.gradle.process.ExecOperations import org.gradle.process.ExecOperations
import org.gradle.process.ExecResult import org.gradle.process.ExecResult
import org.jetbrains.compose.desktop.application.internal.ComposeProperties import org.jetbrains.compose.desktop.application.internal.ComposeProperties
import org.jetbrains.compose.desktop.application.internal.alsoOutputTo
import org.jetbrains.compose.desktop.application.internal.ioFile import org.jetbrains.compose.desktop.application.internal.ioFile
import org.jetbrains.compose.desktop.application.internal.notNullProperty import org.jetbrains.compose.desktop.application.internal.notNullProperty
import java.io.File import java.io.File
import java.time.LocalDateTime import java.time.LocalDateTime
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.util.function.Consumer
import javax.inject.Inject import javax.inject.Inject
abstract class AbstractComposeDesktopTask : DefaultTask() { abstract class AbstractComposeDesktopTask : DefaultTask() {
@ -55,11 +55,12 @@ abstract class AbstractComposeDesktopTask : DefaultTask() {
logsDir.mkdirs() logsDir.mkdirs()
val toolName = tool.nameWithoutExtension val toolName = tool.nameWithoutExtension
val logToConsole = verbose.get()
val outFile = logsDir.resolve("${toolName}-${currentTimeStamp()}-out.txt") val outFile = logsDir.resolve("${toolName}-${currentTimeStamp()}-out.txt")
val errFile = logsDir.resolve("${toolName}-${currentTimeStamp()}-out.txt") val errFile = logsDir.resolve("${toolName}-${currentTimeStamp()}-err.txt")
val result = outFile.outputStream().buffered().use { outStream -> val result = outFile.outputStream().buffered().use { outFileStream ->
errFile.outputStream().buffered().use { errStream -> errFile.outputStream().buffered().use { errFileStream ->
execOperations.exec { spec -> execOperations.exec { spec ->
spec.executable = tool.absolutePath spec.executable = tool.absolutePath
spec.args(*args.toTypedArray()) spec.args(*args.toTypedArray())
@ -68,9 +69,12 @@ abstract class AbstractComposeDesktopTask : DefaultTask() {
// check exit value later // check exit value later
spec.isIgnoreExitValue = true spec.isIgnoreExitValue = true
if (!verbose.get()) { if (logToConsole) {
spec.standardOutput = outStream spec.standardOutput = spec.standardOutput.alsoOutputTo(outFileStream)
spec.errorOutput = errStream spec.errorOutput = spec.errorOutput.alsoOutputTo(errFileStream)
} else {
spec.standardOutput = outFileStream
spec.errorOutput = errFileStream
} }
} }
} }

Loading…
Cancel
Save