-
Notifications
You must be signed in to change notification settings - Fork 176
Add support for ktlint-plugins.properties version synchronization #1001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
34c4c63
1efebf8
b7b5454
de73ef6
e97a8bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| package org.jlleitschuh.gradle.ktlint | ||
|
|
||
| import org.assertj.core.api.Assertions.assertThat | ||
| import org.gradle.util.GradleVersion | ||
| import org.jlleitschuh.gradle.ktlint.testdsl.CommonTest | ||
| import org.jlleitschuh.gradle.ktlint.testdsl.GradleTestVersions | ||
| import org.jlleitschuh.gradle.ktlint.testdsl.build | ||
| import org.jlleitschuh.gradle.ktlint.testdsl.project | ||
|
|
||
| @GradleTestVersions | ||
| class KtlintPluginsPropertiesTest : AbstractPluginTest() { | ||
|
|
||
| @CommonTest | ||
| fun shouldUseVersionFromKtlintPluginsPropertiesFileWhenPresent(gradleVersion: GradleVersion) { | ||
| project(gradleVersion) { | ||
| // Create ktlint-plugins.properties file with version | ||
| projectPath.resolve(KTLINT_PLUGINS_PROPERTIES_FILE_NAME).writeText( | ||
| """ | ||
| ktlint-version=1.2.1 | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| withCleanSources() | ||
|
|
||
| buildGradle.appendText( | ||
| """ | ||
|
||
| tasks.register("printKtlintVersion") { | ||
| doLast { | ||
| println("Ktlint version: " + ktlint.version.get()) | ||
| } | ||
| } | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| build("printKtlintVersion") { | ||
| assertThat(output).contains("Ktlint version: 1.2.1") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @CommonTest | ||
| fun shouldUseDefaultVersionWhenKtlintPluginsPropertiesFileIsAbsent(gradleVersion: GradleVersion) { | ||
| project(gradleVersion) { | ||
| withCleanSources() | ||
|
|
||
| buildGradle.appendText( | ||
| """ | ||
|
||
| tasks.register("printKtlintVersion") { | ||
| doLast { | ||
| println("Ktlint version: " + ktlint.version.get()) | ||
| } | ||
| } | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| build("printKtlintVersion") { | ||
| assertThat(output).contains("Ktlint version: 1.5.0") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @CommonTest | ||
| fun shouldAllowExplicitVersionOverrideEvenWhenPropertiesFileExists(gradleVersion: GradleVersion) { | ||
| project(gradleVersion) { | ||
| // Create ktlint-plugins.properties file with version | ||
| projectPath.resolve(KTLINT_PLUGINS_PROPERTIES_FILE_NAME).writeText( | ||
| """ | ||
| ktlint-version=1.2.1 | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| withCleanSources() | ||
|
|
||
| buildGradle.appendText( | ||
| """ | ||
|
||
| ktlint { | ||
| version = "1.3.0" | ||
| } | ||
| tasks.register("printKtlintVersion") { | ||
| doLast { | ||
| println("Ktlint version: " + ktlint.version.get()) | ||
| } | ||
| } | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| build("printKtlintVersion") { | ||
| assertThat(output).contains("Ktlint version: 1.3.0") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @CommonTest | ||
| fun shouldUseDefaultVersionWhenKtlintVersionPropertyIsBlank(gradleVersion: GradleVersion) { | ||
| project(gradleVersion) { | ||
| // Create ktlint-plugins.properties file with blank version | ||
| projectPath.resolve(KTLINT_PLUGINS_PROPERTIES_FILE_NAME).writeText( | ||
| """ | ||
| ktlint-version= | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| withCleanSources() | ||
|
|
||
| buildGradle.appendText( | ||
| """ | ||
|
||
| tasks.register("printKtlintVersion") { | ||
| doLast { | ||
| println("Ktlint version: " + ktlint.version.get()) | ||
| } | ||
| } | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| build("printKtlintVersion") { | ||
| assertThat(output).contains("Ktlint version: 1.5.0") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @CommonTest | ||
| fun shouldUseDefaultVersionWhenPropertiesFileHasNoKtlintVersionProperty(gradleVersion: GradleVersion) { | ||
| project(gradleVersion) { | ||
| // Create ktlint-plugins.properties file without ktlint-version | ||
| projectPath.resolve(KTLINT_PLUGINS_PROPERTIES_FILE_NAME).writeText( | ||
| """ | ||
| some-other-property=value | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| withCleanSources() | ||
|
|
||
| buildGradle.appendText( | ||
| """ | ||
|
||
| tasks.register("printKtlintVersion") { | ||
| doLast { | ||
| println("Ktlint version: " + ktlint.version.get()) | ||
| } | ||
| } | ||
| """.trimIndent() | ||
| ) | ||
|
|
||
| build("printKtlintVersion") { | ||
| assertThat(output).contains("Ktlint version: 1.5.0") | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.