build.gradle 4.9 KB

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