101 lines
1.9 KiB
Plaintext
101 lines
1.9 KiB
Plaintext
val typescriptRoot = File(rootDir.absolutePath, "src/main/ts")
|
|
|
|
extra.set("typescriptRoot", typescriptRoot)
|
|
|
|
val typescriptOut = File(typescriptRoot, "build/ts")
|
|
|
|
val nodeModules = File(typescriptRoot, "node_modules")
|
|
|
|
val typescriptDependencies = File(typescriptRoot, "build/dependencies")
|
|
|
|
configurations {
|
|
create("typescript") {
|
|
isTransitive = false
|
|
}
|
|
}
|
|
|
|
tasks.register<Sync>("extractTypescriptDependencies") {
|
|
group = "typescript"
|
|
|
|
dependsOn(configurations["typescript"])
|
|
|
|
from(Callable {
|
|
configurations["typescript"].map {
|
|
zipTree(it).matching {
|
|
exclude("META-INF", "META-INF/**")
|
|
}
|
|
}
|
|
})
|
|
|
|
into(typescriptDependencies)
|
|
}
|
|
|
|
tasks.register<Exec>("npmInstall") {
|
|
group = "typescript"
|
|
|
|
inputs.file(File(typescriptRoot, "package.json"))
|
|
outputs.dir(nodeModules)
|
|
|
|
workingDir(typescriptRoot)
|
|
|
|
executable("npm")
|
|
|
|
args("install")
|
|
|
|
doFirst {
|
|
project.delete {
|
|
delete(nodeModules)
|
|
}
|
|
}
|
|
|
|
dependsOn(tasks["extractTypescriptDependencies"])
|
|
}
|
|
|
|
tasks.register<Exec>("typescript") {
|
|
group = "typescript"
|
|
|
|
inputs.dir(typescriptRoot)
|
|
outputs.dirs(typescriptOut)
|
|
|
|
workingDir(typescriptRoot)
|
|
|
|
executable("npm")
|
|
|
|
args("run", "build")
|
|
|
|
doFirst {
|
|
project.delete {
|
|
delete(typescriptOut)
|
|
}
|
|
}
|
|
|
|
dependsOn(tasks["npmInstall"])
|
|
}
|
|
|
|
tasks.register<Jar>("apiJar") {
|
|
group = "typescript"
|
|
|
|
val dtsOut = File(typescriptRoot, "build/dts")
|
|
|
|
into("/types") {
|
|
from(File(typescriptRoot, "types"))
|
|
}
|
|
into("/src") {
|
|
from(dtsOut)
|
|
}
|
|
|
|
archiveClassifier.set("api")
|
|
|
|
dependsOn(tasks["typescript"])
|
|
}
|
|
artifacts {
|
|
add("archives", tasks["apiJar"])
|
|
}
|
|
|
|
tasks.named<Copy>("processResources") {
|
|
dependsOn(tasks["typescript"])
|
|
|
|
from(typescriptOut.absolutePath) {
|
|
into("scriptcraft")
|
|
}
|
|
} |