Skip to content

Commit

Permalink
Using version catalog in convention plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
renelink committed Sep 7, 2024
1 parent a165c83 commit 935ed11
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
5 changes: 5 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ dependencyResolutionManagement {
mavenCentral()
gradlePluginPortal()
}
versionCatalogs {
create("libs") {
from(files("../libs.versions.toml"))
}
}

}
20 changes: 13 additions & 7 deletions build-logic/src/main/kotlin/lis-gradle-plugin.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import org.apache.tools.ant.filters.ReplaceTokens


plugins {
`java-gradle-plugin`
id("com.gradle.plugin-publish")
id("lis-gradle-plugin-maven")
}


java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
Expand All @@ -16,37 +18,41 @@ java {
}



tasks.test {
useJUnitPlatform()
}


gradlePlugin {
website = "https://github.com/link-intersystems/lis-gradle-plugins"
vcsUrl = "https://github.com/link-intersystems/lis-gradle-plugins.git"
}

val jacocoAgentConfig by configurations.creating {
}

val jacocoAgentConfig by configurations.creating
// Using the string-y api for lookup, because the libs version catalog is not compiled yet.
// See https://discuss.gradle.org/t/using-version-catalog-from-buildsrc-buildlogic-xyz-common-conventions-scripts/48534/22
val libs = the<VersionCatalogsExtension>().named("libs")

dependencies {
jacocoAgentConfig("org.jacoco:org.jacoco.agent:0.8.12")
jacocoAgentConfig(libs.findLibrary("jacoco.agent").orElseThrow())
}


tasks.create<Copy>("copyJacoco") {
tasks.create<Copy>("extractJacoco") {
from(zipTree(configurations["jacocoAgentConfig"].singleFile)) {
include("jacocoagent.jar")
}
into(project.layout.buildDirectory.dir("jacoco"));
}


tasks.withType<ProcessResources> {
dependsOn("copyJacoco")
dependsOn("extractJacoco")
filesMatching("**/*") {
expand(project.properties)
val tokens = mapOf(
"jacoco_dir" to tasks.getByName("copyJacoco").outputs.files.singleFile.toPath().toString()
"jacoco_dir" to tasks.getByName("extractJacoco").outputs.files.singleFile.toPath().toString()
.replace("\\", "/")
)
filter<ReplaceTokens>("tokens" to tokens)
Expand Down
3 changes: 3 additions & 0 deletions libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jgit_version = "6.9.0.202403050737-r"
junit_jupiter_version = "5.10.2"
mockito_version = "5.11.0"
slf4j_version = "2.0.12"
jacoco_version = "0.8.12"

[libraries]
lis-platform = { module = "com.link-intersystems.gradle.commons:lis-gradle-platform", version.ref = "listGradleCommons_version" }
Expand All @@ -19,6 +20,8 @@ junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", vers
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito_version" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j_version" }

jacoco-agent = { module = "org.jacoco:org.jacoco.agent", version.ref ="jacoco_version" }

[bundles]
testing = [
"junit-jupiter-api",
Expand Down

0 comments on commit 935ed11

Please sign in to comment.