Skip to content

Commit

Permalink
improved task dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Aug 19, 2024
1 parent 1391429 commit cef2d47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ open class CreateAndCopySekretNativeBinaryTask : DefaultTask() {
val generateTask = project.findMatchingTaskWithType<GenerateSekretTask>(GenerateSekretTask.NAME)
val copyTask = project.findMatchingTaskWithType<CopySekretNativeBinaryTask>(CopySekretNativeBinaryTask.NAME)

generateTask?.let { mustRunAfter(it) }
generateTask?.let {
assembleTask?.dependsOn(it) ?: mustRunAfter(it)
}
assembleTask?.let { dependsOn(it) }
copyTask?.let { finalizedBy(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ open class CreateSekretNativeBinaryTask : DefaultTask() {
val assembleTask = project.findProject("sekret")?.findMatchingTask("assemble")
val generateTask = project.findMatchingTaskWithType<GenerateSekretTask>(GenerateSekretTask.NAME)

generateTask?.let { mustRunAfter(it) }
generateTask?.let {
assembleTask?.dependsOn(it) ?: mustRunAfter(it)
}
assembleTask?.let { dependsOn(assembleTask) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ open class CreateSekretValueTask : DefaultTask() {
open val propertiesFile: RegularFileProperty = project.objects.fileProperty()

@get:Input
open val propertyName: Property<String> = project.objects.property(String::class.java)
open val key: Property<String> = project.objects.property(String::class.java)

@get:Input
open val propertyValue: Property<String> = project.objects.property(String::class.java)
open val value: Property<String> = project.objects.property(String::class.java)

init {
group = "sekret"
Expand All @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit cef2d47

Please sign in to comment.