Home | History | Annotate | Download | only in examples
      1 description = 'OpenCensus Examples'
      2 
      3 buildscript {
      4     repositories {
      5         mavenCentral()
      6         mavenLocal()
      7         maven {
      8             url "https://plugins.gradle.org/m2/"
      9         }
     10     }
     11     dependencies {
     12         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
     13     }
     14 }
     15 
     16 apply plugin: 'idea'
     17 apply plugin: 'java'
     18 apply plugin: 'com.google.protobuf'
     19 
     20 repositories {
     21     mavenCentral()
     22     mavenLocal()
     23 }
     24 
     25 group = "io.opencensus"
     26 version = "0.17.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION
     27 
     28 def opencensusVersion = "0.16.1" // LATEST_OPENCENSUS_RELEASE_VERSION
     29 def grpcVersion = "1.13.1" // CURRENT_GRPC_VERSION
     30 def prometheusVersion = "0.3.0"
     31 
     32 tasks.withType(JavaCompile) {
     33     sourceCompatibility = '1.8'
     34     targetCompatibility = '1.8'
     35 }
     36 
     37 dependencies {
     38     compile "com.google.api.grpc:proto-google-common-protos:1.11.0",
     39             "io.opencensus:opencensus-api:${opencensusVersion}",
     40             "io.opencensus:opencensus-contrib-zpages:${opencensusVersion}",
     41             "io.opencensus:opencensus-contrib-grpc-metrics:${opencensusVersion}",
     42             "io.opencensus:opencensus-exporter-stats-prometheus:${opencensusVersion}",
     43             "io.opencensus:opencensus-exporter-stats-stackdriver:${opencensusVersion}",
     44             "io.opencensus:opencensus-exporter-trace-stackdriver:${opencensusVersion}",
     45             "io.opencensus:opencensus-exporter-trace-logging:${opencensusVersion}",
     46             "io.grpc:grpc-protobuf:${grpcVersion}",
     47             "io.grpc:grpc-stub:${grpcVersion}",
     48             "io.grpc:grpc-netty:${grpcVersion}",
     49             "io.prometheus:simpleclient_httpserver:${prometheusVersion}"
     50 
     51     runtime "io.opencensus:opencensus-impl:${opencensusVersion}",
     52             "io.netty:netty-tcnative-boringssl-static:2.0.8.Final"
     53 }
     54 
     55 protobuf {
     56     protoc {
     57         artifact = 'com.google.protobuf:protoc:3.5.1-1'
     58     }
     59     plugins {
     60         grpc {
     61             artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
     62         }
     63     }
     64     generateProtoTasks {
     65         all()*.plugins {
     66             grpc {}
     67         }
     68         ofSourceSet('main')
     69     }
     70 }
     71 
     72 // Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
     73 sourceSets {
     74     main {
     75         java {
     76             srcDir 'src'
     77             srcDirs 'build/generated/source/proto/main/grpc'
     78             srcDirs 'build/generated/source/proto/main/java'
     79         }
     80     }
     81 }
     82 
     83 // Provide convenience executables for trying out the examples.
     84 apply plugin: 'application'
     85 
     86 startScripts.enabled = false
     87 
     88 task tagContextExample(type: CreateStartScripts) {
     89     mainClassName = 'io.opencensus.examples.tags.TagContextExample'
     90     applicationName = 'TagContextExample'
     91     outputDir = new File(project.buildDir, 'tmp')
     92     classpath = jar.outputs.files + project.configurations.runtime
     93 }
     94 
     95 task multiSpansTracing(type: CreateStartScripts) {
     96     mainClassName = 'io.opencensus.examples.trace.MultiSpansTracing'
     97     applicationName = 'MultiSpansTracing'
     98     outputDir = new File(project.buildDir, 'tmp')
     99     classpath = jar.outputs.files + project.configurations.runtime
    100 }
    101 
    102 task multiSpansScopedTracing(type: CreateStartScripts) {
    103     mainClassName = 'io.opencensus.examples.trace.MultiSpansScopedTracing'
    104     applicationName = 'MultiSpansScopedTracing'
    105     outputDir = new File(project.buildDir, 'tmp')
    106     classpath = jar.outputs.files + project.configurations.runtime
    107 }
    108 
    109 task multiSpansContextTracing(type: CreateStartScripts) {
    110     mainClassName = 'io.opencensus.examples.trace.MultiSpansContextTracing'
    111     applicationName = 'MultiSpansContextTracing'
    112     outputDir = new File(project.buildDir, 'tmp')
    113     classpath = jar.outputs.files + project.configurations.runtime
    114 }
    115 
    116 task zPagesTester(type: CreateStartScripts) {
    117     mainClassName = 'io.opencensus.examples.zpages.ZPagesTester'
    118     applicationName = 'ZPagesTester'
    119     outputDir = new File(project.buildDir, 'tmp')
    120     classpath = jar.outputs.files + project.configurations.runtime
    121 }
    122 
    123 task quickStart(type: CreateStartScripts) {
    124     mainClassName = 'io.opencensus.examples.helloworld.QuickStart'
    125     applicationName = 'QuickStart'
    126     outputDir = new File(project.buildDir, 'tmp')
    127     classpath = jar.outputs.files + project.configurations.runtime
    128 }
    129 
    130 task helloWorldServer(type: CreateStartScripts) {
    131     mainClassName = 'io.opencensus.examples.grpc.helloworld.HelloWorldServer'
    132     applicationName = 'HelloWorldServer'
    133     outputDir = new File(project.buildDir, 'tmp')
    134     classpath = jar.outputs.files + project.configurations.runtime
    135 }
    136 
    137 task helloWorldClient(type: CreateStartScripts) {
    138     mainClassName = 'io.opencensus.examples.grpc.helloworld.HelloWorldClient'
    139     applicationName = 'HelloWorldClient'
    140     outputDir = new File(project.buildDir, 'tmp')
    141     classpath = jar.outputs.files + project.configurations.runtime
    142 }
    143 
    144 applicationDistribution.into('bin') {
    145     from(multiSpansTracing)
    146     from(multiSpansScopedTracing)
    147     from(multiSpansContextTracing)
    148     from(tagContextExample)
    149     from(zPagesTester)
    150     from(quickStart)
    151     from(helloWorldServer)
    152     from(helloWorldClient)
    153     fileMode = 0755
    154 }
    155