2020-04-29 18:56:51 +00:00
|
|
|
def typescriptRoot = 'src/main/ts'
|
|
|
|
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
|
|
|
|
|
2020-05-24 00:54:20 +00:00
|
|
|
def typescriptOut = new File(typescriptRootFile, 'build/ts')
|
2020-04-29 18:56:51 +00:00
|
|
|
|
2020-04-30 00:32:07 +00:00
|
|
|
def nodeModules = new File(typescriptRootFile, 'node_modules')
|
2020-04-29 23:41:08 +00:00
|
|
|
|
2020-05-24 18:09:25 +00:00
|
|
|
task npmInstall(group: 'typescript', type: Exec) {
|
2020-04-29 23:41:08 +00:00
|
|
|
inputs.file new File(typescriptRootFile, 'package.json')
|
|
|
|
outputs.dir nodeModules
|
|
|
|
|
|
|
|
workingDir typescriptRootFile
|
|
|
|
|
|
|
|
executable 'npm'
|
|
|
|
|
|
|
|
args 'install'
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
project.delete {
|
|
|
|
delete nodeModules
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-24 00:54:20 +00:00
|
|
|
def typescriptDependencies = new File(typescriptRootFile, 'build/dependencies')
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
typescript {
|
|
|
|
transitive false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-24 18:09:25 +00:00
|
|
|
task extractTypescriptDependencies(type: Sync, group: 'typescript') {
|
|
|
|
dependsOn configurations.typescript
|
|
|
|
|
|
|
|
from {
|
|
|
|
configurations.typescript.collect {
|
|
|
|
zipTree(it).matching {
|
|
|
|
exclude 'META-INF', 'META-INF/**'
|
2020-05-24 00:54:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-24 18:09:25 +00:00
|
|
|
|
|
|
|
into typescriptDependencies
|
2020-05-24 00:54:20 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 18:56:51 +00:00
|
|
|
task typescript(group: 'typescript', type: Exec) {
|
|
|
|
inputs.dir typescriptRootFile
|
|
|
|
outputs.dirs typescriptOut
|
|
|
|
|
|
|
|
workingDir typescriptRootFile
|
|
|
|
|
|
|
|
executable 'npm'
|
|
|
|
|
|
|
|
args 'run', 'build'
|
|
|
|
|
|
|
|
doFirst {
|
|
|
|
project.delete {
|
|
|
|
delete typescriptOut
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-24 18:09:25 +00:00
|
|
|
typescript.dependsOn npmInstall
|
2020-05-24 00:54:20 +00:00
|
|
|
typescript.dependsOn extractTypescriptDependencies
|
2020-04-29 23:41:08 +00:00
|
|
|
|
2020-04-29 18:56:51 +00:00
|
|
|
processResources.dependsOn typescript
|
|
|
|
|
|
|
|
processResources {
|
|
|
|
from(typescriptOut.absolutePath) {
|
|
|
|
into 'scriptcraft'
|
|
|
|
}
|
|
|
|
}
|