125 lines
4.0 KiB
Groovy
125 lines
4.0 KiB
Groovy
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()
|
|
}
|
|
|
|
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"
|
|
|
|
tasks.withType(JavaCompile) {
|
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
targetCompatibility = JavaVersion.VERSION_1_8
|
|
}
|
|
|
|
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 "com.google.api.grpc:proto-google-common-protos:1.17.0",
|
|
"io.opencensus:opencensus-api:${opencensusVersion}",
|
|
"io.opencensus:opencensus-contrib-grpc-util:${opencensusVersion}",
|
|
"io.opencensus:opencensus-exporter-trace-jaeger:${opencensusVersion}",
|
|
"io.opencensus:opencensus-exporter-stats-stackdriver:${opencensusVersion}",
|
|
"io.opencensus:opencensus-exporter-trace-stackdriver:${opencensusVersion}",
|
|
"io.opencensus:opencensus-exporter-trace-logging:${opencensusVersion}",
|
|
"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"
|
|
|
|
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"
|
|
}
|
|
}
|
|
|
|
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 =
|
|
["-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
|
|
}
|