vscode-gradle/npm-package/build.gradle

191 строка
4.4 KiB
Groovy

description = 'vscode-gradle :: npm-package'
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
project.ext.set('protoLib', "lib/proto")
clean {
delete file('node_modules')
delete file('lib')
delete file('index.d.ts')
delete file('index.js')
}
jar.enabled = false;
task copyProtoLib(type: Copy) {
dependsOn ':extension:copyProtoTs'
dependsOn ':extension:copyProtoJs'
dependsOn ':extension:generateProto'
group 'copy'
description 'Copies genereated proto files'
from file("../extension/src/proto")
into protoLib
}
task copyRootProjectTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies root project types'
from file("../extension/dist/rootProject")
include "*.d.ts"
into 'lib/rootProject'
}
task copyIconTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies stores types'
from file("../extension/dist/icons")
include "*.d.ts"
into 'lib/icons'
}
task copyStoreTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies stores types'
from file("../extension/dist/stores")
include "*.d.ts"
into 'lib/stores'
}
task copyRecentTasksViewTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies recentTasks views'
from file("../extension/dist/views/recentTasks")
include "*.d.ts"
into 'lib/views/recentTasks'
}
task copyGradleDaemonsViewTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies gradleDaemons views'
from file("../extension/dist/views/gradleDaemons")
include "*.d.ts"
into 'lib/views/gradleDaemons'
}
task copyGradleTasksViewTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies gradleTasks views'
from file("../extension/dist/views/gradleTasks")
include "*.d.ts"
into 'lib/views/gradleTasks'
}
task copyViewTypes(type: Copy) {
dependsOn ':extension:buildProd',
copyGradleDaemonsViewTypes,
copyGradleTasksViewTypes,
copyRecentTasksViewTypes
group 'copy'
description 'Copies views'
from file("../extension/dist/views")
include "*.d.ts"
into 'lib/views'
}
task copyClientTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies client'
from file("../extension/dist/client")
include "*.d.ts"
into 'lib/client'
}
task copyUtilTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies util'
from file("../extension/dist/util")
include "*.d.ts"
into 'lib/util'
}
task copyTasksTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies tasks'
from file("../extension/dist/tasks")
include "*.d.ts"
into 'lib/tasks'
}
task copyServerTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies server'
from file("../extension/dist/server")
include "*.d.ts"
into 'lib/server'
}
task copyLoggerTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies logger'
from file("../extension/dist/logger")
include "*.d.ts"
into 'lib/logger'
}
task copyApiTypes(type: Copy) {
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies api'
from file("../extension/dist/api")
include "*.d.ts"
into 'lib/api'
}
task copyPublicApi(type: Copy) {
dependsOn ':extension:buildProd',
copyStoreTypes,
copyViewTypes,
copyClientTypes,
copyTasksTypes,
copyServerTypes,
copyLoggerTypes,
copyRootProjectTypes,
copyApiTypes,
copyIconTypes,
copyUtilTypes
group 'copy'
description 'Copies publc API types'
from file("../extension/dist")
include "*.d.ts"
into 'lib'
}
task npmInstall(type: CrossPlatformExec) {
description 'Installs node dependencies'
inputs.file('package-lock.json').withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir('node_modules')
outputs.cacheIf { true }
// for apple m1, please add npm_arch=x64 in $HOME/.gradle/gradle.properties
if (project.hasProperty('npm_arch')) {
commandLine 'npm', "--target_arch=${npm_arch}", 'install'
} else {
commandLine 'npm', 'install'
}
}
task compileTypeScript(type: CrossPlatformExec) {
dependsOn npmInstall, copyPublicApi
description 'Compiles the TypeScript files'
inputs.file('index.ts')
outputs.file('index.d.ts');
outputs.file('index.js');
commandLine 'npm', 'run', 'compile'
}
build.finalizedBy npmInstall,
compileTypeScript,
copyProtoLib,
copyPublicApi