Skip to content

Commit

Permalink
Merge pull request #38 from BranchMetrics/Release-3.0.1
Browse files Browse the repository at this point in the history
[FIX] Updated gradle publish script
  • Loading branch information
nsingh-branch authored Nov 19, 2024
2 parents 4e30681 + 08fc370 commit dd743b4
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 80 deletions.
174 changes: 96 additions & 78 deletions AdobeBranchExtension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

task androidSourcesJar(type: Jar) {
archiveClassifier.set("sources")
from android.sourceSets.main.java.srcDirs
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
archiveClassifier.set("javadoc")
from androidJavadocs.destinationDir
}
}

dependencies {
Expand Down Expand Up @@ -73,84 +88,72 @@ dependencies {
androidTestImplementation project(path: ':AdobeBranchExtension')
}

def isReleaseBuild() {
return !VERSION_NAME.contains("SNAPSHOT")
}
def applyCommonConfig = { MavenPublication publication ->
publication.groupId = GROUP
publication.artifactId = POM_ARTIFACT_ID
publication.version = VERSION_NAME

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
publication.artifact bundleReleaseAar
publication.artifact androidSourcesJar
publication.artifact androidJavadocsJar

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}
publication.pom {
name.set(POM_NAME)
description.set(POM_DESCRIPTION)
url.set(POM_URL)

def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}
developers {
developer {
id.set(POM_DEVELOPER_ID)
name.set(POM_DEVELOPER_NAME)
}
}

def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}
licenses {
license {
name.set(POM_LICENCE_NAME)
url.set(POM_LICENCE_URL)
distribution.set(POM_LICENCE_DIST)
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.findByName('release')
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME

// // Attach sources and Javadocs
// artifact androidSourcesJar
// artifact androidJavadocsJar

// Configure POM
pom {
name.set(POM_NAME)
description.set(POM_DESCRIPTION)
url.set(POM_URL)
packaging = POM_PACKAGING

scm {
url.set(POM_SCM_URL)
connection.set(POM_SCM_CONNECTION)
developerConnection.set(POM_SCM_DEV_CONNECTION)
}
scm {
url.set(POM_SCM_URL)
connection.set(POM_SCM_CONNECTION)
developerConnection.set(POM_SCM_DEV_CONNECTION)
}

licenses {
license {
name.set(POM_LICENCE_NAME)
url.set(POM_LICENCE_URL)
distribution.set(POM_LICENCE_DIST)
}
withXml {
asNode().dependencies.dependency.findAll {
it.artifactId.text() == 'okhttp' || it.artifactId.text() == 'firebase-appindexing'
}.each { dependency ->
def optionalNode = dependency.optional
if (optionalNode) {
optionalNode[0].value = 'true'
} else {
dependency.appendNode('optional', 'true')
}
}
}
}
}

developers {
developer {
id.set(POM_DEVELOPER_ID)
name.set(POM_DEVELOPER_NAME)
}
}
project.afterEvaluate {
publishing {
publications {

// Optional dependencies
withXml {
asNode().dependencies.dependency.findAll {
it.artifactId.text() == 'okhttp' || it.artifactId.text() == 'firebase-appindexing'
}.each {
if (it.optional)
it.optional.value = 'true'
else
it.appendNode('optional', 'true')
}
}
debug(MavenPublication) {
applyCommonConfig(delegate as MavenPublication)
from components.findByName("debug")
}

release(MavenPublication) {
applyCommonConfig(delegate as MavenPublication)
from components.findByName("release")
}
}
}

repositories {
repositories {
maven {
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
credentials {
Expand All @@ -159,24 +162,39 @@ publishing {
}
}
}
}

signing {
sign publishing.publications.release
}
}

signing {
useGpgCmd()
sign publishing.publications.mavenJava
tasks.withType(PublishToMavenRepository).configureEach {
if (name.contains("Debug")) {
dependsOn assembleDebug
} else if (name.contains("Release")) {
dependsOn assembleRelease
}
}

task androidSourcesJar(type: Jar) {
archiveClassifier.set("sources")
from android.sourceSets.main.java.srcDirs
def isReleaseBuild() {
return !VERSION_NAME.contains("SNAPSHOT")
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
archiveClassifier.set("javadoc")
from androidJavadocs.destinationDir
def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}

def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Adobe Branch SDK Extension change log

- 3.0.1
* Nov 19, 2024
* Fix for missing .aar in 3.0.0

- 3.0.0
* Nov 18, 2024
* Update Branch Android SDK to 5.14.0
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=3.0.0
VERSION_CODE=300000
VERSION_NAME=3.0.1
VERSION_CODE=300001
GROUP=io.branch.sdk.android

POM_NAME=Branch Adobe Android SDK
Expand Down

0 comments on commit dd743b4

Please sign in to comment.