File tree Expand file tree Collapse file tree 3 files changed +11
-16
lines changed
main/kotlin/org/jlleitschuh/gradle/ktlint
test/kotlin/org/jlleitschuh/gradle/ktlint Expand file tree Collapse file tree 3 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77
88## [ Unreleased]
99
10+ ### Added
11+
12+ - Add support for reading ktlint version from ` ktlint-plugins.properties ` file [ #TBD] ( https://github.com/JLLeitschuh/ktlint-gradle/pull/TBD )
13+ - Enables automatic synchronization of ktlint version between IntelliJ plugin and Gradle builds
14+ - When ` ktlint-plugins.properties ` exists in project root with ` ktlint-version ` property, that version is used as default
15+ - Explicit version configuration in build script still takes precedence
16+
1017## [ 14.0.1] - 2025-11-10
1118
1219- Update build to work with gradle 9.1 and Java 25 [ #962 ] ( https://github.com/JLLeitschuh/ktlint-gradle/pull/962 )
Original file line number Diff line number Diff line change @@ -49,17 +49,10 @@ internal fun readKtlintVersionFromPropertiesFile(projectDir: Path): String? {
4949 return null
5050 }
5151
52- return propertiesFile.toFile().useLines { lines ->
53- lines
54- .filter { it.contains(" =" ) }
55- .map {
56- val key = it.substringBefore(" =" ).trim()
57- val value = it.substringAfter(' =' ).trim()
58- key to value
59- }
60- .firstOrNull { it.first == KTLINT_PLUGINS_VERSION_PROPERTY }
61- ?.second
62- ?.takeIf { it.isNotBlank() }
52+ return propertiesFile.toFile().inputStream().use { input ->
53+ val properties = java.util.Properties ()
54+ properties.load(input)
55+ properties.getProperty(KTLINT_PLUGINS_VERSION_PROPERTY )?.takeIf { it.isNotBlank() }
6356 }
6457}
6558
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ class KtlintPluginsPropertiesTest : AbstractPluginTest() {
2424
2525 buildGradle.appendText(
2626 """
27-
2827 tasks.register("printKtlintVersion") {
2928 doLast {
3029 println("Ktlint version: " + ktlint.version.get())
@@ -46,7 +45,6 @@ class KtlintPluginsPropertiesTest : AbstractPluginTest() {
4645
4746 buildGradle.appendText(
4847 """
49-
5048 tasks.register("printKtlintVersion") {
5149 doLast {
5250 println("Ktlint version: " + ktlint.version.get())
@@ -75,7 +73,6 @@ class KtlintPluginsPropertiesTest : AbstractPluginTest() {
7573
7674 buildGradle.appendText(
7775 """
78-
7976 ktlint {
8077 version = "1.3.0"
8178 }
@@ -108,7 +105,6 @@ class KtlintPluginsPropertiesTest : AbstractPluginTest() {
108105
109106 buildGradle.appendText(
110107 """
111-
112108 tasks.register("printKtlintVersion") {
113109 doLast {
114110 println("Ktlint version: " + ktlint.version.get())
@@ -137,7 +133,6 @@ class KtlintPluginsPropertiesTest : AbstractPluginTest() {
137133
138134 buildGradle.appendText(
139135 """
140-
141136 tasks.register("printKtlintVersion") {
142137 doLast {
143138 println("Ktlint version: " + ktlint.version.get())
You can’t perform that action at this time.
0 commit comments