From a6c8b145c3c422dd3974a1b112a7652becdaaff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Mon, 27 May 2024 00:02:29 +0200 Subject: [PATCH] Work around KT-42101 when preprocessing workflows --- .../kotlin/net/kautler/github_actions.gradle.kts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gradle/build-logic/src/main/kotlin/net/kautler/github_actions.gradle.kts b/gradle/build-logic/src/main/kotlin/net/kautler/github_actions.gradle.kts index 9251f2af..2e5769b6 100644 --- a/gradle/build-logic/src/main/kotlin/net/kautler/github_actions.gradle.kts +++ b/gradle/build-logic/src/main/kotlin/net/kautler/github_actions.gradle.kts @@ -53,15 +53,19 @@ dependencies { } } -val preprocessWorkflows by tasks.registering +val preprocessWorkflows by tasks.registering { + group = "github actions" +} file(".github/workflows") .listFiles { _, name -> name.endsWith(".main.kts") }!! .forEach { workflowScript -> val workflowName = workflowScript.name.removeSuffix(".main.kts") - val camelCasedWorkflowName = workflowName.replace("""-\w""".toRegex()) { + val pascalCasedWorkflowName = workflowName.replace("""-\w""".toRegex()) { it.value.substring(1).replaceFirstChar(Char::uppercaseChar) }.replaceFirstChar(Char::uppercaseChar) - val preprocessWorkflow = tasks.register("preprocess${camelCasedWorkflowName}Workflow") { + val preprocessWorkflow = tasks.register("preprocess${pascalCasedWorkflowName}Workflow") { + group = "github actions" + inputs .file(workflowScript) .withPropertyName("workflowScript") @@ -80,6 +84,9 @@ file(".github/workflows") args("-no-stdlib", "-no-reflect") args("-classpath", scriptClasspath.asPath) args("-script", workflowScript.absolutePath) + + // work-around for https://youtrack.jetbrains.com/issue/KT-42101 + systemProperty("kotlin.main.kts.compiled.scripts.cache.dir", "") } preprocessWorkflows { dependsOn(preprocessWorkflow)