forked from newrelic-forks/microservices-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
150 lines (129 loc) · 4.69 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
144
145
146
147
148
149
150
plugins {
id 'com.google.protobuf' version '0.8.11'
id 'com.github.sherter.google-java-format' version '0.8'
id 'idea'
id 'application'
}
repositories {
mavenCentral()
mavenLocal()
maven() {
url "https://oss.sonatype.org/content/repositories/snapshots/"
mavenContent {
snapshotsOnly()
}
}
}
description = 'Ad Service'
group = "adservice"
version = "0.1.0-SNAPSHOT"
def opencensusVersion = "0.25.0"
def grpcVersion = "1.26.0"
def jacksonVersion = "2.10.2"
def protocVersion = "3.11.4"
def openTelemetryVersion = "0.8.0"
tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
ext {
speed = project.hasProperty('speed') ? project.getProperty('speed') : false
offlineCompile = new File("$buildDir/output/lib")
}
configurations {
exporters
}
dependencies {
if (speed) {
implementation fileTree(dir: offlineCompile, include: '*.jar')
} else {
exporters ("com.newrelic.telemetry:opentelemetry-exporters-newrelic-auto:0.8.1") {
transitive = false
}
implementation "com.google.api.grpc:proto-google-common-protos:1.17.0",
"io.opentelemetry:opentelemetry-api:${openTelemetryVersion}",
"io.opentelemetry:opentelemetry-extension-auto-annotations:${openTelemetryVersion}",
"com.newrelic.agent.java:newrelic-api:5.14.0",
"io.grpc:grpc-protobuf:${grpcVersion}",
"io.grpc:grpc-stub:${grpcVersion}",
"io.grpc:grpc-netty:${grpcVersion}",
"io.grpc:grpc-services:${grpcVersion}",
"org.apache.logging.log4j:log4j-core:2.13.0",
"org.apache.logging.log4j:log4j-slf4j-impl:2.13.2",
"javax.annotation:javax.annotation-api:1.3.2",
"com.h2database:h2:1.4.200",
"org.springframework:spring-jdbc:5.2.8.RELEASE"
runtimeOnly "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}",
"com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}",
"io.opencensus:opencensus-contrib-log-correlation-log4j2:${opencensusVersion}",
"io.opencensus:opencensus-impl:${opencensusVersion}",
"io.netty:netty-tcnative-boringssl-static:2.0.26.Final"
}
}
task copyExporters(type: Copy) {
from configurations.exporters
into "$buildDir/exporters"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${protocVersion}"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
ofSourceSet('main')
}
}
googleJavaFormat {
toolVersion '1.7'
}
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
sourceSets {
main {
java {
srcDirs 'hipstershop'
srcDirs 'build/generated/source/proto/main/java/hipstershop'
srcDirs 'build/generated/source/proto/main/grpc/hipstershop'
}
}
}
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.compile
into offlineCompile
from configurations.runtime
into offlineCompile
}
task adService(type: CreateStartScripts) {
mainClassName = 'hipstershop.AdService'
applicationName = 'AdService'
outputDir = new File(project.buildDir, 'tmp')
classpath = startScripts.classpath
defaultJvmOpts = ["-javaagent:auto-agent/opentelemetry-agent.jar",
"-Dio.opentelemetry.auto.slf4j.simpleLogger.log.com.newrelic.telemetry=debug",
"-Dotel.imr.export.interval=10000",
"-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector",
"-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=adservice,-cprof_service_version=1.0.0"]
}
task adServiceClient(type: CreateStartScripts) {
mainClassName = 'hipstershop.AdServiceClient'
applicationName = 'AdServiceClient'
outputDir = new File(project.buildDir, 'tmp')
classpath = startScripts.classpath
defaultJvmOpts =
["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector",
"-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=adserviceclient,-cprof_service_version=1.0.0"]
}
applicationDistribution.into('bin') {
from(adService)
from(adServiceClient)
fileMode = 0755
}