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/typescript.build.gradle

93 lines
1.8 KiB
Groovy

def typescriptRoot = 'src/main/ts'
def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot)
def nodeModules = new File(typescriptRootFile, 'node_modules')
task typescriptInstall(group: 'typescript', type: Exec) {
inputs.file new File(typescriptRootFile, 'package.json')
outputs.dir nodeModules
workingDir typescriptRootFile
executable 'npm'
args 'install'
}
def typescriptOut = new File(typescriptRootFile, 'lib/ts')
def dtsOut = new File(typescriptRootFile, 'lib/dts')
task typescript(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dirs typescriptOut, dtsOut
workingDir typescriptRootFile
executable 'npm'
args 'run', 'build'
doFirst {
project.delete {
delete typescriptOut, dtsOut
}
}
}
typescript.dependsOn typescriptInstall
task typescriptAPI(group: 'typescript', type: Jar) {
into('types') {
from new File(typescriptRootFile as File, 'src/types')
}
into('lib') {
from dtsOut
}
classifier 'api'
}
typescriptAPI.dependsOn typescript
artifacts {
archives typescriptAPI
}
task eslint(group: 'typescript', type: Exec) {
workingDir typescriptRootFile
executable 'npm'
args 'run', 'eslint'
}
eslint.dependsOn typescriptInstall
processResources.dependsOn typescript
def typedocOut = new File(typescriptRootFile, 'lib/typedoc')
task typedoc(group: 'typescript', type: Exec) {
inputs.dir typescriptRootFile
outputs.dir typedocOut
workingDir typescriptRootFile
executable 'npm'
args 'run', 'typedoc'
doFirst {
project.delete {
delete typedocOut
}
}
}
typedoc.dependsOn typescriptInstall
processResources {
from(typescriptOut.absolutePath) {
into 'scriptcraft'
}
}