Skip to content

Commit 977af89

Browse files
wakingrufusJLLeitschuh
authored andcommitted
fix detection of android kotlin source directories in AGP >= 7
increase maximum gradle version to 8.5 increase maximum ktlint version to 1.1.0 increase maximum kotlin version to 1.9.21 fix lint failures fixes #702 based on work in #703 fix bashisms by manually specifying correct version of libdistro-info-perl
1 parent a826dcd commit 977af89

File tree

24 files changed

+309
-68
lines changed

24 files changed

+309
-68
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ indent_size = 4
1010
ij_kotlin_packages_to_use_import_on_demand = unset
1111
ij_kotlin_name_count_to_use_star_import = 999
1212
ij_kotlin_name_count_to_use_star_import_for_members = 999
13+
ktlint_code_style=intellij_idea
1314

1415
[*.{yml,yaml}]
1516
indent_size = 2

.github/workflows/build-and-check.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ jobs:
101101
with:
102102
java-version: 11
103103
distribution: 'zulu'
104+
- name: update apt
105+
run: sudo apt update
104106
- name: Install lintian
105107
run: sudo apt install -qq lintian=2.114.0ubuntu1.3
108+
- name: Install libdistro
109+
run: sudo apt install -qq libdistro-info-perl
106110
- name: Install checkbashisms
107111
run: sudo apt-get install -qq devscripts
108112
- name: Restore Gradle caches

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+
- fix detection of android kotlin source directories in AGP >= 7 [#733](https://github.com/JLLeitschuh/ktlint-gradle/pull/733)
11+
1012
## [12.0.3] - 2023-12-11
1113

1214
- fix: apply configuration for source sets and targets that are added after the plugin is

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Minimal supported [Kotlin](https://kotlinlang.org) version: `1.4`
7070

7171
Minimal supported [ktlint](https://github.com/pinterest/ktlint) version: `0.47.1`
7272

73+
Minimal supported [Android Gradle plugin](https://developer.android.com/build) version: `4.1.0`
74+
7375
### Ktlint plugin
7476

7577
#### Simple setup

plugin/.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
8+
[*.{kt,kts}]
9+
indent_size = 4
10+
ij_kotlin_packages_to_use_import_on_demand = unset
11+
ij_kotlin_name_count_to_use_star_import = 999
12+
ij_kotlin_name_count_to_use_star_import_for_members = 999
13+
ij_kotlin_allow_trailing_comma = false
14+
ij_kotlin_allow_trailing_comma_on_call_site = false
15+
ktlint_code_style=intellij_idea
16+
17+
[*.{yml,yaml}]
18+
indent_size = 2

plugin/VERSION_LATEST_RELEASE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11.6.1
1+
12.0.3

plugin/build.gradle.kts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ java {
3030
}
3131
}
3232

33+
ktlint {
34+
version = "1.1.0"
35+
}
36+
3337
tasks.withType<KotlinCompile> {
3438
kotlinOptions {
3539
// target 1.4 as ktlint 0.49 requires it for inline classes
@@ -56,6 +60,7 @@ configurations {
5660
}
5761
configurations["compileOnly"].extendsFrom(shadowImplementation)
5862
configurations["testImplementation"].extendsFrom(shadowImplementation)
63+
5964
sourceSets {
6065
val adapter by creating {
6166
}
@@ -88,13 +93,15 @@ sourceSets {
8893
runtimeClasspath = adapters.map { it.output }.fold(runtimeClasspath) { a, b -> a + b }
8994
}
9095
}
96+
9197
val test by getting {
9298
kotlin {
9399
compileClasspath = adapters.map { it.output }.fold(compileClasspath) { a, b -> a + b }
94100
runtimeClasspath = adapters.map { it.output }.fold(runtimeClasspath) { a, b -> a + b }
95101
}
96102
}
97103
}
104+
98105
val adapterSources = listOf(
99106
sourceSets.named("adapter"),
100107
sourceSets.named("adapter47"),
@@ -140,12 +147,6 @@ dependencies {
140147
// Explicitly added for shadow plugin to relocate implementation as well
141148
shadowImplementation(libs.slf4j.nop)
142149

143-
/*
144-
* Do not depend upon the gradle script kotlin plugin API. IE: gradleScriptKotlinApi()
145-
* It's currently in flux and has binary breaking changes in gradle 4.0
146-
* https://github.com/JLLeitschuh/ktlint-gradle/issues/9
147-
*/
148-
149150
testImplementation(libs.junit.jupiter)
150151
testImplementation(libs.assertj.core)
151152
testImplementation(libs.kotlin.reflect)
@@ -165,12 +166,8 @@ kotlin {
165166
}
166167
}
167168

168-
// Test tasks loods plugin from local maven repository
169-
tasks.named<Test>("test") {
170-
dependsOn("publishToMavenLocal")
171-
}
172-
173169
tasks.withType<Test> {
170+
dependsOn("publishToMavenLocal")
174171
useJUnitPlatform()
175172
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
176173
doFirst {
@@ -195,6 +192,12 @@ tasks.withType<Test> {
195192
maxFailures.set(10)
196193
}
197194
}
195+
196+
javaLauncher.set(
197+
javaToolchains.launcherFor {
198+
languageVersion = JavaLanguageVersion.of(JavaVersion.current().majorVersion)
199+
}
200+
)
198201
}
199202

200203
val relocateShadowJar = tasks.register<ConfigureShadowRelocation>("relocateShadowJar")
@@ -273,7 +276,9 @@ fun setupPublishingEnvironment() {
273276

274277
if (System.getProperty(keyProperty) == null || System.getProperty(secretProperty) == null) {
275278
logger
276-
.info("`$keyProperty` or `$secretProperty` were not set. Attempting to configure from environment variables")
279+
.info(
280+
"`$keyProperty` or `$secretProperty` were not set. Attempting to configure from environment variables"
281+
)
277282

278283
val key: String? = System.getenv(keyEnvironmentVariable)
279284
val secret: String? = System.getenv(secretEnvironmentVariable)

plugin/src/adapter/kotlin/org/jlleitschuh/gradle/ktlint/reporter/ReportersLoaderAdapter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ interface ReportersLoaderAdapter<
1212
R,
1313
RP : Serializable,
1414
GR : GenericReporter<R>,
15-
GRP : GenericReporterProvider<GR>> {
15+
GRP : GenericReporterProvider<GR>
16+
> {
1617
fun loadAllReporterProviders(): List<ReporterProviderWrapper<RP>>
1718
fun filterEnabledBuiltInProviders(
1819
enabledReporters: Set<ReporterType>,

plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("ConstPropertyName")
2+
13
package org.jlleitschuh.gradle.ktlint
24

35
import org.eclipse.jgit.lib.RepositoryBuilder

plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/KtlintPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ open class KtlintPlugin : Plugin<Project> {
2929
private fun PluginHolder.addKtLintTasksToKotlinPlugin() {
3030
target.plugins.withId("kotlin", applyKtLint())
3131
target.plugins.withId("org.jetbrains.kotlin.js", applyKtLint())
32-
target.plugins.withId("kotlin-android", applyKtLintToAndroid())
32+
target.plugins.withId("org.jetbrains.kotlin.android", applyKtLintToAndroid())
3333
target.plugins.withId(
3434
"org.jetbrains.kotlin.multiplatform",
3535
applyKtlintMultiplatform()

0 commit comments

Comments
 (0)