From 05c308711aa82c8e255272a0fad8230b797dc1ed Mon Sep 17 00:00:00 2001 From: ankitkumar Date: Sat, 10 Feb 2024 02:48:36 +0530 Subject: [PATCH] changes to publish to maven central --- app/build.gradle | 4 +- build.gradle | 14 +++++++ gradle/publish-package.gradle | 75 +++++++++++++++++++++++++++++++++++ rating-bar/build.gradle | 5 +++ settings.gradle | 1 - 5 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 gradle/publish-package.gradle diff --git a/app/build.gradle b/app/build.gradle index a83b817..546ed9a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,7 @@ dependencies { implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" implementation "androidx.compose.material:material:$compose_ui_version" - implementation 'com.github.pseudoankit:RatingBarCompose:v1.0' + implementation 'io.github.pseudoankit:rating-bar:1.0.0' - // implementation project(':rating-bar') +// implementation project(':rating-bar') } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 20c3098..cf6ebba 100644 --- a/build.gradle +++ b/build.gradle @@ -14,8 +14,22 @@ buildscript { plugins { id 'org.jetbrains.kotlin.android' version '1.6.10' apply false + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' } task clean(type: Delete) { delete rootProject.buildDir +} + +nexusPublishing { + repositories { + sonatype { + username = System.getenv("OSS_USERNAME") + password = System.getenv("OSS_PASSWORD") + stagingProfileId = System.getenv("OSS_STAGING_PROFILE_ID") + + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + } + } } \ No newline at end of file diff --git a/gradle/publish-package.gradle b/gradle/publish-package.gradle new file mode 100644 index 0000000..c2f3195 --- /dev/null +++ b/gradle/publish-package.gradle @@ -0,0 +1,75 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +ext { + GROUP_ID = "io.github.pseudoankit" + VERSION = (System.getenv("RELEASE_TAG_NAME") ?: "SNAPSHOT").replace("v", "") + + SITE_URL = 'https://github.com/pseudoankit/ratingbar-compose' + GIT_URL = 'https://github.com/pseudoankit/ratingbar-compose.git' + + POM_DESCRIPTION = "Compose library to add rating bar" + POM_URL = SITE_URL +} + +signing { + useInMemoryPgpKeys( + System.getenv("OSS_SIGNING_KEY_ID"), + System.getenv("OSS_SIGNING_KEY"), + System.getenv("OSS_SIGNING_PASSWORD"), + ) + sign publishing.publications +} + +// If you want to publish your sources as well +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') + from android.sourceSets.main.java.srcDirs + from android.sourceSets.main.kotlin.srcDirs +} + +artifacts { + archives androidSourcesJar +} + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + + groupId GROUP_ID + artifactId ARTIFACT_ID + version VERSION + + from components.release + artifact androidSourcesJar + + pom { + name = ARTIFACT_ID + description = POM_DESCRIPTION + url = POM_URL + licenses { + license { + name = "The Apache Software License, Version 2.0" + url = "https://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + + developers { + developer { + id = 'pseudoankit' + name = 'Ankit Kumar' + email = 'lostankit7@gmail.com' + } + } + + scm { + connection = GIT_URL + developerConnection = GIT_URL + url = SITE_URL + } + } + } + } + } +} \ No newline at end of file diff --git a/rating-bar/build.gradle b/rating-bar/build.gradle index dabe27e..79af1c0 100644 --- a/rating-bar/build.gradle +++ b/rating-bar/build.gradle @@ -3,6 +3,11 @@ plugins { id 'org.jetbrains.kotlin.android' } +apply from: '../gradle/publish-package.gradle' +ext { + ARTIFACT_ID = "rating-bar" +} + android { namespace 'pseudoankit.droid.rating_bar' compileSdk 33 diff --git a/settings.gradle b/settings.gradle index 52c2301..7b46ab5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,6 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://jitpack.io' } } } rootProject.name = "ComposeRatingBar"