-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
a826dcd
commit 6046fb8
Showing
22 changed files
with
256 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{kt,kts}] | ||
indent_size = 4 | ||
ij_kotlin_packages_to_use_import_on_demand = unset | ||
ij_kotlin_name_count_to_use_star_import = 999 | ||
ij_kotlin_name_count_to_use_star_import_for_members = 999 | ||
ij_kotlin_allow_trailing_comma = false | ||
ij_kotlin_allow_trailing_comma_on_call_site = false | ||
ktlint_code_style=intellij_idea | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
11.6.1 | ||
12.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/GitHook.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.assertj.core.api | ||
|
||
import org.assertj.core.internal.Objects | ||
import org.gradle.testkit.runner.BuildTask | ||
import org.gradle.testkit.runner.TaskOutcome | ||
|
||
fun ObjectAssert<BuildTask?>.hasOutcome(outcome: TaskOutcome) { | ||
Objects.instance().assertNotNull(this.info, this.actual) | ||
Objects.instance().assertEqual(this.info, this.actual!!.outcome, outcome) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
plugin/src/test/kotlin/org/jlleitschuh/gradle/ktlint/android/KtlintPluginAndroidTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package org.jlleitschuh.gradle.ktlint.android | ||
|
||
import net.swiftzer.semver.SemVer | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.assertj.core.api.hasOutcome | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.gradle.util.GradleVersion | ||
import org.jlleitschuh.gradle.ktlint.AbstractPluginTest | ||
import org.jlleitschuh.gradle.ktlint.CHECK_PARENT_TASK_NAME | ||
import org.jlleitschuh.gradle.ktlint.testdsl.TestVersions | ||
import org.jlleitschuh.gradle.ktlint.testdsl.androidProjectSetup | ||
import org.jlleitschuh.gradle.ktlint.testdsl.build | ||
import org.jlleitschuh.gradle.ktlint.testdsl.project | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.EnumSource | ||
|
||
class KtlintPluginAndroidTest : AbstractPluginTest() { | ||
|
||
@ParameterizedTest | ||
@EnumSource(AndroidTestInput::class) | ||
fun `ktlint pass src java`(input: AndroidTestInput) { | ||
project( | ||
input.gradleVersion, | ||
projectSetup = androidProjectSetup(input.agpVersion, input.kotlinVersion, input.ktlintVersion) | ||
) { | ||
withCleanSources("src/main/java/CleanSource.kt") | ||
build(CHECK_PARENT_TASK_NAME) { | ||
assertThat(task(":$mainSourceSetCheckTaskName")).hasOutcome(TaskOutcome.SUCCESS) | ||
assertThat(task(":$kotlinScriptCheckTaskName")).hasOutcome(TaskOutcome.SUCCESS) | ||
assertThat(task(":$CHECK_PARENT_TASK_NAME")).hasOutcome(TaskOutcome.SUCCESS) | ||
} | ||
} | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(AndroidTestInput::class) | ||
fun `ktlint pass src kotlin`(input: AndroidTestInput) { | ||
project( | ||
input.gradleVersion, | ||
projectSetup = androidProjectSetup(input.agpVersion, input.kotlinVersion, input.ktlintVersion) | ||
) { | ||
withCleanSources("src/main/kotlin/CleanSource.kt") | ||
if (SemVer.parse(input.agpVersion) < SemVer(7)) { | ||
build(CHECK_PARENT_TASK_NAME) { | ||
assertThat(output).contains("In AGP <7 kotlin source directories are not auto-detected.") | ||
assertThat(task(":$mainSourceSetCheckTaskName")).hasOutcome(TaskOutcome.SKIPPED) | ||
assertThat(task(":$kotlinScriptCheckTaskName")).hasOutcome(TaskOutcome.SUCCESS) | ||
assertThat(task(":$CHECK_PARENT_TASK_NAME")).hasOutcome(TaskOutcome.SUCCESS) | ||
} | ||
} else { | ||
build(CHECK_PARENT_TASK_NAME) { | ||
assertThat(task(":$mainSourceSetCheckTaskName")).hasOutcome(TaskOutcome.SUCCESS) | ||
assertThat(task(":$kotlinScriptCheckTaskName")).hasOutcome(TaskOutcome.SUCCESS) | ||
assertThat(task(":$CHECK_PARENT_TASK_NAME")).hasOutcome(TaskOutcome.SUCCESS) | ||
} | ||
} | ||
} | ||
} | ||
|
||
enum class AndroidTestInput( | ||
val gradleVersion: GradleVersion, | ||
val agpVersion: String, | ||
val kotlinVersion: String, | ||
val ktlintVersion: String? = null | ||
) { | ||
MIN( | ||
GradleVersion.version(TestVersions.minSupportedGradleVersion), | ||
TestVersions.minAgpVersion, | ||
// AGP 4.1 requires kotlin 1.5.20 | ||
"1.5.20", | ||
// old AGP doesn't properly set variant info which ktlint >= 1 requires | ||
"0.47.1" | ||
), | ||
GRADLE_7_5_AGP_7_4( | ||
// AGP 7.4 requires Gradle 7.5 | ||
GradleVersion.version("7.5"), | ||
"7.4.2", | ||
// AGP 4.1 requires kotlin 1.5.20 | ||
"1.5.20", | ||
// old AGP doesn't properly set variant info which ktlint >= 1 requires | ||
"0.47.1" | ||
), | ||
MAX_GRADLE_MIN_AGP( | ||
GradleVersion.version(TestVersions.maxSupportedGradleVersion), | ||
TestVersions.minAgpVersion, | ||
// AGP 4.1 requires kotlin 1.5.20 | ||
"1.5.20" | ||
), | ||
MAX( | ||
GradleVersion.version(TestVersions.maxSupportedGradleVersion), | ||
TestVersions.maxAgpVersion, | ||
TestVersions.maxSupportedKotlinPluginVersion | ||
) | ||
} | ||
} |
Oops, something went wrong.