-
Notifications
You must be signed in to change notification settings - Fork 4
/
publish-mavencentral.gradle
127 lines (108 loc) · 3.5 KB
/
publish-mavencentral.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
apply plugin: 'maven-publish'
apply plugin: 'signing'
def SIGNING_KEY_ID = "signing.keyId"
def SIGNING_PASSWORD = "signing.password"
def SIGNING_SECRET_KEY_RING_FILE = "signing.secretKeyRingFile"
def OSSRH_USERNAME = "ossrhUsername"
def OSSRH_PASSWORD = "ossrhPassword"
def SONATYPE_STAGING_PROFILE_ID = "sonatypeStagingProfileId"
android {
publishing {
singleVariant('release')
}
}
// stub for sources, required by MavenCentral
tasks.register('sourcesJar', Jar) {
archiveClassifier.set('sources')
from file('build/intermediates/aar_main_jar/release/classes.jar')
}
// stub for java doc, required by MavenCentral
tasks.register('javadoc', Javadoc) {
failOnError false
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
group = GROUP_ID
version = VERSION_NAME
ext[SIGNING_KEY_ID] = ''
ext[SIGNING_PASSWORD] = ''
ext[SIGNING_SECRET_KEY_RING_FILE] = ''
ext[OSSRH_USERNAME] = ''
ext[OSSRH_PASSWORD] = ''
ext[SONATYPE_STAGING_PROFILE_ID] = ''
File localPropsFile = project.rootProject.file('local.properties')
if (localPropsFile.exists()) {
Properties p = new Properties()
p.load(new FileInputStream(localPropsFile))
p.each { key, value ->
ext[key] = value
}
} else {
ext[SIGNING_KEY_ID] = System.getenv('SIGNING_KEY_ID')
ext[SIGNING_PASSWORD] = System.getenv('SIGNING_PASSWORD')
ext[SIGNING_SECRET_KEY_RING_FILE] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext[OSSRH_USERNAME] = System.getenv('OSSRH_USERNAME')
ext[OSSRH_PASSWORD] = System.getenv('OSSRH_PASSWORD')
ext[SONATYPE_STAGING_PROFILE_ID] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId GROUP_ID
artifactId ARTIFACT_NAME
version VERSION_NAME
if (project.plugins.findPlugin("com.android.library")) {
from components.release
} else {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}
artifact sourcesJar
artifact javadocJar
pom {
name = ARTIFACT_NAME
description = LIB_DESCRIPTION
url = LIB_SITE
licenses {
license {
name = LIB_LICENSE_NAME
url = LIB_LICENSE_URL
}
}
scm {
connection = LIB_SCM_CONNECTION
developerConnection = LIB_SCM_DEVELOPER_CONNECTION
url = LIB_SCM_URL
}
developers {
developer {
id = LIB_DEVELOPER_ID
name = LIB_DEVELOPER_NAME
email = LIB_DEVELOPER_EMAIL
}
}
}
}
}
repositories {
maven {
name = "sonatype"
url = version.endsWith('SNAPSHOT') ? LIB_SNAPSHOTS_URL : LIB_STAGING_URL
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
}
signing {
sign publishing.publications
}