-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbuild.gradle
80 lines (72 loc) · 1.74 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
plugins {
id 'java'
id 'com.google.protobuf' version '0.8.16'
id 'com.github.jlouns.cpe' version '0.5.0'
}
project.ext.set('protobufVersion', '3.16.0')
project.ext.set('protocVersion', project.protobufVersion)
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
repositories {
mavenCentral()
}
sourceSets {
main {
proto {
srcDir file('./proto')
}
}
}
protobuf {
protoc {
if (osdetector.os == 'osx') {
// Required for arm64 support on MacOS
artifact = "com.google.protobuf:protoc:${protocVersion}:osx-x86_64"
} else {
artifact = "com.google.protobuf:protoc:${protocVersion}"
}
}
plugins {
grpc {
path = file(
'./node_modules/.bin/grpc_tools_node_protoc_plugin' + (isWindows ? '.cmd' : '')
)
}
ts {
path = file(
'./node_modules/.bin/protoc-gen-ts' + (isWindows ? '.cmd' : '')
)
}
}
generateProtoTasks {
generateProto.finalizedBy copyGeneratedProto
all().each { task ->
task.plugins {
grpc {
outputSubDir = 'js'
option 'grpc_js'
}
ts {
option 'service=grpc-node,mode=grpc-js'
}
}
task.builtins {
remove java
js {
option 'import_style=commonjs'
}
}
task.dependsOn npmInstall
}
}
}
task copyGeneratedProto(type: Copy) {
from "$protobuf.generatedFilesBaseDir/main/ts", "$protobuf.generatedFilesBaseDir/main/js"
into 'proto'
}
task npmInstall(type: CrossPlatformExec) {
description 'Installs node dependencies'
inputs.file('package-lock.json').withPathSensitivity(PathSensitivity.RELATIVE)
outputs.dir('node_modules')
outputs.cacheIf { true }
commandLine 'npm', 'install'
}