From bd12eec00f030167e5f53028f1ad3e4ab78e5606 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 20 Apr 2023 17:08:14 +0700 Subject: [PATCH] add scripts to publish --- animatednavbar/build.gradle | 22 ++++++++- animatednavbar/publish-module.gradle | 70 ++++++++++++++++++++++++++++ build.gradle | 3 ++ scripts/publish-root.gradle | 37 +++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 animatednavbar/publish-module.gradle create mode 100644 scripts/publish-root.gradle diff --git a/animatednavbar/build.gradle b/animatednavbar/build.gradle index a31d9c3..b611dd7 100644 --- a/animatednavbar/build.gradle +++ b/animatednavbar/build.gradle @@ -3,6 +3,24 @@ plugins { id 'org.jetbrains.kotlin.android' } +ext { + PUBLISH_GROUP_ID = 'com.exyte' + PUBLISH_VERSION = '1.0.0' + PUBLISH_ARTIFACT_ID = 'animated-navigation-bar' + PUBLISH_DESCRIPTION = 'navigation bar with a number of preset animations' + PUBLISH_URL = 'https://github.com/exyte/AndroidAnimatedNavigationBar' + PUBLISH_LICENSE_NAME = 'MIT License' + PUBLISH_LICENSE_URL = 'https://github.com/exyte/AndroidAnimatedNavigationBar/blob/master/LICENSE' + PUBLISH_DEVELOPER_ID = 'exyte' + PUBLISH_DEVELOPER_NAME = 'Alex Yudenkov' + PUBLISH_DEVELOPER_EMAIL = 'alexydenkov@gmail.com' + PUBLISH_SCM_CONNECTION = 'scm:git:github.com/exyte/AndroidAnimatedNavigationBar.git' + PUBLISH_SCM_DEVELOPER_CONNECTION = 'scm:git:ssh://github.com/exyte/AndroidAnimatedNavigationBar.git' + PUBLISH_SCM_URL = 'https://github.com/exyte/AndroidAnimatedNavigationBar/tree/master' +} + +apply from: "publish-module.gradle" + android { compileSdk 33 @@ -44,8 +62,8 @@ android { } dependencies { - implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.core:core-ktx:1.10.0' implementation "androidx.compose.ui:ui:$compose_ui_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version" - implementation 'androidx.compose.material:material:1.3.1' + implementation 'androidx.compose.material:material:1.4.1' } \ No newline at end of file diff --git a/animatednavbar/publish-module.gradle b/animatednavbar/publish-module.gradle new file mode 100644 index 0000000..ccca4ae --- /dev/null +++ b/animatednavbar/publish-module.gradle @@ -0,0 +1,70 @@ +apply plugin: 'maven-publish' +apply plugin: 'signing' + +tasks.register('androidSourcesJar', 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 + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + from components.release + + artifact androidSourcesJar + + pom { + name = PUBLISH_ARTIFACT_ID + description = PUBLISH_DESCRIPTION + url = PUBLISH_URL + licenses { + license { + name = PUBLISH_LICENSE_NAME + url = PUBLISH_LICENSE_URL + } + } + developers { + developer { + id = PUBLISH_DEVELOPER_ID + name = PUBLISH_DEVELOPER_NAME + email = PUBLISH_DEVELOPER_EMAIL + } + } + + scm { + connection = PUBLISH_SCM_CONNECTION + developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION + url = PUBLISH_SCM_URL + } + } + } + } + } +} + +signing { + useInMemoryPgpKeys( + rootProject.ext["signing.keyId"], + rootProject.ext["signing.key"], + rootProject.ext["signing.password"] + ) + sign publishing.publications +} diff --git a/build.gradle b/build.gradle index 9ab57a5..beffa22 100644 --- a/build.gradle +++ b/build.gradle @@ -9,8 +9,11 @@ plugins { id 'com.android.application' version '7.4.2' apply false id 'com.android.library' version '7.4.2' apply false id 'org.jetbrains.kotlin.android' version '1.8.10' apply false + id 'io.github.gradle-nexus.publish-plugin' version "1.3.0" } +apply from: 'scripts/publish-root.gradle' + subprojects { tasks.withType(KotlinCompile).configureEach { if (project.findProperty("navBar.enableComposeCompilerReports") == "true") { diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle new file mode 100644 index 0000000..243b2f1 --- /dev/null +++ b/scripts/publish-root.gradle @@ -0,0 +1,37 @@ +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.key"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + + +File secretPropsFile = project.rootProject.file('local.properties') +if (secretPropsFile.exists()) { + Properties p = new Properties() + new FileInputStream(secretPropsFile).withCloseable { is -> + p.load(is) + } + p.each { name, value -> + ext[name] = value + } +} else { + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + ext['signing.keyId'] = System.getenv('SIGNING_KEY_ID') + ext['signing.password'] = System.getenv('SIGNING_PASSWORD') + ext["signing.key"] = System.getenv('SIGNING_KEY') +} + +nexusPublishing { + repositories { + sonatype { + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword + 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