From e989c19b07808e1dedbb2a00ef25deedb6883945 Mon Sep 17 00:00:00 2001 From: skydoves Date: Wed, 17 Jul 2024 05:32:06 +0900 Subject: [PATCH] Migrate to nexus plugin plugin --- build.gradle.kts | 4 +- cloudy/build.gradle.kts | 21 +++++--- gradle.properties | 28 +++++++++- gradle/libs.versions.toml | 4 +- scripts/publish-module.gradle | 87 ------------------------------- scripts/publish-module.gradle.kts | 13 +++++ scripts/publish-root.gradle | 46 ---------------- 7 files changed, 58 insertions(+), 145 deletions(-) delete mode 100644 scripts/publish-module.gradle create mode 100644 scripts/publish-module.gradle.kts delete mode 100644 scripts/publish-root.gradle diff --git a/build.gradle.kts b/build.gradle.kts index 5559e24..1cda1e0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,14 +4,12 @@ plugins { alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.compose.compiler) apply false - alias(libs.plugins.nexusPlugin) + alias(libs.plugins.nexus.plugin) alias(libs.plugins.spotless) alias(libs.plugins.dokka) alias(libs.plugins.kotlinBinaryCompatibilityValidator) } -apply(from ="${rootDir}/scripts/publish-root.gradle") - apiValidation { ignoredProjects.addAll(listOf("app")) } diff --git a/cloudy/build.gradle.kts b/cloudy/build.gradle.kts index 67e8c88..6d3ed1a 100644 --- a/cloudy/build.gradle.kts +++ b/cloudy/build.gradle.kts @@ -20,15 +20,24 @@ plugins { id(libs.plugins.android.library.get().pluginId) id(libs.plugins.kotlin.android.get().pluginId) id(libs.plugins.compose.compiler.get().pluginId) + id(libs.plugins.nexus.plugin.get().pluginId) } -rootProject.extra.apply { - set("PUBLISH_GROUP_ID", Configuration.artifactGroup) - set("PUBLISH_ARTIFACT_ID", "cloudy") - set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName")) -} +apply(from = "${rootDir}/scripts/publish-module.gradle.kts") + +mavenPublishing { + val artifactId = "cloudy" + coordinates( + Configuration.artifactGroup, + artifactId, + rootProject.extra.get("libVersion").toString() + ) -apply(from ="${rootDir}/scripts/publish-module.gradle") + pom { + name.set(artifactId) + description.set("Jetpack Compose blur effect library, which falls back onto a CPU-based implementation to support older API levels.") + } +} android { compileSdk = Configuration.compileSdk diff --git a/gradle.properties b/gradle.properties index 995ce83..3bf2de4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -41,4 +41,30 @@ android.defaults.buildfeatures.shaders=false # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library # https://developer.android.com/studio/releases/gradle-plugin#4.1-nontransitive-r-class -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true + +## Maven Central Publication ## +systemProp.org.gradle.internal.publish.checksums.insecure=true + +# Increase timeout when pushing to Sonatype (otherwise we get timeouts) +systemProp.org.gradle.internal.http.socketTimeout=120000 + +GROUP=com.github.skydoves + +POM_URL=https://github.com/skydoves/cloudy/ +POM_SCM_URL=https://github.com/skydoves/cloudy/ +POM_SCM_CONNECTION=scm:git:git://github.com/skydoves/cloudy.git +POM_SCM_DEV_CONNECTION=scm:git:git://github.com/skydoves/cloudy.git + +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo + +POM_DEVELOPER_ID=skydoves +POM_DEVELOPER_NAME=Jaewoong Eum +POM_DEVELOPER_URL=https://github.com/cloudy/ +POM_DEVELOPER_EMAIL=skydoves2@gmail.com + +SONATYPE_HOST=DEFAULT +RELEASE_SIGNING_ENABLED=true +SONATYPE_AUTOMATIC_RELEASE=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0d965fc..92acd44 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ dokka = "1.9.20" javaRelease = "11" jvmTarget = "11" material = "1.12.0" -mavenPublish = "1.3.0" +nexusPlugin = "0.29.0" binaryCompatibility = "0.14.0" androidxActivity = "1.9.0" androidxComposeBom = "2024.06.00" @@ -25,7 +25,7 @@ android-library = { id = "com.android.library", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } -nexusPlugin = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "mavenPublish" } +nexus-plugin = { id = "com.vanniktech.maven.publish", version.ref = "nexusPlugin" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } kotlinBinaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatibility" } diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle deleted file mode 100644 index 40d8b0c..0000000 --- a/scripts/publish-module.gradle +++ /dev/null @@ -1,87 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'org.jetbrains.dokka' - -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 - } -} - -tasks.withType(dokkaHtmlPartial.getClass()).configureEach { - pluginsMapConfiguration.set( - ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""] - ) -} - -task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { - archiveClassifier.set('javadoc') - from dokkaJavadoc.outputDirectory -} - -artifacts { - archives androidSourcesJar - archives javadocJar -} - -group = PUBLISH_GROUP_ID -version = PUBLISH_VERSION - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - groupId PUBLISH_GROUP_ID - artifactId PUBLISH_ARTIFACT_ID - version PUBLISH_VERSION - if (project.plugins.findPlugin("com.android.library")) { - from components.release - } else { - from components.java - } - - artifact androidSourcesJar - artifact javadocJar - - pom { - name = PUBLISH_ARTIFACT_ID - description = 'Jetpack Compose blur process library, which supports all Android versions.' - url = 'https://github.com/skydoves/cloudy' - licenses { - license { - name = 'The Apache Software License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id = 'skydoves' - name = 'Jaewoong Eum' - email = "skydoves2@gmail.com" - url = "https://github.com/skydoves" - } - } - scm { - connection = 'scm:git:github.com/skydoves/cloudy.git' - developerConnection = 'scm:git:ssh://github.com/skydoves/cloudy.git' - url = 'https://github.com/skydoves/cloudy/tree/main' - } - } - } - } - } -} - -signing { - useInMemoryPgpKeys( - rootProject.ext["signing.keyId"], - rootProject.ext["signing.key"], - rootProject.ext["signing.password"], - ) - sign publishing.publications -} diff --git a/scripts/publish-module.gradle.kts b/scripts/publish-module.gradle.kts new file mode 100644 index 0000000..77d5428 --- /dev/null +++ b/scripts/publish-module.gradle.kts @@ -0,0 +1,13 @@ +import com.skydoves.cloudy.Configuration + +apply(plugin = "com.vanniktech.maven.publish") + +rootProject.extra.apply { + val snapshot = System.getenv("SNAPSHOT").toBoolean() + val libVersion = if (snapshot) { + Configuration.snapshotVersionName + } else { + Configuration.versionName + } + set("libVersion", libVersion) +} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle deleted file mode 100644 index 9532bb8..0000000 --- a/scripts/publish-root.gradle +++ /dev/null @@ -1,46 +0,0 @@ -import com.skydoves.cloudy.Configuration - -// Create variables with empty default values - -ext["ossrhUsername"] = '' -ext["ossrhPassword"] = '' -ext["sonatypeStagingProfileId"] = '' -ext["signing.keyId"] = '' -ext["signing.password"] = '' -ext["signing.key"] = '' -ext["snapshot"] = '' - -File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { - // Read local.properties file first if it exists - Properties p = new Properties() - new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } - p.each { name, value -> ext[name] = value } -} else { - // Use system environment variables - 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') - ext["snapshot"] = System.getenv('SNAPSHOT') -} - -if (snapshot) { - ext["rootVersionName"] = Configuration.snapshotVersionName -} else { - ext["rootVersionName"] = Configuration.versionName -} - -// Set up Sonatype repository -nexusPublishing { - repositories { - sonatype { - stagingProfileId = sonatypeStagingProfileId - username = ossrhUsername - password = ossrhPassword - version = rootVersionName - } - } -}