-
Notifications
You must be signed in to change notification settings - Fork 11
/
publish.gradle
102 lines (92 loc) · 2.73 KB
/
publish.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
apply plugin: 'maven-publish'
apply plugin: 'signing'
// Create variables with empty default values
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["sonatypeStagingProfileId"] = ''
File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
} else {
// Use system environment variables
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
}
}
}
// to remove shadowed jar from the regular release publication
components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
skip()
}
def configurePom(pom) {
pom.with {
name = "Stream Chat official Java API Client"
description = "Stream Chat Java Client for backend integrations"
url = 'https://github.com/getstream/stream-chat-java'
licenses {
license {
name = 'Stream License'
url = 'https://github.com/GetStream/stream-chat-java/blob/main/LICENSE'
}
}
developers {
developer {
id = 'getstream-support'
name = 'Stream Support'
email = 'support@getstream.io'
}
}
scm {
connection = 'scm:git:github.com/getstream/stream-chat-java.git'
developerConnection = 'scm:git:ssh://github.com/getstream/stream-chat-java.git'
url = 'https://github.com/getstream/stream-chat-java/tree/main'
}
}
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.java
artifactId 'stream-chat-java'
configurePom(pom)
}
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
artifactId 'stream-chat-java-all'
artifact javadocJar
artifact sourcesJar
configurePom(pom)
}
}
}
}
signing {
sign publishing.publications
}
// Ensure that the publish tasks run after the sign tasks, otherwise gradle will complain
tasks.matching { it.name.startsWith('publish') }.all { publishTask ->
tasks.matching { it.name.startsWith('sign') }.all { signTask ->
publishTask.mustRunAfter(signTask)
}
}
javadoc {
options.addBooleanOption('html5', true)
}