Skip to content

Commit a8f001c

Browse files
committed
Attempt to use CLI rather than TAPI
1 parent c9e6bb0 commit a8f001c

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

buildSrc/src/main/kotlin/io/micronaut/build/GenerateReport.kt

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import org.gradle.api.file.RegularFileProperty
77
import org.gradle.api.provider.Property
88
import org.gradle.api.provider.ProviderFactory
99
import org.gradle.api.tasks.*
10-
import org.gradle.tooling.GradleConnector
1110
import java.io.File
1211
import java.nio.file.Files
1312
import javax.inject.Inject
@@ -41,16 +40,24 @@ abstract class GenerateReport : DefaultTask() {
4140
}
4241
Files.createDirectories(reportDirectory.get().asFile.toPath())
4342
try {
44-
GradleConnector.newConnector()
45-
.forProjectDirectory(projectDir)
46-
.connect().use {
47-
it.newBuild()
48-
.withArguments("-I", initScriptPath, "-DreportDir=" + reportDirectory.asFile.get().absolutePath)
49-
.forTasks("extractMicronautDependencies")
50-
.setStandardOutput(System.out)
51-
.setStandardError(System.err)
52-
.run()
53-
}
43+
val gradlew = if (System.getProperty("os.name").lowercase().contains("win")) "gradlew.bat" else "./gradlew"
44+
val reportDirPath = reportDirectory.asFile.get().absolutePath
45+
val command = listOf(
46+
gradlew,
47+
"--no-daemon",
48+
"-I", initScriptPath,
49+
"-DreportDir=$reportDirPath",
50+
"extractMicronautDependencies"
51+
)
52+
val process = ProcessBuilder(command)
53+
.directory(projectDir)
54+
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
55+
.redirectError(ProcessBuilder.Redirect.INHERIT)
56+
.start()
57+
val exit = process.waitFor()
58+
if (exit != 0) {
59+
throw RuntimeException("Gradle build failed with exit code $exit")
60+
}
5461
} catch (e: Exception) {
5562
// We intentionally ignore the status of the build result
5663
System.err.println(e.message)

0 commit comments

Comments
 (0)