aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: d5e3b0d855ea87d638a231379f2bceaae6a3735d (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
174
175
176
177
178
import org.apache.tools.ant.taskdefs.condition.Os

subprojects {
    apply plugin: "checkstyle"
    apply plugin: "java"
    apply plugin: "maven"
    apply plugin: "idea"
    apply plugin: "signing"

    group = "io.grpc"
    version = "0.1.0-SNAPSHOT"

    sourceCompatibility = 1.6
    targetCompatibility = 1.6

    repositories {
        mavenCentral()
        mavenLocal()
    }

    [compileJava, compileTestJava].each() {
        it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options"]
        it.options.encoding = "UTF-8"
    }

    javadoc.options.encoding = "UTF-8"

    ext {
        libraries = [
                guava: 'com.google.guava:guava:18.0',
                // used to collect benchmark results
                hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.4',
                hpack: 'com.twitter:hpack:0.10.1',
                javaee_api: 'javax:javaee-api:7.0',
                jsonp: 'org.glassfish:javax.json:1.0.4',
                jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
                oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.1.0',
                okhttp: 'com.squareup.okhttp:okhttp:2.2.0',
                protobuf: 'com.google.protobuf:protobuf-java:3.0.0-alpha-2',
                protobuf_nano: 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2',
                protobuf_plugin: 'ws.antonov.gradle.plugins:gradle-plugin-protobuf:0.9.1',

                // TODO: Unreleased dependencies.
                // These must already be installed in the local maven repository.
                netty: 'io.netty:netty-codec-http2:4.1.0.Beta5-SNAPSHOT',

                // Test dependencies.
                junit: 'junit:junit:4.11',
                mockito: 'org.mockito:mockito-core:1.10.19'
        ]

        // Determine the correct version of Jetty ALPN boot to use based
        // on the Java version.
        def alpnboot_version = '8.1.2.v20141202'
        if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) {
            alpnboot_version = '7.1.2.v20141202'
        }

        alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version

        def exeSuffix = Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : ""
        // The split is to workaround everything after the colon in C:\ being
        // removed due to a bug in the protobuf plugin.
        // https://github.com/aantono/gradle-plugin-protobuf/issues/23
        def splitRootDir = rootDir
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
          splitRootDir = splitRootDir.getPath().split(":", 2)[1]
        }
        protocPluginBaseName = 'protoc-gen-grpc-java'
        javaPluginPath = "$splitRootDir/compiler/build/binaries/java_pluginExecutable/$protocPluginBaseName$exeSuffix"
    }

    dependencies {
        testCompile libraries.junit,
                    libraries.mockito
    }

    signing {
        required false
        sign configurations.archives
    }

    // Disable JavaDoc doclint on Java 8. It's annoying.
    if (JavaVersion.current().isJava8Compatible()) {
      allprojects {
        tasks.withType(Javadoc) {
          options.addStringOption('Xdoclint:none', '-quiet')
        }
      }
    }

    checkstyle {
        configFile = file("$rootDir/checkstyle.xml")
        toolVersion = "6.5"
        ignoreFailures = true
        if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
            ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
        }
    }

    checkstyleMain {
        source = fileTree(dir: "src", include: "**/*.java",
            excludes: ["${buildDir}/generated-sources", "**/TestServiceGrpc.java"])
    }

    checkstyleTest {
        source = fileTree(dir: "test", include: "**/*.java",
            exclude: "${buildDir}/generated-sources")
    }

    task javadocJar(type: Jar) {
        classifier = 'javadoc'
        from javadoc
    }

    task sourcesJar(type: Jar) {
        classifier = 'sources'
        from sourceSets.main.allSource
    }

    artifacts {
        archives javadocJar, sourcesJar
    }

    uploadArchives.repositories.mavenDeployer {
        beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

        repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
            if (rootProject.hasProperty("ossrhUsername")
                    && rootProject.hasProperty("ossrhPassword")) {
                authentication(userName: ossrhUsername, password: ossrhPassword)
            }
        }

        snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
            if (rootProject.hasProperty("ossrhUsername")
                    && rootProject.hasProperty("ossrhPassword")) {
                authentication(userName: ossrhUsername, password: ossrhPassword)
            }
        }
    }

    [
      install.repositories.mavenInstaller,
      uploadArchives.repositories.mavenDeployer,
    ]*.pom*.whenConfigured { pom ->
        pom.project {
            name "$project.group:$project.name"
            description project.description
            url 'https://github.com/grpc/grpc-java'

            scm {
                connection 'scm:svn:https://github.com/grpc/grpc-java.git'
                developerConnection 'scm:svn:git@github.com:grpc/grpc-java.git'
                url 'https://github.com/grpc/grpc-java'
            }

            licenses {
                license {
                    name 'BSD 3-Clause'
                    url 'http://opensource.org/licenses/BSD-3-Clause'
                }
            }

            developers {
                developer {
                    id "grpc.io"
                    name "gRPC Contributors"
                    email "grpc-io@googlegroups.com"
                    url "http://grpc.io/"
                    // https://issues.gradle.org/browse/GRADLE-2719
                    organization = "Google, Inc."
                    organizationUrl "https://www.google.com"
                }
            }
        }
    }
}