summaryrefslogtreecommitdiff
path: root/src/ad/build.gradle
diff options
context:
space:
mode:
authorSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
committerSaumit <justsaumit@protonmail.com>2025-09-27 02:14:26 +0530
commit82e03978b89938219958032efb1448cc76baa181 (patch)
tree626f3e54d52ecd49be0ed3bee30abacc0453d081 /src/ad/build.gradle
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'src/ad/build.gradle')
-rw-r--r--src/ad/build.gradle143
1 files changed, 143 insertions, 0 deletions
diff --git a/src/ad/build.gradle b/src/ad/build.gradle
new file mode 100644
index 0000000..2d4e8e1
--- /dev/null
+++ b/src/ad/build.gradle
@@ -0,0 +1,143 @@
+
+plugins {
+ id 'com.google.protobuf' version '0.9.5'
+ 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.54.1"
+def opentelemetryInstrumentationVersion = "2.20.1"
+def grpcVersion = "1.75.0"
+def jacksonVersion = "2.20.0"
+def protocVersion = "4.32.1"
+
+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.61.2",
+ "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.25.2",
+ "dev.openfeature.contrib.providers:flagd:0.11.15",
+ 'dev.openfeature:sdk:1.18.1'
+
+ runtimeOnly "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}",
+ "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}",
+ "io.netty:netty-tcnative-boringssl-static:2.0.74.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
+}