Skip to content

Commit

Permalink
Move workflows Kotlin dependencies for Gradle to version catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Dec 30, 2024
1 parent e08b875 commit 6e111db
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

dependencies {
implementation('org.jetbrains.kotlin:kotlin-compiler-embeddable:2.1.0')
implementation(libs.workflows.kotlin.compiler.embeddable)
}

gradlePlugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package org.spockframework.gradle
import groovy.transform.CompileStatic
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.tasks.JavaExec
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.toolchain.JavaToolchainService
Expand All @@ -40,15 +41,16 @@ import static org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles.JVM_C
@CompileStatic
class PreprocessWorkflowsPlugin implements Plugin<Project> {
void apply(Project project) {
def libs = project.extensions.getByType(VersionCatalogsExtension).find('libs').orElseThrow(AssertionError::new)
def kotlinCompilerClasspath = project.configurations.detachedConfiguration(
project.dependencies.create('org.jetbrains.kotlin:kotlin-compiler:2.1.0'),
project.dependencies.create('org.jetbrains.kotlin:kotlin-scripting-compiler:2.1.0')
libs.findLibrary('workflows-kotlin-compiler').orElseThrow(AssertionError::new).get(),
libs.findLibrary('workflows-kotlin-scripting-compiler').orElseThrow(AssertionError::new).get()
)
def kotlinScriptClasspath = project.configurations.detachedConfiguration(
project.dependencies.create('org.jetbrains.kotlin:kotlin-main-kts:2.1.0') { ModuleDependency it ->
it.transitive = false
}
)
libs.findLibrary('workflows-kotlin-main-kts').orElseThrow(AssertionError::new).get()
).tap {
it.transitive = false
}

def preprocessWorkflows = project.tasks.register('preprocessWorkflows') {
it.group = 'github actions'
Expand Down Expand Up @@ -83,6 +85,12 @@ class PreprocessWorkflowsPlugin implements Plugin<Project> {
// work-around for https://youtrack.jetbrains.com/issue/KT-42101
it.systemProperty('kotlin.main.kts.compiled.scripts.cache.dir', '')
}
project.pluginManager.withPlugin('io.spring.nohttp') {
// iff both tasks are run, workflow files should be generated before checkstyle check
project.tasks.named('checkstyleNohttp') {
it.mustRunAfter(preprocessWorkflow)
}
}
preprocessWorkflows.configure {
it.dependsOn(preprocessWorkflow)
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ tasks.register("codeCoverageReport", JacocoReport) {
}

if (gradle.startParameter.taskNames == ["ghActionsBuild"]) {
gradle.startParameter.taskNames = ["build", "codeCoverageReport"]
gradle.startParameter.taskNames = ["build", "preprocessWorkflows", "codeCoverageReport"]
}

if (gradle.startParameter.taskNames == ["ghActionsPublish"] || gradle.startParameter.taskNames == ["ghActionsDocs"]) {
Expand Down
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ junit = '5.11.4'
asm = '9.7.1'
mockito4 = '4.11.0'
mockito5 = '5.14.2'
workflows-kotlin = "2.0.20"

[libraries]
jetbrains-annotations = "org.jetbrains:annotations:26.0.1"
Expand All @@ -33,6 +34,10 @@ junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
junit-jupiter.module = "org.junit.jupiter:junit-jupiter"
junit-platform-testkit.module = "org.junit.platform:junit-platform-testkit"
junit-platform-console.module = "org.junit.platform:junit-platform-console"
workflows-kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler", version.ref = "workflows-kotlin" }
workflows-kotlin-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "workflows-kotlin" }
workflows-kotlin-main-kts = { module = "org.jetbrains.kotlin:kotlin-main-kts", version.ref = "workflows-kotlin" }
workflows-kotlin-scripting-compiler = { module = "org.jetbrains.kotlin:kotlin-scripting-compiler", version.ref = "workflows-kotlin" }

# just here so that renovate can figure out the dependencies
groovy-v2 = { module = "org.codehaus.groovy:groovy", version.ref="groovy2" }
Expand Down

0 comments on commit 6e111db

Please sign in to comment.