Skip to content

Commit ca1ce65

Browse files
committed
Align build-logic with wrkx/srcx conventions
- Split conventions: clkx-module, clkx-toolchain, clkx-plugin, clkx-publish, clkx-testing, clkx-detekt, clkx-ktlint, clkx-conventions (uber) - Add ClkxSettingsPlugin for foojay toolchain resolution - Add detekt.yml config - Add slopTest source set with konsist - Kover at 90% with @TaskAction and SettingsPlugin exclusions - clkx-library for exec module (JavaLibrary publishing)
1 parent 1832ace commit ca1ce65

29 files changed

Lines changed: 2599 additions & 2324 deletions

build-logic/build.gradle.kts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@ plugins {
22
`kotlin-dsl`
33
}
44

5+
repositories {
6+
mavenCentral()
7+
gradlePluginPortal()
8+
}
9+
510
dependencies {
6-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.0")
11+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${embeddedKotlinVersion}")
712
implementation("com.vanniktech:gradle-maven-publish-plugin:0.32.0")
13+
implementation("org.gradle.toolchains:foojay-resolver:1.0.0")
14+
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.9.1")
815
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8")
916
implementation("org.jlleitschuh.gradle:ktlint-gradle:12.2.0")
10-
implementation("org.jetbrains.kotlinx:kover-gradle-plugin:0.9.1")
17+
}
18+
19+
gradlePlugin {
20+
plugins {
21+
register("clkx-settings") {
22+
id = "clkx-settings"
23+
implementationClass = "zone.clanker.gradle.conventions.ClkxSettingsPlugin"
24+
}
25+
}
1126
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id("clkx-module")
3+
id("clkx-toolchain")
4+
id("clkx-plugin")
5+
id("clkx-publish")
6+
id("clkx-testing")
7+
id("clkx-detekt")
8+
id("clkx-ktlint")
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id("io.gitlab.arturbosch.detekt")
3+
}
4+
5+
detekt {
6+
config.setFrom(rootProject.file("config/detekt.yml"))
7+
buildUponDefaultConfig = true
8+
parallel = true
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id("org.jlleitschuh.gradle.ktlint")
3+
}
4+
5+
ktlint {
6+
version.set("1.5.0")
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1+
import com.vanniktech.maven.publish.JavaLibrary
2+
import com.vanniktech.maven.publish.JavadocJar
3+
14
plugins {
25
id("clkx-module")
6+
id("clkx-toolchain")
7+
id("clkx-testing")
8+
id("clkx-detekt")
9+
id("clkx-ktlint")
310
id("com.vanniktech.maven.publish")
411
}
12+
13+
mavenPublishing {
14+
configure(JavaLibrary(javadocJar = JavadocJar.Empty()))
15+
}
Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
11
plugins {
2+
`java-library`
23
kotlin("jvm")
3-
id("io.gitlab.arturbosch.detekt")
4-
id("org.jlleitschuh.gradle.ktlint")
5-
id("org.jetbrains.kotlinx.kover")
64
}
75

8-
kotlin { jvmToolchain(17) }
6+
group = "zone.clanker"
97

10-
tasks.withType<Test>().configureEach {
11-
useJUnitPlatform()
8+
dependencies {
9+
"implementation"(gradleApi())
1210
}
1311

14-
kover {
15-
reports {
16-
filters {
17-
excludes {
18-
// Exclude @TaskAction run() methods — trivial delegation to Cli.execAndPrint
19-
annotatedBy("org.gradle.api.tasks.TaskAction")
20-
// Exclude Settings plugin apply() — requires real Gradle Settings, tested via registerTasks
21-
classes("*\$SettingsPlugin", "*\$SettingsPlugin\$*")
22-
}
23-
}
24-
verify {
25-
rule {
26-
minBound(90)
27-
}
28-
}
29-
}
12+
tasks.withType<Test> {
13+
useJUnitPlatform()
3014
}
3115

32-
dependencies {
33-
testImplementation("io.kotest:kotest-runner-junit5:5.9.1")
34-
testImplementation("io.kotest:kotest-assertions-core:5.9.1")
16+
tasks.withType<PublishToMavenRepository>().configureEach {
17+
dependsOn(tasks.withType<Sign>())
3518
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import com.vanniktech.maven.publish.GradlePlugin
2+
import com.vanniktech.maven.publish.JavadocJar
3+
4+
plugins {
5+
id("com.vanniktech.maven.publish")
6+
}
7+
8+
mavenPublishing {
9+
configure(GradlePlugin(javadocJar = JavadocJar.Empty()))
10+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
plugins {
2+
`java-base`
3+
id("org.jetbrains.kotlinx.kover")
4+
}
5+
6+
val sourceSets = the<SourceSetContainer>()
7+
8+
dependencies {
9+
"testImplementation"("io.kotest:kotest-runner-junit5:5.9.1")
10+
"testImplementation"("io.kotest:kotest-assertions-core:5.9.1")
11+
"testImplementation"("io.kotest:kotest-framework-datatest:5.9.1")
12+
"testImplementation"(gradleTestKit())
13+
}
14+
15+
kover {
16+
reports {
17+
filters {
18+
excludes {
19+
// @TaskAction run() methods delegate to Cli.execAndPrint — untestable without real CLIs
20+
annotatedBy("org.gradle.api.tasks.TaskAction")
21+
// Settings plugin apply() requires real Gradle Settings — tested via registerTasks
22+
classes("*\$SettingsPlugin", "*\$SettingsPlugin\$*")
23+
}
24+
}
25+
verify {
26+
rule {
27+
minBound(90)
28+
}
29+
}
30+
}
31+
}
32+
33+
val slopTest by sourceSets.creating {
34+
compileClasspath += sourceSets["main"].output
35+
runtimeClasspath += sourceSets["main"].output
36+
}
37+
38+
configurations[slopTest.implementationConfigurationName].extendsFrom(configurations["testImplementation"])
39+
configurations[slopTest.runtimeOnlyConfigurationName].extendsFrom(configurations["testRuntimeOnly"])
40+
41+
dependencies {
42+
"slopTestImplementation"("com.lemonappdev:konsist:0.17.3")
43+
"slopTestImplementation"("io.kotest:kotest-runner-junit5:5.9.1")
44+
"slopTestImplementation"("io.kotest:kotest-assertions-core:5.9.1")
45+
}
46+
47+
val slopTask = tasks.register<Test>("slopTest") {
48+
description = "Run slop taste tests — architecture, naming, boundaries, style"
49+
group = "verification"
50+
testClassesDirs = slopTest.output.classesDirs
51+
classpath = slopTest.runtimeClasspath
52+
useJUnitPlatform()
53+
}
54+
55+
tasks.named("check") {
56+
dependsOn(slopTask)
57+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
`java-base`
3+
}
4+
5+
java {
6+
toolchain {
7+
languageVersion.set(JavaLanguageVersion.of(17))
8+
vendor.set(JvmVendorSpec.JETBRAINS)
9+
}
10+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package zone.clanker.gradle.conventions
2+
3+
import org.gradle.api.Plugin
4+
import org.gradle.api.initialization.Settings
5+
import org.gradle.api.initialization.resolve.RepositoriesMode
6+
7+
class ClkxSettingsPlugin : Plugin<Settings> {
8+
override fun apply(settings: Settings) {
9+
settings.pluginManager.apply("org.gradle.toolchains.foojay-resolver-convention")
10+
11+
@Suppress("UnstableApiUsage")
12+
settings.dependencyResolutionManagement {
13+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
14+
repositories {
15+
mavenCentral()
16+
gradlePluginPortal()
17+
}
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)