forked from open-telemetry/opentelemetry-demo
/
build.gradle
139 lines (119 loc) · 4.12 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
plugins {
id 'com.google.protobuf' version '0.9.4'
id 'com.github.sherter.google-java-format' version '0.9'
id 'idea'
id 'application'
id 'com.github.ben-manes.versions' version '0.47.0'
}
repositories {
mavenCentral()
mavenLocal()
}
description = 'Ad Service'
group = "adservice"
version = "0.1.0-SNAPSHOT"
def opentelemetryVersion = "1.28.0"
def opentelemetryInstrumentationAlphaVersion = "1.28.0-alpha"
def grpcVersion = "1.56.1"
def jacksonVersion = "2.15.2"
def protocVersion = "3.20.0"
tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
ext {
speed = project.hasProperty('speed') ? project.getProperty('speed') : false
offlineCompile = new File("$buildDir/output/lib")
}
dependencies {
if (speed) {
implementation fileTree(dir: offlineCompile, include: '*.jar')
} else {
implementation platform("io.opentelemetry:opentelemetry-bom:${opentelemetryVersion}")
implementation platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${opentelemetryInstrumentationAlphaVersion}")
implementation "com.google.api.grpc:proto-google-common-protos:2.22.1",
"javax.annotation:javax.annotation-api:1.3.2",
"io.grpc:grpc-protobuf:${grpcVersion}",
"io.grpc:grpc-stub:${grpcVersion}",
"io.grpc:grpc-netty:${grpcVersion}",
"io.grpc:grpc-services:${grpcVersion}",
"io.opentelemetry:opentelemetry-api",
"io.opentelemetry:opentelemetry-sdk",
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations",
"org.apache.logging.log4j:log4j-core:2.20.0"
runtimeOnly "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}",
"com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}",
"io.netty:netty-tcnative-boringssl-static:2.0.61.Final"
}
}
// Default protoSourceDir is in /opentelemetry-demo/pb. Optionally override the
// location for the docker build, which copies the protos to a different location.
def protoSourceDir = findProperty('protoSourceDir')?: project.projectDir.parentFile.parentFile.toPath().toString() + "/pb"
def protoDestDir = project.buildDir.toPath().toString() + "/proto"
// Copy protos to the build directory
tasks.register('copyProtos', Copy) {
from protoSourceDir
into protoDestDir
}
// Include the output directory of copyProtos in main source set so they are
// picked up by the protobuf plugin
sourceSets {
main {
proto {
srcDir(protoDestDir)
}
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${protocVersion}"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks { task ->
all()*.plugins {
grpc {}
}
ofSourceSet('main')
}
}
afterEvaluate {
// Ensure protos are copy before classes are generated
tasks.getByName('processResources').dependsOn 'copyProtos'
tasks.getByName('generateProto').dependsOn 'copyProtos'
}
googleJavaFormat {
toolVersion '1.7'
}
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
sourceSets {
main {
java {
srcDirs 'oteldemo'
srcDirs 'build/generated/source/proto/main/java/oteldemo'
srcDirs 'build/generated/source/proto/main/grpc/oteldemo'
}
}
}
startScripts.enabled = false
// This to cache dependencies during Docker image building. First build will take time.
// Subsequent build will be incremental.
task downloadRepos(type: Copy) {
from configurations.compileClasspath
into offlineCompile
from configurations.runtimeClasspath
into offlineCompile
}
task adService(type: CreateStartScripts) {
mainClass.set('oteldemo.AdService')
applicationName = 'AdService'
outputDir = new File(project.buildDir, 'tmp')
classpath = startScripts.classpath
}
applicationDistribution.into('bin') {
from(adService)
fileMode = 0755
}