Skip to content

Commit

Permalink
build: hook viewer build tasks to gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
octocorvus committed Aug 3, 2023
1 parent e459136 commit f05e7dc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.apache.tools.ant.taskdefs.condition.Os
import java.util.Properties
import java.io.FileInputStream

Expand Down Expand Up @@ -94,3 +95,30 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.9.0")
}

fun getCommand(command: String, winExt: String = "cmd"): String {
return if (Os.isFamily(Os.FAMILY_WINDOWS)) "$command.$winExt" else command
}

val npmSetup = tasks.register("npmSetup", Exec::class) {
workingDir = rootDir
commandLine(getCommand("npm"), "ci", "--ignore-scripts")
}

val processStatic = tasks.register("processStatic", Exec::class) {
workingDir = rootDir
dependsOn(npmSetup)
commandLine(getCommand("node", "exe"), "process_static.mjs")
}

val cleanStatic = tasks.register("cleanStatic", Delete::class) {
delete("src/main/assets/viewer", "src/debug/assets/viewer")
}

tasks.preBuild {
dependsOn(processStatic)
}

tasks.clean {
dependsOn(cleanStatic)
}

0 comments on commit f05e7dc

Please sign in to comment.