| buildscript { |
| repositories { |
| mavenCentral() |
| mavenLocal() |
| } |
| dependencies { |
| classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0' |
| } |
| } |
| |
| subprojects { |
| apply plugin: "checkstyle" |
| apply plugin: "java" |
| apply plugin: "maven" |
| apply plugin: "idea" |
| apply plugin: "signing" |
| apply plugin: "jacoco" |
| |
| apply plugin: "com.google.osdetector" |
| |
| group = "io.grpc" |
| version = "0.10.0-SNAPSHOT" |
| |
| sourceCompatibility = 1.6 |
| targetCompatibility = 1.6 |
| |
| repositories { |
| mavenCentral() |
| mavenLocal() |
| } |
| |
| [compileJava, compileTestJava].each() { |
| it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options", |
| "-Xlint:rawtypes"] |
| it.options.encoding = "UTF-8" |
| } |
| |
| jar.manifest { |
| attributes('Implementation-Title': name, |
| 'Implementation-Version': version, |
| 'Built-By': System.getProperty('user.name'), |
| 'Built-JDK': System.getProperty('java.version'), |
| 'Source-Compatibility': sourceCompatibility, |
| 'Target-Compatibility': targetCompatibility) |
| } |
| |
| javadoc.options { |
| encoding = 'UTF-8' |
| links 'https://docs.oracle.com/javase/8/docs/api/' |
| } |
| |
| ext { |
| def exeSuffix = osdetector.os == 'windows' ? ".exe" : "" |
| protocPluginBaseName = 'protoc-gen-grpc-java' |
| javaPluginPath = "$rootDir/compiler/build/binaries/java_pluginExecutable/$protocPluginBaseName$exeSuffix" |
| |
| protobufVersion = '3.0.0-beta-1' |
| protobufNanoVersion = '3.0.0-alpha-4' |
| |
| configureProtoCompilation = { |
| String generatedSourcePath = "${projectDir}/src/generated" |
| if (rootProject.childProjects.containsKey('grpc-compiler')) { |
| // Only when the codegen is built along with the project, will we be able to recompile |
| // the proto files. |
| project.apply plugin: 'com.google.protobuf' |
| project.protobuf { |
| protoc { |
| if (project.hasProperty('protoc')) { |
| path = project.protoc |
| } else { |
| artifact = "com.google.protobuf:protoc:${protobufVersion}" |
| } |
| } |
| plugins { |
| grpc { |
| path = javaPluginPath |
| } |
| } |
| generateProtoTasks { |
| all().each { task -> |
| task.dependsOn ':grpc-compiler:java_pluginExecutable' |
| // Delete the generated sources first, so that we can be alerted if they are not re-compiled. |
| task.dependsOn deleteGeneratedSource |
| // Recompile protos when the codegen has been changed |
| task.inputs.file javaPluginPath |
| // Recompile protos when build.gradle has been changed, because |
| // it's possible the version of protoc has been changed. |
| task.inputs.file "${rootProject.projectDir}/build.gradle" |
| task.plugins { |
| grpc {} |
| } |
| } |
| } |
| generatedFilesBaseDir = generatedSourcePath |
| } |
| |
| task deleteGeneratedSource << { |
| project.delete project.fileTree(dir: generatedSourcePath) |
| } |
| } else { |
| // Otherwise, we just use the checked-in generated code. |
| project.sourceSets { |
| main { |
| java { |
| srcDir "${generatedSourcePath}/main/java" |
| srcDir "${generatedSourcePath}/main/grpc" |
| } |
| } |
| } |
| } |
| } |
| |
| def tcnative_suffix = osdetector.classifier; |
| // Fedora variants use a different soname for OpenSSL than other linux distributions |
| // (see http://netty.io/wiki/forked-tomcat-native.html). |
| if (osdetector.os == "linux" && osdetector.release.isLike("fedora")) { |
| tcnative_suffix += "-fedora"; |
| } |
| |
| def epoll_suffix = ""; |
| if (osdetector.classifier in ["linux-x86_64"]) { |
| // The native code is only pre-compiled on certain platforms. |
| epoll_suffix = ":" + osdetector.classifier |
| } |
| 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', |
| 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.3.0', |
| okhttp: 'com.squareup.okhttp:okhttp:2.4.0', |
| protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}", |
| protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}", |
| protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.7.0', |
| |
| netty: 'io.netty:netty-codec-http2:4.1.0.Beta6', |
| netty_tcnative: 'io.netty:netty-tcnative:1.1.33.Fork7:' + tcnative_suffix, |
| netty_transport_native_epoll: 'io.netty:netty-transport-native-epoll:4.1.0.Beta6' + epoll_suffix, |
| |
| // 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.3.v20150130' |
| } |
| |
| alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version |
| } |
| |
| // Define a separate configuration for managing the dependency on Jetty alpnboot jar. |
| configurations { |
| alpnboot |
| tcnative |
| } |
| |
| dependencies { |
| testCompile libraries.junit, |
| libraries.mockito |
| |
| // Configuration for modules that use Jetty ALPN |
| alpnboot alpnboot_package_name |
| |
| // Configuration for modules that use Netty tcnative (for OpenSSL). |
| tcnative libraries.netty_tcnative |
| } |
| |
| 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 = false |
| if (rootProject.hasProperty("checkstyle.ignoreFailures")) { |
| ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean() |
| } |
| configProperties["rootDir"] = rootDir |
| } |
| |
| checkstyleMain { |
| source = fileTree(dir: "src/main", include: "**/*.java") |
| } |
| |
| checkstyleTest { |
| source = fileTree(dir: "src/test", include: "**/*.java") |
| } |
| |
| 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) } |
| String stagingUrl |
| if (rootProject.hasProperty('repositoryId')) { |
| stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + |
| rootProject.repositoryId |
| } else { |
| stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' |
| } |
| def configureAuth = { |
| if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { |
| authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) |
| } |
| } |
| repository(url: stagingUrl, configureAuth) |
| snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) |
| } |
| |
| [ |
| 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" |
| } |
| } |
| } |
| } |
| // At a test failure, log the stack trace to the console so that we don't |
| // have to open the HTML in a browser. |
| test { |
| testLogging { |
| exceptionFormat = 'full' |
| showExceptions true |
| showCauses true |
| showStackTraces true |
| } |
| } |
| } |