Skip to content

Commit

Permalink
Update to use Gradle Nexus Publish Plugin (#442)
Browse files Browse the repository at this point in the history
* Update gradle publish plugin
  • Loading branch information
sarahkoop committed Sep 26, 2023
1 parent 6b23f12 commit 9e5c0aa
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 93 deletions.
6 changes: 3 additions & 3 deletions .github/actions/close_and_release_repository/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ inputs:
runs:
using: "composite"
steps:
- run: ./gradlew --stacktrace closeAndReleaseRepository
- run: ./gradlew --stacktrace closeAndReleaseSonatypeStagingRepository
shell: bash
env:
SONATYPE_USERNAME: ${{ inputs.sonatype_usr }}
SONATYPE_PASSWORD: ${{ inputs.sonatype_pwd }}
SONATYPE_NEXUS_USERNAME: ${{ inputs.sonatype_usr }}
SONATYPE_NEXUS_PASSWORD: ${{ inputs.sonatype_pwd }}
SIGNING_KEY_ID: ${{ inputs.signing_key_id }}
SIGNING_KEY_PASSWORD: ${{ inputs.signing_key_pwd }}
SIGNING_KEY_FILE: ${{ inputs.signing_key_file }}
4 changes: 2 additions & 2 deletions .github/actions/publish_module/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ runs:
- run: ./gradlew --stacktrace clean :${{ inputs.module }}:publishToSonatype
shell: bash
env:
SONATYPE_USERNAME: ${{ inputs.sonatype_usr }}
SONATYPE_PASSWORD: ${{ inputs.sonatype_pwd }}
SONATYPE_NEXUS_USERNAME: ${{ inputs.sonatype_usr }}
SONATYPE_NEXUS_PASSWORD: ${{ inputs.sonatype_pwd }}
SIGNING_KEY_ID: ${{ inputs.signing_key_id }}
SIGNING_KEY_PASSWORD: ${{ inputs.signing_key_pwd }}
SIGNING_KEY_FILE: ${{ inputs.signing_key_file }}
90 changes: 8 additions & 82 deletions Drop-In/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
plugins {
id 'com.android.library'
id 'de.marcphilipp.nexus-publish'
id 'signing'
id 'kotlin-android'
}

ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') ?: ''
ext["signing.password"] = System.getenv('SIGNING_KEY_PASSWORD') ?: ''
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEY_FILE') ?: ''

def LOCALHOST_IP = System.properties['LOCALHOST_IP'] ?: '"10.0.2.2"';
def GATEWAY_IP = System.properties['GATEWAY_IP'] ?: '"10.0.2.2"';
def GATEWAY_PORT = System.properties['GATEWAY_PORT'] ?: '"3000"';
Expand Down Expand Up @@ -115,84 +109,16 @@ dependencies {

// region signing and publishing

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

task javadocsJar(type: Jar, dependsOn: javadocs) {
archiveClassifier.set('javadoc')
from javadocs.destinationDir
}

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

signing {
required {
!version.endsWith("SNAPSHOT") && !version.endsWith("DEVELOPMENT")
}
sign publishing.publications
}

nexusPublishing {
// give nexus sonatype more time to initialize the staging repository
clientTimeout = Duration.ofMinutes(3)
useStaging = !rootProject.versionName.endsWith("SNAPSHOT")
repositories {
sonatype()
}
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

artifact sourcesJar
artifact javadocsJar

groupId = 'com.braintreepayments.api'
artifactId = 'drop-in'
version = rootProject.versionName

pom {
name = 'drop-in'
packaging = 'aar'
description = 'Drop-in payment form for Braintree\'s Android SDK. Integrate this library to add a readymade UI for your payments.'
url = 'https://github.com/braintree/braintree-android-drop-in'

scm {
url = 'scm:[email protected]:braintree/braintree-android-drop-in.git'
connection = 'scm:[email protected]:braintree/braintree-android-drop-in.git'
developerConnection = 'scm:[email protected]:braintree/braintree-android-drop-in.git'
}

developers {
developer {
id = 'devs'
name = 'Braintree Payments'
}
}

licenses {
license {
name = 'MIT'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
}
}
}
}
}
repositories {
mavenCentral()
}

project.ext.name = "drop-in"
project.ext.pom_name = "drop-in"
project.ext.group_id = "com.braintreepayments.api"
project.ext.version = rootProject.version
project.ext.pom_desc = "Drop-in payment form for Braintree\'s Android SDK. Integrate this library to add a readymade UI for your payments."

apply from: rootProject.file("gradle/gradle-publish.gradle")

// endregion
23 changes: 17 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ buildscript {
}

plugins {
id 'io.codearte.nexus-staging' version '0.21.2'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
}

version '6.13.1-SNAPSHOT'
group "com.braintreepayments"

ext {
compileSdkVersion = 34
minSdkVersion = 21
Expand Down Expand Up @@ -62,12 +64,21 @@ subprojects {
}
}

nexusStaging {
nexusPublishing {
useStaging = !rootProject.versionName.endsWith("SNAPSHOT")
packageGroup = "com.braintreepayments"
// give nexus sonatype more time to close the staging repository
delayBetweenRetriesInMillis = 20000
username = System.getenv('SONATYPE_USERNAME')
password = System.getenv('SONATYPE_PASSWORD')

repositories {
sonatype {
username = System.getenv('SONATYPE_NEXUS_USERNAME') ?: ''
password = System.getenv('SONATYPE_NEXUS_PASSWORD') ?: ''
}
}

transitionCheckOptions {
// give nexus sonatype more time to close the staging repository
delayBetween.set(Duration.ofSeconds(20))
}
}

task changeGradleReleaseVersion {
Expand Down
16 changes: 16 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,19 @@
# We can remove this option after the following dependencies have AndrdoidX builds:
# - com.google.android.gms:play-services-wallet
android.useAndroidX=true

POM_PACKAGING=aar

POM_URL=https://github.com/braintree/braintree-android-drop-in

POM_SCM_URL=scm:[email protected]:braintree/braintree-android-drop-in.git
POM_SCM_CONNECTION=scm:[email protected]:braintree/braintree-android-drop-in.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:braintree/braintree-android-drop-in.git

POM_LICENSE_NAME=MIT
POM_LICENSE_URL=http://opensource.org/licenses/MIT
POM_LICENSE_DISTRIBUTION=repo

POM_DEVELOPER_ID=devs
POM_DEVELOPER_NAME=Braintree Payments
POM_DEVELOPER_EMAIL=[email protected]
75 changes: 75 additions & 0 deletions gradle/gradle-publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'


ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') ?: ''
ext["signing.password"] = System.getenv('SIGNING_KEY_PASSWORD') ?: ''
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEY_FILE') ?: ''

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId project.ext.group_id
version project.ext.version
artifactId project.ext.name
from components.release
artifact androidSourcesJar
artifact javadocsJar

pom {
name = project.ext.pom_name ?: ''
packaging = POM_PACKAGING
description = project.ext.pom_desc ?: ''
url = POM_URL
licenses {
license {
name = POM_LICENSE_NAME
url = POM_LICENSE_URL
distribution = POM_LICENSE_DISTRIBUTION
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
email = POM_DEVELOPER_EMAIL
}
}
scm {
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
url = POM_SCM_URL
}
}
}
}
}

signing {
sign publishing.publications
sign configurations.archives
}
}

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

task javadocsJar(type: Jar, dependsOn: javadocs) {
archiveClassifier.set('javadoc')
from javadocs.destinationDir
}

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

artifacts {
archives androidSourcesJar
archives javadocsJar
}

0 comments on commit 9e5c0aa

Please sign in to comment.