From cef2d475e22dd3f0896d0636a70239b18fe4a7ab Mon Sep 17 00:00:00 2001 From: DatLag Date: Mon, 19 Aug 2024 13:06:51 +0200 Subject: [PATCH] improved task dependencies --- .../tasks/CreateAndCopySekretNativeBinaryTask.kt | 4 +++- .../gradle/tasks/CreateSekretNativeBinaryTask.kt | 4 +++- .../sekret/gradle/tasks/CreateSekretValueTask.kt | 14 +++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateAndCopySekretNativeBinaryTask.kt b/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateAndCopySekretNativeBinaryTask.kt index 84ad9d9..ba88099 100644 --- a/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateAndCopySekretNativeBinaryTask.kt +++ b/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateAndCopySekretNativeBinaryTask.kt @@ -26,7 +26,9 @@ open class CreateAndCopySekretNativeBinaryTask : DefaultTask() { val generateTask = project.findMatchingTaskWithType(GenerateSekretTask.NAME) val copyTask = project.findMatchingTaskWithType(CopySekretNativeBinaryTask.NAME) - generateTask?.let { mustRunAfter(it) } + generateTask?.let { + assembleTask?.dependsOn(it) ?: mustRunAfter(it) + } assembleTask?.let { dependsOn(it) } copyTask?.let { finalizedBy(it) } } diff --git a/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretNativeBinaryTask.kt b/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretNativeBinaryTask.kt index 02a1de3..902457a 100644 --- a/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretNativeBinaryTask.kt +++ b/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretNativeBinaryTask.kt @@ -26,7 +26,9 @@ open class CreateSekretNativeBinaryTask : DefaultTask() { val assembleTask = project.findProject("sekret")?.findMatchingTask("assemble") val generateTask = project.findMatchingTaskWithType(GenerateSekretTask.NAME) - generateTask?.let { mustRunAfter(it) } + generateTask?.let { + assembleTask?.dependsOn(it) ?: mustRunAfter(it) + } assembleTask?.let { dependsOn(assembleTask) } } } diff --git a/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretValueTask.kt b/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretValueTask.kt index 90590ff..bbc05c6 100644 --- a/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretValueTask.kt +++ b/sekret-gradle-plugin/src/main/java/dev/datlag/sekret/gradle/tasks/CreateSekretValueTask.kt @@ -26,10 +26,10 @@ open class CreateSekretValueTask : DefaultTask() { open val propertiesFile: RegularFileProperty = project.objects.fileProperty() @get:Input - open val propertyName: Property = project.objects.property(String::class.java) + open val key: Property = project.objects.property(String::class.java) @get:Input - open val propertyValue: Property = project.objects.property(String::class.java) + open val value: Property = project.objects.property(String::class.java) init { group = "sekret" @@ -42,12 +42,12 @@ open class CreateSekretValueTask : DefaultTask() { return } - val name = propertyName.orNull ?: throw IllegalArgumentException("Missing property 'key'") - val value = propertyValue.orNull ?: throw IllegalArgumentException("Missing property 'value'") + val name = key.orNull ?: throw IllegalArgumentException("Missing property 'key'") + val data = value.orNull ?: throw IllegalArgumentException("Missing property 'value'") val propFile = propertiesFile.asFile.orNull ?: throw IllegalStateException("No sekret properties file found.") val properties = Utils.propertiesFromFile(propFile) - properties[name] = value + properties[name] = data Utils.saveProperties(properties, propFile) } @@ -76,8 +76,8 @@ open class CreateSekretValueTask : DefaultTask() { fun apply(project: Project, extension: SekretPluginExtension = project.sekretExtension) { enabled.set(extension.properties.enabled) propertiesFile.set(propertiesFile(project, extension.properties)) - propertyName.set(project.findProperty("key")?.toString()?.ifBlank { null }) - propertyValue.set(project.findProperty("value")?.toString()?.ifBlank { null }) + key.set(project.findProperty("key")?.toString()?.ifBlank { null }) + value.set(project.findProperty("value")?.toString()?.ifBlank { null }) } companion object {