From 15a744c842543027b13ce045c13e1acdc685e2e6 Mon Sep 17 00:00:00 2001 From: Dmitriy Gorbunov Date: Sun, 7 Feb 2021 15:18:54 +0300 Subject: [PATCH] Setup publishing to mavenCentral --- rxpm/androidmaven.gradle | 16 ----- rxpm/bintray.gradle | 25 ------- rxpm/build.gradle | 35 ++-------- rxpm/publish-mavencentral.gradle | 116 +++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 71 deletions(-) delete mode 100644 rxpm/androidmaven.gradle delete mode 100644 rxpm/bintray.gradle create mode 100644 rxpm/publish-mavencentral.gradle diff --git a/rxpm/androidmaven.gradle b/rxpm/androidmaven.gradle deleted file mode 100644 index b6c1247..0000000 --- a/rxpm/androidmaven.gradle +++ /dev/null @@ -1,16 +0,0 @@ -apply plugin: 'com.github.dcendents.android-maven' - -group = publishedGroupId - -install { - repositories.mavenInstaller { - // This generates POM.xml with proper parameters - pom { - project { - packaging 'aar' - groupId publishedGroupId - artifactId artifactId - } - } - } -} \ No newline at end of file diff --git a/rxpm/bintray.gradle b/rxpm/bintray.gradle deleted file mode 100644 index 253da84..0000000 --- a/rxpm/bintray.gradle +++ /dev/null @@ -1,25 +0,0 @@ -apply plugin: 'com.jfrog.bintray' - -version = libraryVersion - -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) - -bintray { - - user = properties.getProperty("bintrayUser") - key = properties.getProperty("bintrayApiKey") - - configurations = ['archives'] - - pkg { - repo = bintrayRepo - name = bintrayName - licenses = allLicenses - vcsUrl = gitUrl - publish = true - } -} - -// Dependency to call only bintrayUpload task -bintrayUpload.dependsOn install \ No newline at end of file diff --git a/rxpm/build.gradle b/rxpm/build.gradle index 67e4968..a388cdf 100644 --- a/rxpm/build.gradle +++ b/rxpm/build.gradle @@ -1,13 +1,3 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' - } -} - apply plugin: 'com.android.library' apply plugin: 'kotlin-android' @@ -36,6 +26,7 @@ android { main.java.srcDirs += 'src/main/kotlin' test.java.srcDirs += 'src/test/kotlin' } + } dependencies { @@ -68,25 +59,9 @@ dependencies { } ext { - bintrayRepo = 'maven' - bintrayName = 'RxPM' - publishedGroupId = 'me.dmdev.rxpm' - artifact = 'rxpm' - libraryVersion = '1.2.5' - gitUrl = 'https://github.com/dmdevgo/RxPM' - allLicenses = ['MIT'] + PUBLISH_GROUP_ID = 'me.dmdev.rxpm' + PUBLISH_VERSION = '1.2.6' + PUBLISH_ARTIFACT_ID = 'rxpm' } -// Configuration of the library uploading to the Bintray -// Note: Call 'bintrayUpload' task (it will execute 'install' task first) -apply from: 'androidmaven.gradle' -apply from: 'bintray.gradle' - -task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - classifier = 'sources' -} - -artifacts { - archives sourcesJar -} +apply from: "publish-mavencentral.gradle" \ No newline at end of file diff --git a/rxpm/publish-mavencentral.gradle b/rxpm/publish-mavencentral.gradle new file mode 100644 index 0000000..9e26db4 --- /dev/null +++ b/rxpm/publish-mavencentral.gradle @@ -0,0 +1,116 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') + if (project.plugins.findPlugin("com.android.library")) { + from android.sourceSets.main.java.srcDirs + } else { + from sourceSets.main.java.srcDirs + } +} + +artifacts { + archives androidSourcesJar +} + + +group = PUBLISH_GROUP_ID +version = PUBLISH_VERSION + +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +File secretPropsFile = project.rootProject.file('local.properties') +if (secretPropsFile.exists()) { + Properties p = new Properties() + p.load(new FileInputStream(secretPropsFile)) + p.each { name, value -> + ext[name] = value + } +} else { + ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') + ext["signing.password"] = System.getenv('SIGNING_PASSWORD') + ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') +} + +publishing { + publications { + release(MavenPublication) { + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + if (project.plugins.findPlugin("com.android.library")) { + artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") + } else { + artifact("$buildDir/libs/${project.getName()}-${version}.jar") + } + + artifact androidSourcesJar + + pom { + name = PUBLISH_ARTIFACT_ID + description = 'Reactive implementation of Presentation Model pattern in Android' + url = 'https://github.com/dmdevgo/RxPM' + licenses { + license { + name = 'MIT' + url = 'https://github.com/dmdevgo/RxPM/blob/develop/LICENSE' + } + } + developers { + developer { + id = 'dmdev' + name = 'Dmitriy Gorbunov' + email = 'dmitriy.goto@gmail.com' + } + developer { + id = 'jeevuz' + name = 'Vasili Chyrvon' + email = 'vasili.chyrvon@gmail.com' + } + } + scm { + connection = 'scm:git@github.com:dmdevgo/RxPM.git' + developerConnection = 'scm:git@github.com:dmdevgo/RxPM.git' + url = 'https://github.com/dmdevgo/RxPM' + } + withXml { + def dependenciesNode = asNode().appendNode('dependencies') + + project.configurations.implementation.allDependencies.each { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + } + } + } + } + } + repositories { + maven { + name = "sonatype" + + def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + + credentials { + username ossrhUsername + password ossrhPassword + } + } + } +} + +signing { + sign publishing.publications +} \ No newline at end of file