Skip to content

Commit 1f251bb

Browse files
authored
update gradle build script to prepare for publishing to maven central (#159)
* update gradle build script to prepare for publishing to maven central * add ci status image in readme page * do not sign archives if key is missing
1 parent 93e3493 commit 1f251bb

File tree

2 files changed

+119
-5
lines changed

2 files changed

+119
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Java framework for Cadence
1+
# Java framework for Cadence [![Build Status](https://travis-ci.org/uber-java/cadence-client.svg?branch=master)](https://travis-ci.org/uber-java/cadence-client)
2+
3+
24
[Cadence](https://github.com/uber/cadence) is a distributed, scalable, durable, and highly available orchestration engine we developed at Uber Engineering to execute asynchronous long-running business logic in a scalable and resilient way.
35

46
`cadence-client` is the framework for authoring workflows and activities in Java.

build.gradle

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ apply plugin: "org.jruyi.thrift"
2323
apply plugin: 'maven-publish'
2424
apply plugin: 'com.github.sherter.google-java-format'
2525

26+
if (hasProperty("signing.keyId")) {
27+
apply plugin: 'signing'
28+
signing {
29+
sign configurations.archives
30+
}
31+
}
32+
2633
googleJavaFormat {
2734
toolVersion '1.5'
2835
include '**/*.java'
2936
exclude '**/generated-sources/*'
3037
}
3138

32-
group = 'com.uber'
39+
group = 'com.uber.cadence'
3340
version = '0.2.0-SNAPSHOT'
3441

3542
description = """Uber Cadence Java Client"""
@@ -74,24 +81,79 @@ if (JavaVersion.current().isJava8Compatible()) {
7481
}
7582
}
7683

84+
task javadocJar(type: Jar) {
85+
classifier = 'javadoc'
86+
from javadoc
87+
}
88+
7789
task sourcesJar(type: Jar, dependsOn: classes) {
7890
classifier = 'sources'
7991
from sourceSets.main.allSource
8092
}
8193

8294
artifacts {
83-
archives sourcesJar
95+
archives javadocJar, sourcesJar
8496
}
8597

98+
def ossrhUsername = hasProperty('ossrhUsername') ? property('ossrhUsername') : ""
99+
def ossrhPassword = hasProperty('ossrhPassword') ? property('ossrhPassword') : ""
100+
86101
publishing {
102+
// Uncomment the following when we can use maven-publish to sign artifacts
103+
// https://github.com/gradle/gradle/issues/4943
104+
105+
// mavenCustom(MavenPublication) {
106+
// pom.withXml {
107+
// asNode().with {
108+
// appendNode('packaging', 'jar')
109+
// appendNode('name', 'cadence-client')
110+
// appendNode('description', description)
111+
// appendNode('url', 'https://github.com/uber-java/cadence-client')
112+
// appendNode('scm').with {
113+
// appendNode('url', 'https://github.com/uber-java/cadence-client')
114+
// appendNode('connection', '[email protected]:uber-java/cadence-client.git')
115+
// }
116+
// appendNode('licenses').with {
117+
// appendNode('license').with {
118+
// appendNode('name', 'The Apache License, Version 2.0')
119+
// appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
120+
// }
121+
// }
122+
// appendNode('developers').with {
123+
// appendNode('maxim').with {
124+
// appendNode('id', 'maxim')
125+
// appendNode('name', 'Maxim Fateev')
126+
// appendNode('email', '[email protected]')
127+
// }
128+
// appendNode('developer').with {
129+
// appendNode('id', 'meiliang')
130+
// appendNode('name', 'Liang Mei')
131+
// appendNode('email', '[email protected]')
132+
// }
133+
// }
134+
// }
135+
// }
136+
// }
137+
87138
publications {
88139
mavenJava(MavenPublication) {
89140
from components.java
141+
artifact javadocJar
90142
artifact sourcesJar
91143
}
92144
}
93145
repositories {
94-
mavenLocal()
146+
maven {
147+
credentials {
148+
username ossrhUsername
149+
password ossrhPassword
150+
}
151+
if(project.version.endsWith('-SNAPSHOT')) {
152+
url "https://oss.sonatype.org/content/repositories/snapshots/"
153+
} else {
154+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
155+
}
156+
}
95157
}
96158
}
97159

@@ -102,4 +164,54 @@ test {
102164
// Uncomment the following line if you want to see test logs in gradlew run.
103165
// showStandardStreams true
104166
}
105-
}
167+
}
168+
169+
uploadArchives {
170+
repositories {
171+
mavenDeployer {
172+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
173+
174+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
175+
authentication(userName: ossrhUsername, password: ossrhPassword)
176+
}
177+
178+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
179+
authentication(userName: ossrhUsername, password: ossrhPassword)
180+
}
181+
182+
pom.project {
183+
name 'cadence-client'
184+
packaging 'jar'
185+
// optionally artifactId can be defined here
186+
description 'Uber Cadence Java Client'
187+
url 'https://github.com/uber-java/cadence-client'
188+
189+
scm {
190+
connection 'scm:git:[email protected]:uber-java/cadence-client.git/'
191+
developerConnection 'scm:git:[email protected]:uber-java/cadence-client.git/'
192+
url 'https://github.com/uber-java/cadence-client'
193+
}
194+
195+
licenses {
196+
license {
197+
name 'The Apache License, Version 2.0'
198+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
199+
}
200+
}
201+
202+
developers {
203+
developer {
204+
id 'maxim'
205+
name 'Maxim Fateev'
206+
207+
}
208+
developer {
209+
id 'meiliang'
210+
name 'Liang Mei'
211+
212+
}
213+
}
214+
}
215+
}
216+
}
217+
}

0 commit comments

Comments
 (0)