Skip to content

Commit

Permalink
added lazy target detection
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Dec 1, 2024
1 parent 12acfc1 commit 3138d51
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.maybeCreate
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension
import java.util.*

open class SekretPlugin : Plugin<Project> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ internal val Project.targetsMapped: Set<Target>
val allFlatten = listOf(
usedTargets.map { it.targetName },
usedTargets.map { it.name },
this.sourceSets.map { it.name }.also {
println("Used sourceSets: $it")
},
this.sourceSets.map { it.name },
when (this) {
is KotlinJvmProjectExtension -> listOf("jvm")
is KotlinAndroidProjectExtension -> listOf("android")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import dev.datlag.sekret.gradle.*
import dev.datlag.sekret.gradle.Target
import dev.datlag.sekret.gradle.common.canWriteSafely
import dev.datlag.sekret.gradle.common.existsSafely
import dev.datlag.sekret.gradle.common.sekretExtension
import dev.datlag.sekret.gradle.common.targetsMapped
import dev.datlag.sekret.gradle.extension.PropertiesExtension
import org.gradle.api.Project
import java.io.File

object BuildFileGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ open class GenerateSekretBuildScriptTask : DefaultTask() {
return
}
BuildFileGenerator.generate(
targets = Target.addDependingTargets(targets.get()),
targets = Target.addDependingTargets(
listOf(targets.get(), project.targetsMapped).flatten()
),
packageName = packageName.getOrElse(PropertiesExtension.sekretPackageName),
outputDir = ModuleGenerator.createBase(outputDir),
overwrite = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ open class GenerateSekretTask : DefaultTask() {
}

val sekretDir = ModuleGenerator.createBase(outputDir)
val requiredTargets = Target.addDependingTargets(targets.get())
val requiredTargets = Target.addDependingTargets(
listOf(targets.get(), project.targetsMapped).flatten()
).also {
println("Used targets for generating: ${it.map { t -> t.name }.joinToString(", ")}")
}
BuildFileGenerator.generate(
targets = requiredTargets,
packageName = packageName.getOrElse(PropertiesExtension.sekretPackageName),
Expand Down

0 comments on commit 3138d51

Please sign in to comment.