-
Notifications
You must be signed in to change notification settings - Fork 4
/
publish.gradle
101 lines (92 loc) · 2.94 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
apply plugin: 'maven-publish'
apply plugin: 'signing'
// https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is ->
p.load(is)
}
p.each { name, value ->
ext[name] = value
}
} else {
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["sonatypeUsername"] = System.getenv('SONATYPE_USERNAME')
ext["sonatypePassword"] = System.getenv('SONATYPE_PASSWORD')
}
// https://gist.github.com/wasabeef/2f2ae8d97b429e7d967128125dc47854
def sonatypeUsername = rootProject.hasProperty('sonatypeUsername')? rootProject.sonatypeUsername : ''
def sonatypePassword = rootProject.hasProperty('sonatypePassword')? rootProject.sonatypePassword : ''
version configs.libraryVersionName
group configs.groupId
task sourcesJar(type: Jar) {
archiveClassifier.set("sources")
from android.sourceSets.getByName("main").java.srcDirs
}
task javadoc(type: Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
source = android.sourceSets.getByName("main").java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
excludes = ['**/*.kt']
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set("javadoc")
from javadoc.destinationDir
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
artifactId = configs.artifactId
from components.release
artifact javadocJar
artifact sourcesJar
pom {
name = configs.artifactId
description = configs.description
url = configs.siteUrl
licenses {
license {
name = configs.licenseName
url = configs.licenseUrl
}
}
developers {
developer {
id = configs.developerId
name = configs.developerName
email = configs.developerEmail
}
}
scm {
connection = configs.gitUrl
developerConnection = configs.gitUrl
url = configs.siteUrl
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = "${sonatypeUsername}"
password = "${sonatypePassword}"
}
}
}
}
}
signing {
sign publishing.publications
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}