From 5efea57ce72689ee9aed3810a2d2569e2b6002c7 Mon Sep 17 00:00:00 2001 From: Jaroslaw Pietraszek Date: Mon, 17 Apr 2023 17:22:18 +0200 Subject: [PATCH 1/2] Replace backslashes with forwad slashes in paths --- .../main/kotlin/io/wttech/gradle/config/prop/StringProp.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt b/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt index cba7921..fe5d925 100644 --- a/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt +++ b/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt @@ -39,10 +39,13 @@ class StringProp(group: Group, name: String) : Prop(group, name) { fun password() = valueTypePassword() + fun path() = valueTypePath() + val valueType = project.objects.property(ValueType::class.java).convention(ValueType.STRING) enum class ValueType { STRING, + PATH, PASSWORD, INT, DOUBLE, @@ -50,6 +53,7 @@ class StringProp(group: Group, name: String) : Prop(group, name) { } fun valueTypeString() { valueType.set(ValueType.STRING) } + fun valueTypePath() { valueType.set(ValueType.PATH) } fun valueTypePassword() { valueType.set(ValueType.PASSWORD) } fun valueTypeInt() { valueType.set(ValueType.INT) } fun valueTypeDouble() { valueType.set(ValueType.DOUBLE) } @@ -66,6 +70,7 @@ class StringProp(group: Group, name: String) : Prop(group, name) { private var valueSaved: (String?) -> Any? = { v -> when (valueType.get()) { + ValueType.PATH -> v?.let { v.replace("\\", "/")} ValueType.BOOL -> v?.toBoolean() ValueType.INT -> v?.toInt() ValueType.DOUBLE -> v?.toDouble() @@ -116,6 +121,7 @@ class StringProp(group: Group, name: String) : Prop(group, name) { init { when { // name-based smart defaults + listOf("path", "directory", "URL").any { name.endsWith(it, true) } -> path() listOf("token", "password", "key").any { name.endsWith(it, true) } -> password() listOf("enabled", "disabled").any { name.endsWith(it, true) } -> checkbox() } From d0b01fb05796fc8e0bfe6384103d445235a3dc03 Mon Sep 17 00:00:00 2001 From: Jaroslaw Pietraszek Date: Tue, 18 Apr 2023 10:15:46 +0200 Subject: [PATCH 2/2] Fix missing whitespace (detekt error) --- .../src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt b/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt index fe5d925..eb990a9 100644 --- a/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt +++ b/plugin/src/main/kotlin/io/wttech/gradle/config/prop/StringProp.kt @@ -70,7 +70,7 @@ class StringProp(group: Group, name: String) : Prop(group, name) { private var valueSaved: (String?) -> Any? = { v -> when (valueType.get()) { - ValueType.PATH -> v?.let { v.replace("\\", "/")} + ValueType.PATH -> v?.let { v.replace("\\", "/") } ValueType.BOOL -> v?.toBoolean() ValueType.INT -> v?.toInt() ValueType.DOUBLE -> v?.toDouble()