From 5631ee2160dda925fbb993282063e728aa33997f Mon Sep 17 00:00:00 2001 From: Javier Su Date: Mon, 5 Apr 2021 14:55:48 +0800 Subject: [PATCH] Updated with gradle tasks to upload to maven central --- build.gradle | 7 ++- gradle.properties | 5 ++- xendit-android/build.gradle | 89 +++++++++++++++++++++++++++++++++++-- 3 files changed, 95 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 7a3f0bf..4ddbeb3 100644 --- a/build.gradle +++ b/build.gradle @@ -5,12 +5,13 @@ buildscript { google() jcenter() mavenLocal() + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.6.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' - + classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -26,4 +27,6 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir -} \ No newline at end of file +} + +apply plugin: 'io.codearte.nexus-staging' \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 46de1e0..8c398b5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,4 +17,7 @@ org.gradle.jvmargs=-Xmx1536m # org.gradle.parallel=true android.useAndroidX=true -#android.enableJetifier=true \ No newline at end of file +android.enableJetifier=true + +signing.keyId=619A4A2B +signing.secretKeyRingFile=../secring.gpg diff --git a/xendit-android/build.gradle b/xendit-android/build.gradle index 9f544dd..5db4aac 100644 --- a/xendit-android/build.gradle +++ b/xendit-android/build.gradle @@ -26,7 +26,7 @@ ext { developerEmail = 'juan@xendit.co' licenseName = 'MIT' - licenseUrl = '' + licenseUrl = 'https://opensource.org/licenses/MIT' allLicenses = ["MIT"] } @@ -141,5 +141,88 @@ publishing { tasks.withType(Javadoc).all { enabled = false } -apply from: 'https://raw.githubusercontent.com/xendit/xendit-sdk-android/master/installv1.gradle' -apply from: 'https://raw.githubusercontent.com/xendit/xendit-sdk-android/master/bintrayv1.gradle' +apply plugin: 'maven' +apply plugin: 'signing' + +if (project.hasProperty("android")) { // Android libraries + task sourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + } + + task javadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + } +} else { // Java libraries + task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } +} + +artifacts { + archives sourcesJar +} + +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) +String ossrhUser = properties.getProperty('ossrh.username') +String ossrhPassword = properties.getProperty('ossrh.password') + +signing { + sign configurations.archives +} + +uploadArchives { + repositories { + mavenDeployer { + + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUser, password: ossrhPassword) + } + + snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUser, password: ossrhPassword) + } + + pom.project { + name bintrayName + packaging 'aar' + // optionally artifactId can be defined here + description libraryDescription + url siteUrl + + scm { + connection gitUrl + developerConnection gitUrl + url gitUrl + } + + licenses { + license { + name licenseName + url licenseUrl + } + } + + developers { + developer { + id developerId + name developerName + email developerEmail + } + } + } + } + } +} + +nexusStaging { + serverUrl = 'https://s01.oss.sonatype.org/service/local/' + username = ossrhUser + password = ossrhPassword + repositoryDescription = 'Closed and released using gradle script' +} \ No newline at end of file