Skip to content

Commit

Permalink
Lazy. Initial plugin implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed Sep 12, 2024
1 parent 5ea25c0 commit 2e95e84
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ package seskar.gradle.plugin
class LazyConfiguration(
val compileTask: String,
val syncTask: String,
val generateTask: String,
) {
companion object {
val PRODUCTION = LazyConfiguration(
private val PRODUCTION = LazyConfiguration(
compileTask = "compileProductionExecutableKotlinJs",
syncTask = "jsProductionExecutableCompileSync",
generateTask = "jsProductionGenerateLazyModules",
)

val DEVELOPMENT = LazyConfiguration(
private val DEVELOPMENT = LazyConfiguration(
compileTask = "compileDevelopmentExecutableKotlinJs",
syncTask = "jsDevelopmentExecutableCompileSync",
generateTask = "jsDevelopmentGenerateLazyModules",
)

val ALL: List<LazyConfiguration> = listOf(
PRODUCTION,
DEVELOPMENT,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,30 @@ package seskar.gradle.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.Sync
import org.gradle.kotlin.dsl.create

private const val SESKAR_TASK_GROUP = "seskar"

internal class SeskarLazyPlugin : Plugin<Project> {
override fun apply(project: Project) {
// TBD
override fun apply(project: Project): Unit = with(project) {
plugins.withId("io.github.turansky.kfc.application") {
for (configuration in LazyConfiguration.ALL) {
val generateTask = tasks.create<Sync>(configuration.generateTask) {
group = SESKAR_TASK_GROUP

from(tasks.named(configuration.compileTask)) {
include("**/*__lazy__component.mjs")
includeEmptyDirs = false
}

into(temporaryDir)
}

tasks.named(configuration.syncTask) {
dependsOn(generateTask)
}
}
}
}
}

0 comments on commit 2e95e84

Please sign in to comment.