forked from stripe/stripe-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.gradle
141 lines (119 loc) · 5.01 KB
/
deploy.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
apply plugin: "signing"
apply plugin: "maven-publish"
nexusStaging {
packageGroup = GROUP
numberOfRetries = 40
delayBetweenRetriesInMillis = 4000
}
def getReleaseRepositoryUrl() {
return findProperty('RELEASE_REPOSITORY_URL') ?:
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
return findProperty('SNAPSHOT_REPOSITORY_URL') ?:
"https://oss.sonatype.org/content/repositories/snapshots/"
}
def getRepositoryUsername() {
return findProperty('NEXUS_USERNAME') ?: ""
}
def getRepositoryPassword() {
return findProperty('NEXUS_PASSWORD') ?: ""
}
if (project.hasProperty('android')) {
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}
}
afterEvaluate { project ->
// See https://developer.android.com/studio/build/maven-publish-plugin
// and https://docs.gradle.org/current/userguide/publishing_maven.html
// and https://proandroiddev.com/android-maven-publish-for-your-libraries-b76ad47677df
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Adds Javadocs and Sources as separate jars.
if (project.hasProperty('android')) {
artifact androidSourcesJar
artifact bundleReleaseAar
} else if (project.hasProperty('artifactPath')) {
artifact project.artifactPath
}
groupId = rootProject.group_name
artifactId = project.artifactId
version = rootProject.version_name
pom {
name = project.artifactName
packaging = "aar"
description = project.artifactDescrption
url = "https://github.com/stripe/stripe-android"
scm {
url = "https://github.com/stripe/stripe-android"
connection = "scm:[email protected]:stripe/stripe-android.git"
developerConnection = "scm:[email protected]:stripe/stripe-android.git"
}
licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
developers {
developer {
id = "stripe"
name = "Stripe"
}
}
}
pom.withXml {
final dependenciesNode = asNode().appendNode("dependencies")
ext.addDependency = { dep, scope ->
logger.lifecycle("updating dep $dep")
if (dep.group == null || dep.version == null || dep.name == null || dep.name == "unspecified") {
return // invalid dependencies should be ignored
}
final depGroup = dep.group
// If it's a project dependency, use the artifactId, otherwise use its name.
final depName = dep.hasProperty("dependencyProject") && dep.dependencyProject.hasProperty("artifactId") ?
dep.dependencyProject.artifactId : dep.name
final depVersion = dep.version != 'unspecified' ? dep.version : VERSION_NAME
final dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", depGroup)
dependencyNode.appendNode("artifactId", depName)
dependencyNode.appendNode("version", depVersion)
dependencyNode.appendNode("scope", scope)
}
if (configurations.hasProperty("api")) {
configurations.api.getDependencies().each { dep -> addDependency(dep, "compile") }
}
if (configurations.hasProperty("implementation")) {
configurations.implementation.getDependencies().each { dep -> addDependency(dep, "runtime") }
}
}
}
}
repositories {
maven {
url getReleaseRepositoryUrl()
credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publish") }
useGpgCmd()
sign publishing.publications.release
}
tasks.withType(Sign) {
onlyIf { project.hasProperty('signing.gnupg.keyName') }
}
artifacts {
if (project.hasProperty('android')) {
archives androidSourcesJar
}
}
}