Skip to content

Commit

Permalink
fix: restore plugin compatibility with Gradle 8.12+
Browse files Browse the repository at this point in the history
Manually tested with Gradle 8.8 and 8.12
  • Loading branch information
lppedd committed Jan 16, 2025
1 parent a7b1a99 commit 992ab15
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.strumenta.antlrkotlin.gradle.internal

import org.gradle.api.file.FileCollection
import org.gradle.process.internal.JavaExecHandleBuilder
import org.gradle.process.internal.worker.RequestHandler
import org.gradle.process.internal.worker.WorkerProcessFactory
import java.io.File
Expand Down Expand Up @@ -37,8 +38,19 @@ internal class AntlrWorkerManager {
javaCommand.workingDir = workingDir
javaCommand.maxHeapSize = spec.maxHeapSize
javaCommand.systemProperty("ANTLR_DO_NOT_EXIT", "true")
javaCommand.redirectErrorStream()
javaCommand.redirectErrorStreamCompat()

return builder.build()
}

/**
* Merge the process' error stream into its output stream.
*
* Solves a compatibility issue with Gradle 8.12+.
* See [antlr-kotlin/issues/201](https://github.com/Strumenta/antlr-kotlin/issues/201).
*/
private fun JavaExecHandleBuilder.redirectErrorStreamCompat() {
val method = this::class.java.getMethod("redirectErrorStream")
method.invoke(this)
}
}

0 comments on commit 992ab15

Please sign in to comment.