Skip to content

Commit

Permalink
Vite. Depend on kotlin compile task
Browse files Browse the repository at this point in the history
  • Loading branch information
porotkin committed Sep 2, 2024
1 parent 662f1d3 commit 7ce8577
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.turansky.kfc.gradle.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.kotlin.dsl.create

class ViteApplicationPlugin : Plugin<Project> {
Expand All @@ -12,7 +13,7 @@ class ViteApplicationPlugin : Plugin<Project> {
mode.set(ViteMode.PRODUCTION)
outputDirectory.convention(getProductionDistDirectory())

dependsOn(COMPILE_PRODUCTION)
dependOnCompile(COMPILE_PRODUCTION)
}

tasks.create<KotlinViteTask>(Vite.developmentTask) {
Expand All @@ -21,11 +22,19 @@ class ViteApplicationPlugin : Plugin<Project> {
mode.set(ViteMode.DEVELOPMENT)
outputDirectory.convention(getDevelopmentDistDirectory())

dependsOn(COMPILE_DEVELOPMENT)
dependOnCompile(COMPILE_DEVELOPMENT)
}

tasks.named("build") {
dependsOn(Vite.productionTask)
}
}

private fun Task.dependOnCompile(
taskName: String,
) {
val compile = project.tasks.named(taskName).get()
inputs.files(compile.outputs.files)
dependsOn(compile)
}
}

0 comments on commit 7ce8577

Please sign in to comment.