build: hook viewer build tasks to gradle
This commit is contained in:
parent
c0148fc483
commit
e0c0a9c136
@ -1,3 +1,4 @@
|
|||||||
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
|
||||||
@ -94,3 +95,30 @@ dependencies {
|
|||||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||||
implementation("com.google.android.material:material:1.9.0")
|
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.js")
|
||||||
|
}
|
||||||
|
|
||||||
|
val cleanStatic = tasks.register("cleanStatic", Delete::class) {
|
||||||
|
delete("src/main/assets/viewer", "src/debug/assets/viewer")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.preBuild {
|
||||||
|
dependsOn(processStatic)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.clean {
|
||||||
|
dependsOn(cleanStatic)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user