From a82e81b6ab1132efdd311e3b17668b8f8a28dad0 Mon Sep 17 00:00:00 2001 From: Sparrow007 Date: Sun, 14 Mar 2021 16:44:54 +0530 Subject: [PATCH] update for library deployment --- .idea/.name | 1 + build.gradle | 1 + carouselrecyclerview/build.gradle | 12 ++- scripts/publish-mavencentral.gradle | 114 ++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 .idea/.name create mode 100644 scripts/publish-mavencentral.gradle diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..826d356 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +CarouselLayout \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4e6e31c..3e79259 100644 --- a/build.gradle +++ b/build.gradle @@ -11,6 +11,7 @@ buildscript { // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } diff --git a/carouselrecyclerview/build.gradle b/carouselrecyclerview/build.gradle index f9c98ae..cfc0338 100644 --- a/carouselrecyclerview/build.gradle +++ b/carouselrecyclerview/build.gradle @@ -1,7 +1,9 @@ plugins { id 'com.android.library' id 'kotlin-android' + id 'com.github.dcendents.android-maven' } +group = 'com.github.sparrow007' android { compileSdkVersion 30 @@ -34,4 +36,12 @@ android { dependencies { implementation 'com.google.android.material:material:1.3.0' -} \ No newline at end of file +} + +ext { + PUBLISH_GROUP_ID = 'com.github.sparrow007' + PUBLISH_VERSION = '1.0.0' + PUBLISH_ARTIFACT_ID = 'carouselrecyclerview' +} + +apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle" \ No newline at end of file diff --git a/scripts/publish-mavencentral.gradle b/scripts/publish-mavencentral.gradle new file mode 100644 index 0000000..7a13f06 --- /dev/null +++ b/scripts/publish-mavencentral.gradle @@ -0,0 +1,114 @@ +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 + from android.sourceSets.main.kotlin.srcDirs + } else { + from sourceSets.main.java.srcDirs + from sourceSets.main.kotlin.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 = 'Create carousel effect in recyclerview with the CarouselRecyclerview in a simple way.' + url = 'https://github.com/sparrow007/CarouselRecyclerview' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'sparrow007' + name = 'Ankit kumar' + email = 'ankit.steven007@gmail.com' + } + } + scm { + connection = 'scm:git:github.com/sparrow007/CarouselRecyclerview.git' + developerConnection = 'scm:git:ssh://github.com/sparrow007/CarouselRecyclerview.git' + url = 'https://github.com/sparrow007/CarouselRecyclerview/tree/main' + } + 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