Skip to content

Commit

Permalink
log passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed May 13, 2024
1 parent d281adc commit 026e527
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

package xyz.wagyourtail.jvmdg.gradle.task

import org.apache.commons.io.output.NullOutputStream
import org.gradle.api.JavaVersion
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.logging.LogLevel
import org.gradle.api.logging.configuration.ShowStacktrace
import org.gradle.api.tasks.*
import org.gradle.jvm.tasks.Jar
import xyz.wagyourtail.jvmdg.gradle.JVMDowngraderExtension
Expand Down Expand Up @@ -45,17 +48,28 @@ abstract class DowngradeJar : Jar() {
val tempOutput = temporaryDir.resolve("downgradedInput.jar")
tempOutput.deleteIfExists()

project.javaexec {
it.mainClass.set("xyz.wagyourtail.jvmdg.compile.ZipDowngrader")
it.args = listOf(
project.javaexec { spec ->
spec.mainClass.set("xyz.wagyourtail.jvmdg.compile.ZipDowngrader")
spec.args = listOf(
jvToOpc(downgradeTo).toString(),
inputFile.get().asFile.absolutePath,
tempOutput.absolutePath,
sourceSet.compileClasspath.files.joinToString(File.pathSeparator) { it.absolutePath }
)
it.workingDir = temporaryDir
it.classpath = jvmdg.core
it.jvmArgs = listOf("-Djvmdg.java-api=${jvmdg.api.resolve().first { it.extension == "jar" }.absolutePath}")
spec.workingDir = temporaryDir
spec.classpath = jvmdg.core
spec.jvmArgs = listOf("-Djvmdg.java-api=${jvmdg.api.resolve().first { it.extension == "jar" }.absolutePath}")

if (project.gradle.startParameter.logLevel < LogLevel.LIFECYCLE) {
spec.standardOutput = System.out
} else {
spec.standardOutput = NullOutputStream.NULL_OUTPUT_STREAM
}
if (project.gradle.startParameter.logLevel < LogLevel.LIFECYCLE || project.gradle.startParameter.showStacktrace != ShowStacktrace.INTERNAL_EXCEPTIONS) {
spec.errorOutput = System.err
} else {
spec.errorOutput = NullOutputStream.NULL_OUTPUT_STREAM
}
}.assertNormalExitValue().rethrowFailure()

inputFile.asFile.get().toPath().readZipInputStreamFor("META-INF/MANIFEST.MF", false) { inp ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

package xyz.wagyourtail.jvmdg.gradle.task

import org.apache.commons.io.output.NullOutputStream
import org.gradle.api.JavaVersion
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.logging.LogLevel
import org.gradle.api.logging.configuration.ShowStacktrace
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
Expand Down Expand Up @@ -57,6 +60,17 @@ abstract class ShadeAPI : Jar() {
)
spec.workingDir = temporaryDir
spec.classpath = jvmdg.core

if (project.gradle.startParameter.logLevel < LogLevel.LIFECYCLE) {
spec.standardOutput = System.out
} else {
spec.standardOutput = NullOutputStream.NULL_OUTPUT_STREAM
}
if (project.gradle.startParameter.logLevel < LogLevel.LIFECYCLE || project.gradle.startParameter.showStacktrace != ShowStacktrace.INTERNAL_EXCEPTIONS) {
spec.errorOutput = System.err
} else {
spec.errorOutput = NullOutputStream.NULL_OUTPUT_STREAM
}
}.assertNormalExitValue().rethrowFailure()

inputFile.asFile.get().toPath().readZipInputStreamFor("META-INF/MANIFEST.MF", false) { inp ->
Expand Down

0 comments on commit 026e527

Please sign in to comment.