Skip to content

Commit 2a10370

Browse files
committed
collapse remaining adapter source sets into main
since we now only support ktlint 1.0+ we no longer need adapter source sets for older versions, so the adapter source sets for 1.0+ can be merged into main in order to simplify the build update tests to run against latest gradle and kotlin releases
1 parent ac51bdc commit 2a10370

File tree

21 files changed

+18
-81
lines changed

21 files changed

+18
-81
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
- Collapse sourcesets to simply build [#964](https://github.com/JLLeitschuh/ktlint-gradle/pull/964)
11+
1012
## [13.1.0] - 2025-08-21
1113

1214
- Gradle 9 Support [#937](https://github.com/JLLeitschuh/ktlint-gradle/pull/937)

plugin/build.gradle.kts

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import com.github.breadmoirai.githubreleaseplugin.GithubReleaseTask
22
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
33
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
4-
import com.gradle.enterprise.gradleplugin.testretry.retry
54
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
65
import org.gradle.api.tasks.testing.logging.TestLogEvent
76
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
@@ -63,61 +62,15 @@ configurations {
6362
configurations["compileOnly"].extendsFrom(shadowImplementation)
6463
configurations["testImplementation"].extendsFrom(shadowImplementation)
6564

66-
sourceSets {
67-
val adapter by creating {
68-
}
69-
70-
val adapter100 by creating {
71-
compileClasspath += adapter.output
72-
}
73-
val adapters = listOf(
74-
adapter,
75-
adapter100
76-
)
77-
val main by getting {
78-
kotlin {
79-
compileClasspath = adapters.map { it.output }.fold(compileClasspath) { a, b -> a + b }
80-
runtimeClasspath = adapters.map { it.output }.fold(runtimeClasspath) { a, b -> a + b }
81-
}
82-
}
83-
84-
val test by getting {
85-
kotlin {
86-
compileClasspath = adapters.map { it.output }.fold(compileClasspath) { a, b -> a + b }
87-
runtimeClasspath = adapters.map { it.output }.fold(runtimeClasspath) { a, b -> a + b }
88-
}
89-
}
90-
}
91-
92-
val adapterSources = listOf(
93-
sourceSets.named("adapter"),
94-
sourceSets.named("adapter100")
95-
)
96-
97-
tasks.named<Jar>("shadowJar").configure {
98-
this.from(adapterSources.map { sourceSet -> sourceSet.map { it.output.classesDirs } })
99-
manifest {
100-
attributes(
101-
"Implementation-Title" to project.name,
102-
"Implementation-Version" to project.version,
103-
"Implementation-Vendor" to project.group,
104-
"Implementation-Vendor-Id" to project.group
105-
)
106-
}
107-
}
108-
10965
dependencies {
110-
add("adapterImplementation", libs.commons.io)
111-
add("adapterImplementation", libs.semver)
112-
113-
add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-cli-reporter-core:1.0.0")
114-
add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-rule-engine:1.0.0")
115-
add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-ruleset-standard:1.0.0")
116-
add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-cli-reporter-baseline:1.0.0")
117-
66+
compileOnly("com.pinterest.ktlint:ktlint-cli-reporter-core:1.0.0")
67+
compileOnly("com.pinterest.ktlint:ktlint-rule-engine:1.0.0")
68+
compileOnly("com.pinterest.ktlint:ktlint-ruleset-standard:1.0.0")
69+
compileOnly("com.pinterest.ktlint:ktlint-cli-reporter-baseline:1.0.0")
11870
compileOnly(libs.kotlin.gradle.plugin)
11971
compileOnly(libs.android.gradle.plugin)
12072
compileOnly(kotlin("stdlib-jdk8"))
73+
12174
shadowImplementation(libs.semver)
12275
shadowImplementation(libs.jgit)
12376
shadowImplementation(libs.commons.io)
@@ -131,18 +84,6 @@ dependencies {
13184
testImplementation(libs.archunit.junit5)
13285
}
13386

134-
kotlin {
135-
// set up friend paths so that we can use internal classes across source sets
136-
target.compilations.forEach {
137-
if (it.name.startsWith("adapter")) {
138-
if (it.name != "adapter") {
139-
it.associateWith(target.compilations.getByName("adapter"))
140-
}
141-
target.compilations.getByName("main").associateWith(it)
142-
}
143-
}
144-
}
145-
14687
tasks.withType<Test> {
14788
dependsOn("publishToMavenLocal")
14889
useJUnitPlatform()
@@ -162,7 +103,7 @@ tasks.withType<Test> {
162103
showStackTraces = true
163104
}
164105

165-
retry {
106+
develocity.testRetry {
166107
val isCiServer = System.getenv().containsKey("CI")
167108
if (isCiServer) {
168109
maxRetries.set(2)
@@ -179,6 +120,14 @@ tasks.withType<Test> {
179120

180121
val relocateShadowJar = tasks.register<ConfigureShadowRelocation>("relocateShadowJar")
181122
val shadowJarTask = tasks.named<ShadowJar>("shadowJar") {
123+
manifest {
124+
attributes(
125+
"Implementation-Title" to project.name,
126+
"Implementation-Version" to project.version,
127+
"Implementation-Vendor" to project.group,
128+
"Implementation-Vendor-Id" to project.group
129+
)
130+
}
182131
// Enable package relocation in resulting shadow jar
183132
relocateShadowJar.get().apply {
184133
prefix = "$pluginGroup.shadow"

plugin/src/adapter/kotlin/org/jlleitschuh/gradle/ktlint/worker/BaselineLoader.kt

Lines changed: 0 additions & 5 deletions
This file was deleted.

plugin/src/adapter100/kotlin/org/jlleitschuh/gradle/ktlint/worker/BaselineLoader49.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)