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 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 }