aboutsummaryrefslogtreecommitdiff
path: root/examples/build.gradle
blob: 7f9b3ad843f3d0c8c6f91c6914585953e565b3a1 (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
description = 'OpenCensus Examples'

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
        classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6"
    }
}

apply plugin: "checkstyle"
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'findbugs'
// Plugins that require java8
if (JavaVersion.current().isJava8Compatible()) {
    apply plugin: "net.ltgt.errorprone"
    apply plugin: 'com.github.sherter.google-java-format'
}

repositories {
    mavenCentral()
    mavenLocal()
}

group = "io.opencensus"
version = "0.11.0-SNAPSHOT"

compileJava {
    // We suppress the "processing" warning as suggested in
    // https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM
    it.options.compilerArgs += ["-Xlint:all", "-Xlint:-try", "-Xlint:-processing"]
    if (JavaVersion.current().isJava8Compatible()) {
        it.options.compilerArgs += ["-XepDisableWarningsInGeneratedCode"]
        // TODO(bdrutu): Read files directly instead of reading from properties.
        if (rootProject.hasProperty("errorProneWarnings")) {
            it.options.compilerArgs += rootProject.properties["errorProneWarnings"].split(',').collect {
                it as String
            }
        }
        if (rootProject.hasProperty("errorProneExperimentalErrors")) {
            it.options.compilerArgs += rootProject.properties["errorProneExperimentalErrors"].split(',').collect {
                it as String
            }
        }
        if (rootProject.hasProperty("errorProneExperimentalWarnings")) {
            it.options.compilerArgs += rootProject.properties["errorProneExperimentalWarnings"].split(',').collect {
                it as String
            }
        }
        if (rootProject.hasProperty("errorProneExperimentalSuggestions")) {
            it.options.compilerArgs += rootProject.properties["errorProneExperimentalSuggestions"].split(',').collect {
                it as String
            }
        }
    }
    it.options.encoding = "UTF-8"
    // TODO(bdrutu): Enable when fix the issue with configuring bootstrap class.
    // [options] bootstrap class path not set in conjunction with -source 1.6
    if (JavaVersion.current().isJava8Compatible()) {
        it.options.compilerArgs += ["-Werror"]
    }
}

ext {
    findBugsVersion = '3.0.1'
}

findbugs {
    toolVersion = findBugsVersion
    ignoreFailures = false   // bug free or it doesn't ship!
    effort = 'max'
    reportLevel = 'low'      // low = sensitive to even minor mistakes
    omitVisitors = []        // bugs that we want to ignore
}
// Generate html report for findbugs.
findbugsMain {
    reports {
        xml.enabled = false
        html.enabled = true
    }
}
// Disable findbugs for tests.
findbugsTest.enabled = false

checkstyle {
    configFile = file("$rootDir/../buildscripts/checkstyle.xml")
    toolVersion = "8.0"
    ignoreFailures = false
    if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
        ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
    }
    configProperties["rootDir"] = file("$rootDir/../")
}

// Disable checkstyle if no java8.
checkstyleMain.enabled = JavaVersion.current().isJava8Compatible()
checkstyleTest.enabled = JavaVersion.current().isJava8Compatible()

// Google formatter works only on java8.
if (JavaVersion.current().isJava8Compatible()) {
    googleJavaFormat {
        toolVersion '1.5'
    }
}

tasks.withType(JavaCompile) {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

dependencies {
    compile "io.opencensus:opencensus-api:${version}",
            "io.opencensus:opencensus-contrib-zpages:${version}",
            "io.opencensus:opencensus-exporter-trace-logging:${version}"

    runtime "io.opencensus:opencensus-impl:${version}"
}

// Provide convenience executables for trying out the examples.
apply plugin: 'application'

startScripts.enabled = false

task statsRunner(type: CreateStartScripts) {
    mainClassName = 'io.opencensus.examples.stats.StatsRunner'
    applicationName = 'StatsRunner'
    outputDir = new File(project.buildDir, 'tmp')
    classpath = jar.outputs.files + project.configurations.runtime
}

task multiSpansTracing(type: CreateStartScripts) {
    mainClassName = 'io.opencensus.examples.trace.MultiSpansTracing'
    applicationName = 'MultiSpansTracing'
    outputDir = new File(project.buildDir, 'tmp')
    classpath = jar.outputs.files + project.configurations.runtime
}

task multiSpansScopedTracing(type: CreateStartScripts) {
    mainClassName = 'io.opencensus.examples.trace.MultiSpansScopedTracing'
    applicationName = 'MultiSpansScopedTracing'
    outputDir = new File(project.buildDir, 'tmp')
    classpath = jar.outputs.files + project.configurations.runtime
}

task multiSpansContextTracing(type: CreateStartScripts) {
    mainClassName = 'io.opencensus.examples.trace.MultiSpansContextTracing'
    applicationName = 'MultiSpansContextTracing'
    outputDir = new File(project.buildDir, 'tmp')
    classpath = jar.outputs.files + project.configurations.runtime
}

task zPagesTester(type: CreateStartScripts) {
    mainClassName = 'io.opencensus.examples.zpages.ZPagesTester'
    applicationName = 'ZPagesTester'
    outputDir = new File(project.buildDir, 'tmp')
    classpath = jar.outputs.files + project.configurations.runtime
}

applicationDistribution.into('bin') {
    from(multiSpansTracing)
    from(multiSpansScopedTracing)
    from(multiSpansContextTracing)
    from(statsRunner)
    from(zPagesTester)
    fileMode = 0755
}