Skip to content

Commit 68f2a95

Browse files
authored
[html][tests] Explicitly set executable flag for gradlew in integrat… (#5440)
This PR is a supposed fix for https://youtrack.jetbrains.com/issue/CMP-8990 Basically the problem is that `copyRecursively` does not guarantee execution flag to be preserved ## Testing `./gradlew checkComposeCases` ## Release Notes N/A
1 parent 8d23594 commit 68f2a95

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

html/compose-compiler-integration/build.gradle.kts

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fun cloneTemplate(templateName: String, contentMain: String, contentLib: String)
5454
return tempDir
5555
}
5656

57-
fun build(
57+
private fun build(
5858
caseName: String,
5959
directory: File,
6060
failureExpected: Boolean = false,
@@ -70,29 +70,48 @@ fun build(
7070
it.add("--info")
7171
}.toTypedArray()
7272

73-
val procBuilder = if (isWin) {
74-
ProcessBuilder("gradlew.bat", *arguments)
73+
val gradlewFile = File(directory, if (isWin) "gradlew.bat" else "gradlew")
74+
75+
println("[compose-compiler-integration] Working directory: ${directory.absolutePath}")
76+
77+
if (!gradlewFile.exists()) {
78+
throw GradleException("gradlew not found in ${directory.absolutePath}. Please ensure the Gradle wrapper is present.")
79+
}
80+
81+
if (!isWin) {
82+
if (!gradlewFile.canExecute()) {
83+
val isExecutable = gradlewFile.setExecutable(true)
84+
if (!isExecutable) {
85+
throw GradleException("Failed to make gradlew executable: ${gradlewFile.absolutePath}")
86+
}
87+
}
88+
}
89+
90+
val command: List<String> = if (isWin) {
91+
listOf("cmd", "/c", "gradlew.bat") + arguments
7592
} else {
76-
ProcessBuilder("bash", "./gradlew", *arguments)
93+
listOf("./gradlew") + arguments
7794
}
78-
val proc = procBuilder
79-
.directory(directory)
80-
.redirectOutput(ProcessBuilder.Redirect.PIPE)
81-
.redirectError(ProcessBuilder.Redirect.PIPE)
82-
.start()
83-
84-
proc.waitFor(5, TimeUnit.MINUTES)
85-
86-
"(COMPOSE_INTEGRATION_VERSION=\\[.*\\])".toRegex().find(
87-
proc.inputStream.bufferedReader().readText()
88-
)?.also {
89-
println(it.groupValues[1])
95+
println("[compose-compiler-integration] Executing: ${command.joinToString(" ")}")
96+
97+
val proc = try {
98+
ProcessBuilder(command)
99+
.directory(directory)
100+
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
101+
.redirectError(ProcessBuilder.Redirect.INHERIT)
102+
.start()
103+
} catch (e: Exception) {
104+
throw GradleException("Failed to start Gradle process. Command: ${command.joinToString(" ")}", e)
90105
}
91106

92-
println(proc.errorStream.bufferedReader().readText())
107+
val finished = proc.waitFor(10, TimeUnit.MINUTES)
108+
if (!finished) {
109+
proc.destroyForcibly()
110+
throw GradleException("Gradle process timed out for $caseName. Command: ${command.joinToString(" ")}")
111+
}
93112

94113
if (proc.exitValue() != 0 && !failureExpected) {
95-
throw GradleException("Error compiling $caseName")
114+
throw GradleException("Error compiling $caseName (exit code ${proc.exitValue()})")
96115
}
97116

98117
if (failureExpected && proc.exitValue() == 0) {

0 commit comments

Comments
 (0)