1description = 'Opencensus Proto' 2 3apply plugin: 'idea' 4apply plugin: 'java' 5apply plugin: 'com.google.protobuf' 6apply plugin: 'maven' 7apply plugin: "signing" 8 9group = "io.opencensus" 10version = "0.3.0-SNAPSHOT" // CURRENT_OPENCENSUS_PROTO_VERSION 11 12sourceCompatibility = 1.6 13targetCompatibility = 1.6 14 15repositories { 16 maven { url "https://plugins.gradle.org/m2/" } 17} 18 19jar.manifest { 20 attributes('Implementation-Title': name, 21 'Implementation-Version': version, 22 'Built-By': System.getProperty('user.name'), 23 'Built-JDK': System.getProperty('java.version'), 24 'Source-Compatibility': sourceCompatibility, 25 'Target-Compatibility': targetCompatibility) 26} 27 28def protobufVersion = '3.7.0' 29def protocVersion = '3.7.0' 30def grpcVersion = "1.19.0" // CURRENT_GRPC_VERSION 31def javaxAnnotationVersion = '1.3.2' 32 33buildscript { 34 repositories { 35 maven { url "https://plugins.gradle.org/m2/" } 36 } 37 dependencies { 38 classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8" 39 } 40} 41 42sourceSets { 43 main { 44 proto { 45 srcDir 'src' 46 } 47 } 48} 49 50dependencies { 51 compile "com.google.protobuf:protobuf-java:${protobufVersion}", 52 "io.grpc:grpc-protobuf:${grpcVersion}", 53 "io.grpc:grpc-stub:${grpcVersion}" 54 55 compileOnly "javax.annotation:javax.annotation-api:${javaxAnnotationVersion}" 56} 57 58protobuf { 59 protoc { 60 // The artifact spec for the Protobuf Compiler 61 artifact = "com.google.protobuf:protoc:${protocVersion}" 62 } 63 plugins { 64 grpc { 65 artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" 66 } 67 } 68 generateProtoTasks { 69 all()*.plugins { 70 grpc {} 71 } 72 ofSourceSet('main') 73 } 74 75 generatedFilesBaseDir = "$projectDir/gen_gradle/src" 76} 77 78// Disable all java warnings for proto generated files build 79compileJava { 80 options.compilerArgs += ["-Xlint:none"] 81 options.encoding = "UTF-8" 82} 83 84clean { 85 delete protobuf.generatedFilesBaseDir 86} 87 88// IntelliJ complains that the generated classes are not found, ask IntelliJ to include the 89// generated Java directories as source folders. 90idea { 91 module { 92 sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java"); 93 sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/grpc"); 94 // If you have additional sourceSets and/or codegen plugins, add all of them 95 } 96} 97 98signing { 99 required false 100 sign configurations.archives 101} 102 103javadoc.source = "$projectDir/gen_gradle/src" 104 105javadoc.options { 106 encoding = 'UTF-8' 107 links 'https://docs.oracle.com/javase/8/docs/api/' 108} 109 110task javadocJar(type: Jar) { 111 classifier = 'javadoc' 112 from javadoc 113} 114 115task sourcesJar(type: Jar) { 116 classifier = 'sources' 117 from sourceSets.main.allSource 118} 119 120artifacts { 121 archives javadocJar, sourcesJar 122} 123 124uploadArchives { 125 repositories { 126 mavenDeployer { 127 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 128 129 def configureAuth = { 130 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { 131 authentication(userName:rootProject.ossrhUsername, password: rootProject.ossrhPassword) 132 } 133 } 134 135 repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", configureAuth) 136 137 snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/", configureAuth) 138 139 pom.project { 140 name "OpenCensus" 141 packaging 'jar' 142 description project.description 143 url 'https://github.com/census-instrumentation/opencensus-proto' 144 145 scm { 146 connection 'scm:svn:https://github.com/census-instrumentation/opencensus-proto' 147 developerConnection 'scm:git:git@github.com/census-instrumentation/opencensus-proto' 148 url 'https://github.com/census-instrumentation/opencensus-proto' 149 } 150 151 licenses { 152 license { 153 name 'The Apache License, Version 2.0' 154 url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 155 } 156 } 157 158 developers { 159 developer { 160 id 'io.opencensus' 161 name 'OpenCensus Contributors' 162 email 'census-developers@googlegroups.com' 163 url 'opencensus.io' 164 // https://issues.gradle.org/browse/GRADLE-2719 165 organization = 'OpenCensus Authors' 166 organizationUrl 'https://www.opencensus.io' 167 } 168 } 169 } 170 } 171 } 172 } 173