Skip to content

Commit 08fc370

Browse files
committed
Updated gradle publish script
1 parent 4e30681 commit 08fc370

File tree

3 files changed

+102
-80
lines changed

3 files changed

+102
-80
lines changed

AdobeBranchExtension/build.gradle

Lines changed: 96 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ android {
4343
sourceCompatibility JavaVersion.VERSION_1_8
4444
targetCompatibility JavaVersion.VERSION_1_8
4545
}
46+
47+
task androidSourcesJar(type: Jar) {
48+
archiveClassifier.set("sources")
49+
from android.sourceSets.main.java.srcDirs
50+
}
51+
52+
task androidJavadocs(type: Javadoc) {
53+
source = android.sourceSets.main.java.srcDirs
54+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
55+
}
56+
57+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
58+
archiveClassifier.set("javadoc")
59+
from androidJavadocs.destinationDir
60+
}
4661
}
4762

4863
dependencies {
@@ -73,84 +88,72 @@ dependencies {
7388
androidTestImplementation project(path: ':AdobeBranchExtension')
7489
}
7590

76-
def isReleaseBuild() {
77-
return !VERSION_NAME.contains("SNAPSHOT")
78-
}
91+
def applyCommonConfig = { MavenPublication publication ->
92+
publication.groupId = GROUP
93+
publication.artifactId = POM_ARTIFACT_ID
94+
publication.version = VERSION_NAME
7995

80-
def getReleaseRepositoryUrl() {
81-
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
82-
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
83-
}
96+
publication.artifact bundleReleaseAar
97+
publication.artifact androidSourcesJar
98+
publication.artifact androidJavadocsJar
8499

85-
def getSnapshotRepositoryUrl() {
86-
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
87-
: "https://oss.sonatype.org/content/repositories/snapshots/"
88-
}
100+
publication.pom {
101+
name.set(POM_NAME)
102+
description.set(POM_DESCRIPTION)
103+
url.set(POM_URL)
89104

90-
def getRepositoryUsername() {
91-
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
92-
}
105+
developers {
106+
developer {
107+
id.set(POM_DEVELOPER_ID)
108+
name.set(POM_DEVELOPER_NAME)
109+
}
110+
}
93111

94-
def getRepositoryPassword() {
95-
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
96-
}
112+
licenses {
113+
license {
114+
name.set(POM_LICENCE_NAME)
115+
url.set(POM_LICENCE_URL)
116+
distribution.set(POM_LICENCE_DIST)
117+
}
118+
}
97119

98-
publishing {
99-
publications {
100-
mavenJava(MavenPublication) {
101-
from components.findByName('release')
102-
groupId = GROUP
103-
artifactId = POM_ARTIFACT_ID
104-
version = VERSION_NAME
105-
106-
// // Attach sources and Javadocs
107-
// artifact androidSourcesJar
108-
// artifact androidJavadocsJar
109-
110-
// Configure POM
111-
pom {
112-
name.set(POM_NAME)
113-
description.set(POM_DESCRIPTION)
114-
url.set(POM_URL)
115-
packaging = POM_PACKAGING
116-
117-
scm {
118-
url.set(POM_SCM_URL)
119-
connection.set(POM_SCM_CONNECTION)
120-
developerConnection.set(POM_SCM_DEV_CONNECTION)
121-
}
120+
scm {
121+
url.set(POM_SCM_URL)
122+
connection.set(POM_SCM_CONNECTION)
123+
developerConnection.set(POM_SCM_DEV_CONNECTION)
124+
}
122125

123-
licenses {
124-
license {
125-
name.set(POM_LICENCE_NAME)
126-
url.set(POM_LICENCE_URL)
127-
distribution.set(POM_LICENCE_DIST)
128-
}
126+
withXml {
127+
asNode().dependencies.dependency.findAll {
128+
it.artifactId.text() == 'okhttp' || it.artifactId.text() == 'firebase-appindexing'
129+
}.each { dependency ->
130+
def optionalNode = dependency.optional
131+
if (optionalNode) {
132+
optionalNode[0].value = 'true'
133+
} else {
134+
dependency.appendNode('optional', 'true')
129135
}
136+
}
137+
}
138+
}
139+
}
130140

131-
developers {
132-
developer {
133-
id.set(POM_DEVELOPER_ID)
134-
name.set(POM_DEVELOPER_NAME)
135-
}
136-
}
141+
project.afterEvaluate {
142+
publishing {
143+
publications {
137144

138-
// Optional dependencies
139-
withXml {
140-
asNode().dependencies.dependency.findAll {
141-
it.artifactId.text() == 'okhttp' || it.artifactId.text() == 'firebase-appindexing'
142-
}.each {
143-
if (it.optional)
144-
it.optional.value = 'true'
145-
else
146-
it.appendNode('optional', 'true')
147-
}
148-
}
145+
debug(MavenPublication) {
146+
applyCommonConfig(delegate as MavenPublication)
147+
from components.findByName("debug")
148+
}
149+
150+
release(MavenPublication) {
151+
applyCommonConfig(delegate as MavenPublication)
152+
from components.findByName("release")
149153
}
150154
}
151-
}
152155

153-
repositories {
156+
repositories {
154157
maven {
155158
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
156159
credentials {
@@ -159,24 +162,39 @@ publishing {
159162
}
160163
}
161164
}
165+
}
166+
167+
signing {
168+
sign publishing.publications.release
169+
}
162170
}
163171

164-
signing {
165-
useGpgCmd()
166-
sign publishing.publications.mavenJava
172+
tasks.withType(PublishToMavenRepository).configureEach {
173+
if (name.contains("Debug")) {
174+
dependsOn assembleDebug
175+
} else if (name.contains("Release")) {
176+
dependsOn assembleRelease
177+
}
167178
}
168179

169-
task androidSourcesJar(type: Jar) {
170-
archiveClassifier.set("sources")
171-
from android.sourceSets.main.java.srcDirs
180+
def isReleaseBuild() {
181+
return !VERSION_NAME.contains("SNAPSHOT")
172182
}
173183

174-
task androidJavadocs(type: Javadoc) {
175-
source = android.sourceSets.main.java.srcDirs
176-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
184+
def getReleaseRepositoryUrl() {
185+
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
186+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
187+
}
188+
189+
def getSnapshotRepositoryUrl() {
190+
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
191+
: "https://oss.sonatype.org/content/repositories/snapshots/"
177192
}
178193

179-
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
180-
archiveClassifier.set("javadoc")
181-
from androidJavadocs.destinationDir
194+
def getRepositoryUsername() {
195+
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
196+
}
197+
198+
def getRepositoryPassword() {
199+
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
182200
}

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Adobe Branch SDK Extension change log
22

3+
- 3.0.1
4+
* Nov 19, 2024
5+
* Fix for missing .aar in 3.0.0
6+
37
- 3.0.0
48
* Nov 18, 2024
59
* Update Branch Android SDK to 5.14.0

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ org.gradle.jvmargs=-Xmx1536m
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
14-
VERSION_NAME=3.0.0
15-
VERSION_CODE=300000
14+
VERSION_NAME=3.0.1
15+
VERSION_CODE=300001
1616
GROUP=io.branch.sdk.android
1717

1818
POM_NAME=Branch Adobe Android SDK

0 commit comments

Comments
 (0)