Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit f303ae3

Browse files
authored
Add Gradle build rules for generating gRPC service and releasing to Maven. (#102)
* Add build rules for generating gRPC service and releasing to Maven. * Update to use gRPC v1.14.0 * Update version name.
1 parent d3b7200 commit f303ae3

File tree

1 file changed

+88
-2
lines changed

1 file changed

+88
-2
lines changed

build.gradle

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@ description = 'Opencensus Proto'
33
apply plugin: 'idea'
44
apply plugin: 'java'
55
apply plugin: 'com.google.protobuf'
6+
apply plugin: 'maven'
7+
apply plugin: "signing"
8+
9+
group = "io.opencensus"
10+
version = "0.0.1-SNAPSHOT" // CURRENT_OPENCENSUS_PROTO_VERSION
11+
12+
sourceCompatibility = 1.6
13+
targetCompatibility = 1.6
614

715
repositories {
816
maven { url "https://plugins.gradle.org/m2/" }
917
}
1018

19+
jar.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+
1128
def protobufVersion = '3.5.1'
1229
def protocVersion = '3.5.1'
30+
def grpcVersion = "1.14.0" // CURRENT_GRPC_VERSION
1331

1432
buildscript {
1533
repositories {
@@ -23,20 +41,33 @@ buildscript {
2341
sourceSets {
2442
main {
2543
proto {
26-
srcDir "src"
44+
srcDir 'src'
2745
}
2846
}
2947
}
3048

3149
dependencies {
32-
compile "com.google.protobuf:protobuf-java:${protobufVersion}"
50+
compile "com.google.protobuf:protobuf-java:${protobufVersion}",
51+
"io.grpc:grpc-protobuf:${grpcVersion}",
52+
"io.grpc:grpc-stub:${grpcVersion}"
3353
}
3454

3555
protobuf {
3656
protoc {
3757
// The artifact spec for the Protobuf Compiler
3858
artifact = "com.google.protobuf:protoc:${protocVersion}"
3959
}
60+
plugins {
61+
grpc {
62+
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
63+
}
64+
}
65+
generateProtoTasks {
66+
all()*.plugins {
67+
grpc {}
68+
}
69+
ofSourceSet('main')
70+
}
4071

4172
generatedFilesBaseDir = "$projectDir/gen_gradle/src"
4273
}
@@ -59,3 +90,58 @@ idea {
5990
// If you have additional sourceSets and/or codegen plugins, add all of them
6091
}
6192
}
93+
94+
signing {
95+
required false
96+
sign configurations.archives
97+
}
98+
99+
uploadArchives {
100+
repositories {
101+
mavenDeployer {
102+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
103+
104+
def configureAuth = {
105+
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
106+
authentication(userName:rootProject.ossrhUsername, password: rootProject.ossrhPassword)
107+
}
108+
}
109+
110+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", configureAuth)
111+
112+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/", configureAuth)
113+
114+
pom.project {
115+
name "OpenCensus"
116+
packaging 'jar'
117+
description project.description
118+
url 'https://github.com/census-instrumentation/opencensus-proto'
119+
120+
scm {
121+
connection 'scm:svn:https://github.com/census-instrumentation/opencensus-proto'
122+
developerConnection 'scm:git:git@github.com/census-instrumentation/opencensus-proto'
123+
url 'https://github.com/census-instrumentation/opencensus-proto'
124+
}
125+
126+
licenses {
127+
license {
128+
name 'The Apache License, Version 2.0'
129+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
130+
}
131+
}
132+
133+
developers {
134+
developer {
135+
id 'io.opencensus'
136+
name 'OpenCensus Contributors'
137+
email 'census-developers@googlegroups.com'
138+
url 'opencensus.io'
139+
// https://issues.gradle.org/browse/GRADLE-2719
140+
organization = 'OpenCensus Authors'
141+
organizationUrl 'https://www.opencensus.io'
142+
}
143+
}
144+
}
145+
}
146+
}
147+
}

0 commit comments

Comments
 (0)