Skip to content

Commit

Permalink
added compile task
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Apr 13, 2024
1 parent 7912f75 commit edeea8d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package dev.datlag.sekret.gradle

import dev.datlag.sekret.gradle.common.createSekretExtension
import dev.datlag.sekret.gradle.common.kotlinProjectExtension
import dev.datlag.sekret.gradle.tasks.CopySekretNativeBinaryTask
import dev.datlag.sekret.gradle.tasks.CreateAndCopySekretNativeBinaryTask
import dev.datlag.sekret.gradle.tasks.GenerateSekretBuildScriptTask
import dev.datlag.sekret.gradle.tasks.GenerateSekretTask
import dev.datlag.sekret.gradle.tasks.*
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
Expand All @@ -22,6 +19,9 @@ open class SekretPlugin : Plugin<Project> {
project.tasks.maybeCreate(GenerateSekretBuildScriptTask.NAME, GenerateSekretBuildScriptTask::class)
project.tasks.maybeCreate(GenerateSekretTask.NAME, GenerateSekretTask::class)
project.tasks.maybeCreate(CopySekretNativeBinaryTask.NAME, CopySekretNativeBinaryTask::class)
project.tasks.maybeCreate(CreateSekretNativeBinaryTask.NAME, CreateSekretNativeBinaryTask::class).also {
it.setupDependingTasks()
}
project.tasks.maybeCreate(CreateAndCopySekretNativeBinaryTask.NAME, CreateAndCopySekretNativeBinaryTask::class).also {
it.setupDependingTasks()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.datlag.sekret.gradle.tasks

import dev.datlag.sekret.gradle.common.findMatchingTask
import dev.datlag.sekret.gradle.common.findMatchingTaskWithType
import org.gradle.api.DefaultTask
import org.gradle.api.Project

open class CreateSekretNativeBinaryTask : DefaultTask() {

init {
group = "sekret"
}

private val sekretProject: Project?
get() = runCatching {
project.findProject("sekret")
}.getOrNull()

fun setupDependingTasks() {
val assembleTask = sekretProject?.findMatchingTask("assemble")
val generateTask = project.findMatchingTaskWithType<GenerateSekretTask>(GenerateSekretTask.NAME)

if (assembleTask != null && generateTask != null) {
dependsOn(generateTask, assembleTask)
} else if (assembleTask != null) {
dependsOn(assembleTask)
} else if (generateTask != null) {
dependsOn(generateTask)
}
}

companion object {
internal const val NAME = "createSekretNativeBinary"
}
}

0 comments on commit edeea8d

Please sign in to comment.