This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
ScriptCraft/examples/typescript/typescript.build.gradle
TheBrokenRail 37f11a92f0
All checks were successful
ScriptCraft/pipeline/head This commit looks good
Add Documentation
2020-05-24 14:09:25 -04:00

73 lines
1.5 KiB
Groovy

def typescriptRoot = 'src/main/ts'
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
def typescriptOut = new File(typescriptRootFile, 'build/ts')
def nodeModules = new File(typescriptRootFile, 'node_modules')
task npmInstall(group: 'typescript', type: Exec) {
inputs.file new File(typescriptRootFile, 'package.json')
outputs.dir nodeModules
workingDir typescriptRootFile
executable 'npm'
args 'install'
doFirst {
project.delete {
delete nodeModules
}
}
}
def typescriptDependencies = new File(typescriptRootFile, 'build/dependencies')
configurations {
typescript {
transitive false
}
}
task extractTypescriptDependencies(type: Sync, group: 'typescript') {
dependsOn configurations.typescript
from {
configurations.typescript.collect {
zipTree(it).matching {
exclude 'META-INF', 'META-INF/**'
}
}
}
into typescriptDependencies
}
task typescript(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dirs typescriptOut
workingDir typescriptRootFile
executable 'npm'
args 'run', 'build'
doFirst {
project.delete {
delete typescriptOut
}
}
}
typescript.dependsOn npmInstall
typescript.dependsOn extractTypescriptDependencies
processResources.dependsOn typescript
processResources {
from(typescriptOut.absolutePath) {
into 'scriptcraft'
}
}