-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathbuild.gradle
143 lines (123 loc) · 4.32 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
140
141
142
143
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.52.0'
}
repositories {
mavenCentral()
mavenLocal()
}
description = 'Ad Service'
group = "ad"
version = "0.1.0-SNAPSHOT"
def opentelemetryVersion = "1.48.0"
def opentelemetryInstrumentationVersion = "2.13.3"
def grpcVersion = "1.71.0"
def jacksonVersion = "2.18.3"
def protocVersion = "4.30.0"
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
ext {
speed = project.hasProperty('speed') ? project.getProperty('speed') : false
Provider<Directory> output = layout.buildDirectory.dir("outputLocation")
offlineCompile = output.get().asFile
}
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:${opentelemetryInstrumentationVersion}")
implementation "com.google.api.grpc:proto-google-common-protos:2.53.0",
"com.google.protobuf:protobuf-java:${protocVersion}",
"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.24.3",
"dev.openfeature.contrib.providers:flagd:0.11.5",
'dev.openfeature:sdk:1.14.1'
runtimeOnly "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}",
"com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}",
"io.netty:netty-tcnative-boringssl-static:2.0.70.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.18.1'
}
// 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 ad(type: CreateStartScripts) {
mainClass.set('oteldemo.AdService')
applicationName = 'Ad'
outputDir = new File(project.buildDir, 'tmp')
classpath = startScripts.classpath
}
applicationDistribution.into('bin') {
from(ad)
fileMode = 0755
}