@@ -7,7 +7,6 @@ import org.gradle.api.file.RegularFileProperty
77import org.gradle.api.provider.Property
88import org.gradle.api.provider.ProviderFactory
99import org.gradle.api.tasks.*
10- import org.gradle.tooling.GradleConnector
1110import java.io.File
1211import java.nio.file.Files
1312import 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