Skip to content

Commit 5e6b095

Browse files
committed
Add race-condition work-around
1 parent 2489e53 commit 5e6b095

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

build-logic/preprocess-workflows/src/main/groovy/org/spockframework/gradle/PreprocessGithubWorkflowWorkAction.groovy

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,27 @@ abstract class PreprocessGithubWorkflowWorkAction implements WorkAction<Paramete
1616

1717
@Override
1818
void execute() {
19-
execOperations.javaexec {
20-
it.executable = parameters.javaExecutable.get().asFile.absolutePath
21-
it.classpath(parameters.kotlinCompilerClasspath)
22-
it.mainClass.set('org.jetbrains.kotlin.cli.jvm.K2JVMCompiler')
23-
it.args('-no-stdlib', '-no-reflect')
24-
it.args('-classpath', parameters.mainKtsClasspath.asPath)
25-
it.args('-script', parameters.workflowScript.get().asFile.absolutePath)
26-
27-
// work-around for https://youtrack.jetbrains.com/issue/KT-42101
28-
it.systemProperty('kotlin.main.kts.compiled.scripts.cache.dir', '')
19+
// work-around for https://youtrack.jetbrains.com/issue/KT-74830
20+
Exception lastException = null
21+
for (i in 1..5) {
22+
try {
23+
execOperations.javaexec {
24+
it.executable = parameters.javaExecutable.get().asFile.absolutePath
25+
it.classpath(parameters.kotlinCompilerClasspath)
26+
it.mainClass.set('org.jetbrains.kotlin.cli.jvm.K2JVMCompiler')
27+
it.args('-no-stdlib', '-no-reflect')
28+
it.args('-classpath', parameters.mainKtsClasspath.asPath)
29+
it.args('-script', parameters.workflowScript.get().asFile.absolutePath)
30+
31+
// work-around for https://youtrack.jetbrains.com/issue/KT-42101
32+
it.systemProperty('kotlin.main.kts.compiled.scripts.cache.dir', '')
33+
}
34+
return
35+
} catch (Exception e) {
36+
lastException = e
37+
}
2938
}
39+
throw lastException
3040
}
3141

3242
static interface Parameters extends WorkParameters {

0 commit comments

Comments
 (0)