diff --git a/.github/workflows/build_snapshot.yml b/.github/workflows/build_snapshot.yml index 47a9c961..2514d8cf 100644 --- a/.github/workflows/build_snapshot.yml +++ b/.github/workflows/build_snapshot.yml @@ -19,7 +19,9 @@ jobs: with: distribution: 'temurin' java-version: '17' - cache: 'gradle' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Grant execute permission for gradlew run: chmod +x gradlew diff --git a/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/McpExecutor.kt b/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/McpExecutor.kt index 832bfc92..840651f9 100644 --- a/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/McpExecutor.kt +++ b/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/McpExecutor.kt @@ -211,7 +211,7 @@ data class McpExecutor( return path } - override fun javaexec(configurator: Action) { + override fun javaexec(configurator: Action) { SubprocessExecutor.exec(project, configurator).rethrowFailure().assertNormalExitValue() } diff --git a/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/SubprocessExecutor.kt b/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/SubprocessExecutor.kt index 5fb353d3..48de9afb 100644 --- a/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/SubprocessExecutor.kt +++ b/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/forge/fg3/mcpconfig/SubprocessExecutor.kt @@ -7,39 +7,44 @@ import org.gradle.api.logging.LogLevel import org.gradle.api.logging.configuration.ShowStacktrace import org.gradle.process.ExecResult import org.gradle.process.JavaExecSpec +import org.gradle.process.ExecOperations +import org.gradle.api.provider.Provider object SubprocessExecutor { - fun shouldShowVerboseStdout(project: Project): Boolean { + + private fun shouldShowVerboseStdout(project: Project): Boolean { // if running with INFO or DEBUG logging return project.gradle.startParameter.logLevel < LogLevel.LIFECYCLE } - fun shouldShowVerboseStderr(project: Project): Boolean { + private fun shouldShowVerboseStderr(project: Project): Boolean { // if stdout is shown or stacktraces are visible so that errors printed to stderr show up return shouldShowVerboseStdout(project) || project.gradle.startParameter.showStacktrace != ShowStacktrace.INTERNAL_EXCEPTIONS } /** - * Executes a [javaexec][Project.javaexec] action with suppressed output. + * Executes a [javaexec][ExecOperations.javaexec] action with suppressed output. * * @param project the project * @param configurator the `javaexec` configuration action - * @return the execution result + * @return a Provider of the execution result */ - fun exec(project: Project, configurator: Action): ExecResult { - return project.javaexec { spec: JavaExecSpec -> + fun exec(project: Project, configurator: Action): ExecResult { + val execOperations = project.extensions.getByType(ExecOperations::class.java) + + return execOperations.javaexec { spec: JavaExecSpec -> spec.workingDir(project.rootProject.projectDir) configurator.execute(spec) - if (shouldShowVerboseStdout(project)) { - spec.standardOutput = System.out + spec.standardOutput = if (shouldShowVerboseStdout(project)) { + System.out } else { - spec.standardOutput = NullOutputStream.NULL_OUTPUT_STREAM + NullOutputStream.NULL_OUTPUT_STREAM } - if (shouldShowVerboseStderr(project)) { - spec.errorOutput = System.err + spec.errorOutput = if (shouldShowVerboseStderr(project)) { + System.err } else { - spec.errorOutput = NullOutputStream.NULL_OUTPUT_STREAM + NullOutputStream.NULL_OUTPUT_STREAM } } } -} \ No newline at end of file +} diff --git a/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/jarmod/JarModAgentMinecraftTransformer.kt b/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/jarmod/JarModAgentMinecraftTransformer.kt index 693812ae..862de5c1 100644 --- a/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/jarmod/JarModAgentMinecraftTransformer.kt +++ b/src/minecraft/kotlin/xyz/wagyourtail/unimined/internal/minecraft/patch/jarmod/JarModAgentMinecraftTransformer.kt @@ -120,18 +120,21 @@ open class JarModAgentMinecraftTransformer( try { val classpath = (task as RemapJarTaskImpl).provider.sourceSet.runtimeClasspath.files.toMutableSet() - val result = SubprocessExecutor.exec(project) { + val resultProvider = SubprocessExecutor.exec(project) { it.jvmArgs = listOf( "-D${JMA_TRANSFORMERS}=${transforms.joinToString(File.pathSeparator)}", - "-D${JMA_DEBUG}=true") + "-D${JMA_DEBUG}=true" + ) it.args = listOf( input.absolutePathString(), classpath.joinToString(File.pathSeparator) { it.absolutePath }, - output.absolutePathString(), + output.absolutePathString() ) it.mainClass.set("xyz.wagyourtail.unimined.jarmodagent.JarModAgent") it.classpath = jarModAgent } + + val result = resultProvider.get() if (result.exitValue != 0) { throw IOException("Failed to run JarModAgent transformer: ${result.exitValue}") }