Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit a1369e9

Browse files
committed
Prepare version catalog accessor release v0.2.0 and fix Kotlin deprecations
1 parent e057a95 commit a1369e9

File tree

10 files changed

+46
-19
lines changed

10 files changed

+46
-19
lines changed
Lines changed: 1 addition & 1 deletion
Loading

docs/develop/badges.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ curl "https://img.shields.io/badge/Plugin_Development-→-orange.svg?style=flat"
8080
```
8181
- Gradle Version catalog accessor
8282
```bash
83-
curl "https://img.shields.io/badge/VersionCatalogAccessor-v0.1.1-orange.svg?style=flat" -s -o ../assets/images/badge-release-gradle-version-catalog-accessor.svg
83+
curl "https://img.shields.io/badge/VersionCatalogAccessor-v0.2.0-orange.svg?style=flat" -s -o ../assets/images/badge-release-gradle-version-catalog-accessor.svg
8484
```
8585

8686
### Other

plugin-development/gradle-test-util/gradle/libs-gradle-test-util.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ gradle = "8.0"
33
kotlin = "1.8.10"
44
test-jUnit5 = "5.9.2"
55
test-mockk = "1.13.4"
6-
plugin-kotlin-binaryCompatibility = "0.12.1"
6+
plugin-kotlin-binaryCompatibility = "0.13.0"
77
plugin-mavenPublish = "0.24.0"
88

99
[libraries]

plugin-development/version-catalog-accessor/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ This project adheres to [semantic versioning](http://semver.org/spec/v2.0.0.html
99

1010
## [Unreleased](https://github.com/bitfunk/gradle-plugins/releases/latest)
1111

12-
See [changeset](https://github.com/bitfunk/gradle-plugins/compare/[email protected])
12+
See [changeset](https://github.com/bitfunk/gradle-plugins/compare/[email protected])
13+
14+
## [0.2.0](https://github.com/bitfunk/gradle-plugins/releases/tag/[email protected])
15+
16+
See [changeset](https://github.com/bitfunk/gradle-plugins/compare/plugin-dev-version-catalog-accessor@[email protected])
1317

1418
### Bumped
1519

plugin-development/version-catalog-accessor/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ plugins {
2323
}
2424

2525
group = "eu.bitfunk.gradle.plugin.development.version.catalog.accessor"
26-
version = "0.1.1"
26+
version = "0.2.0"
2727

2828
gradlePlugin {
2929
plugins.create("gradlePluginVersionCatalog") {

plugin-development/version-catalog-accessor/src/main/kotlin/eu/bitfunk/gradle/plugin/development/version/catalog/accessor/intern/Generator.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ internal class Generator(
4242

4343
val file = FileSpec.builder(classPackageName, className + CLASS_NAME)
4444
.indent(" ")
45-
.addImport(classPackageName, "${accessorInterface.name}.${NAME_BUNDLES.capitalize()}")
46-
.addImport(classPackageName, "${accessorInterface.name}.${NAME_LIBRARIES.capitalize()}")
47-
.addImport(classPackageName, "${accessorInterface.name}.${NAME_PLUGINS.capitalize()}")
48-
.addImport(classPackageName, "${accessorInterface.name}.${NAME_VERSIONS.capitalize()}")
45+
.addImport(classPackageName, "${accessorInterface.name}.${NAME_BUNDLES.titleCase()}")
46+
.addImport(classPackageName, "${accessorInterface.name}.${NAME_LIBRARIES.titleCase()}")
47+
.addImport(classPackageName, "${accessorInterface.name}.${NAME_PLUGINS.titleCase()}")
48+
.addImport(classPackageName, "${accessorInterface.name}.${NAME_VERSIONS.titleCase()}")
4949
.addImport(
5050
VersionCatalogsExtension::class.java.packageName,
5151
VersionCatalogsExtension::class.java.simpleName
@@ -63,7 +63,7 @@ internal class Generator(
6363

6464
private fun generateClassName(): String {
6565
return baseName.split("-")
66-
.map { it.capitalize() }
66+
.map { it.titleCase() }
6767
.joinToString(separator = "") { it }
6868
}
6969

plugin-development/version-catalog-accessor/src/main/kotlin/eu/bitfunk/gradle/plugin/development/version/catalog/accessor/intern/GeneratorTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ internal class GeneratorTask(
7474

7575
private fun generateFileName(name: String): String {
7676
return name.split("-")
77-
.map { it.capitalize() }
77+
.map { it.titleCase() }
7878
.joinToString(separator = "") { it }
7979
}
8080

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* ISC License
3+
*
4+
* Copyright (c) 2023. Wolf-Martell Montwé (bitfunk)
5+
*
6+
* Permission to use, copy, modify, and/or distribute this software for any
7+
* purpose with or without fee is hereby granted, provided that the above
8+
* copyright notice and this permission notice appear in all copies.
9+
*
10+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12+
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16+
* PERFORMANCE OF THIS SOFTWARE.
17+
*/
18+
19+
package eu.bitfunk.gradle.plugin.development.version.catalog.accessor.intern
20+
21+
internal fun String.titleCase(): String = replaceFirstChar { char: Char -> if (char.isLowerCase()) char.titlecase() else char.toString() }
22+
23+
internal fun String.titleUncase(): String = replaceFirstChar { char: Char -> if (char.isLowerCase()) char.toString() else char.lowercase() }

plugin-development/version-catalog-accessor/src/main/kotlin/eu/bitfunk/gradle/plugin/development/version/catalog/accessor/intern/VersionCatalogAccessorClassGenerator.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ internal class VersionCatalogAccessorClassGenerator(
5757
.addModifiers(PRIVATE)
5858
.build()
5959
)
60-
.addSuperinterface(ClassName(packageName, Generator.NAME_LIBRARIES.capitalize()))
60+
.addSuperinterface(ClassName(packageName, Generator.NAME_LIBRARIES.titleCase()))
6161
.addProperty(
6262
PropertySpec.builder("versionCatalog", VersionCatalog::class.java)
6363
.getter(
6464
FunSpec.getterBuilder()
6565
.addStatement(
6666
"return %L",
6767
"project.extensions.getByType(VersionCatalogsExtension::class.java)\n" +
68-
" .named(\"${baseName.decapitalize()}\")"
68+
" .named(\"${baseName.titleUncase()}\")"
6969
)
7070
.build()
7171
)
@@ -79,7 +79,7 @@ internal class VersionCatalogAccessorClassGenerator(
7979
generateProperties(
8080
catalog.libraries::class,
8181
libraryNodes,
82-
Generator.NAME_LIBRARIES.capitalize()
82+
Generator.NAME_LIBRARIES.titleCase()
8383
)
8484
)
8585
.addFunction(generateCatalogFindFunction("findVersion"))
@@ -90,7 +90,7 @@ internal class VersionCatalogAccessorClassGenerator(
9090
}
9191

9292
private fun generateRootProperty(name: String, catalogEntry: CatalogEntry): PropertySpec {
93-
val className = ClassName(packageName, name.capitalize())
93+
val className = ClassName(packageName, name.titleCase())
9494
return PropertySpec.builder(name, className)
9595
.initializer("%L", generateRootImplementation(className, catalogEntry))
9696
.build()
@@ -115,7 +115,7 @@ internal class VersionCatalogAccessorClassGenerator(
115115

116116
for (node in nodes) {
117117
val property = if (node.isGroup() && node.isLeaf()) {
118-
val name = "$parentName.${node.name.capitalize()}"
118+
val name = "$parentName.${node.name.titleCase()}"
119119
generateNodeProperty(
120120
catalogType,
121121
node,
@@ -132,7 +132,7 @@ internal class VersionCatalogAccessorClassGenerator(
132132
parentName
133133
)
134134
} else {
135-
val name = "$parentName.${node.name.capitalize()}"
135+
val name = "$parentName.${node.name.titleCase()}"
136136
generateNodeProperty(
137137
catalogType,
138138
node,

plugin-development/version-catalog-accessor/src/main/kotlin/eu/bitfunk/gradle/plugin/development/version/catalog/accessor/intern/VersionCatalogAccessorInterfaceGenerator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal class VersionCatalogAccessorInterfaceGenerator(
6060
)
6161
}
6262

63-
return TypeSpec.interfaceBuilder(name.capitalize())
63+
return TypeSpec.interfaceBuilder(name.titleCase())
6464
.also { if (kClass != null) it.addSuperinterface(kClass) }
6565
.addProperties(generateInterfaceProperties(nodes))
6666
.addTypes(interfaces)
@@ -81,7 +81,7 @@ internal class VersionCatalogAccessorInterfaceGenerator(
8181
} else {
8282
generateInterfaceNodeProperty(
8383
node,
84-
ClassName("", node.name.capitalize())
84+
ClassName("", node.name.titleCase())
8585
)
8686
}
8787

0 commit comments

Comments
 (0)