From 98bb4f1b93be5495e178f87d7234726503a7be38 Mon Sep 17 00:00:00 2001 From: Erick Tijero Date: Sun, 1 Aug 2021 22:55:14 -0500 Subject: [PATCH] Migrate maven to jcenter --- .github/workflows/publish.yml | 32 +++++++ README.md | 18 ++-- build.gradle.kts | 109 +++-------------------- buildSrc/build.gradle.kts | 1 - buildSrc/extra.gradle.kts | 2 +- buildSrc/src/main/kotlin/Dependencies.kt | 10 +-- gradle.properties | 2 +- scripts/publish-module.gradle | 85 ++++++++++++++++++ scripts/publish-root.gradle | 36 ++++++++ 9 files changed, 182 insertions(+), 113 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 scripts/publish-module.gradle create mode 100644 scripts/publish-root.gradle diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..dc5c532 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,32 @@ +name: Publish + +on: + release: + types: [released] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + - name: Release build + # assembleRelease for all modules, excluding non-library modules: samples, docs + run: ./gradlew assembleRelease -x :stream-chat-android-sample:assembleRelease -x :stream-chat-android-ui-components-sample:assembleRelease -x :stream-chat-android-compose-sample:assembleRelease -x :stream-chat-android-docs:assembleRelease + - name: Source jar and dokka + run: ./gradlew androidSourcesJar javadocJar + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} \ No newline at end of file diff --git a/README.md b/README.md index ba2f35d..6f7f645 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,11 @@ > The easiest library to show skeleton screens in an Android app. -[![bintray](https://api.bintray.com/packages/ericktijerou/maven/koleton/images/download.svg)](https://bintray.com/ericktijerou/maven/koleton/_latestVersion) -[![Build Status](https://travis-ci.com/ericktijerou/koleton.svg?branch=master)](https://travis-ci.com/ericktijerou/koleton) -[![Kotlin](https://img.shields.io/badge/Kotlin-1.4.30-blueviolet.svg)](https://kotlinlang.org) + + +[![Kotlin](https://img.shields.io/badge/Kotlin-1.5.10-blueviolet.svg)](https://kotlinlang.org) + + ![Minimum SDK Version](https://img.shields.io/badge/minSdkVersion-14-brightgreen.svg) An Android library that provides an easy way to show skeleton of any view. @@ -18,19 +20,19 @@ Made with ❤ by [ericktijerou](https://ericktijerou.com). ![img](image/journey_detail.gif) ## Installation -You can [download](https://bintray.com/ericktijerou/maven/koleton/_latestVersion) and install `Koleton` with `Maven` and `Gradle`: +You can [download](https://bintray.com/ericktijerou/maven/koleton/_latestVersion) and install `Koleton` with `Maven Central` and `Gradle`: ```gradle // In your module's `build.gradle.kts` dependencies { - implementation("com.ericktijerou.koleton:koleton:0.8.8") + implementation("com.ericktijerou.koleton:koleton:1.0.0-beta01") } ``` -Make sure to include `jcenter()` in your repositories +Make sure to include `mavenCentral()` in your repositories ```gradle repositories { - jcenter() + mavenCentral() } ``` @@ -176,4 +178,4 @@ You can find more information about Facebook's shimmer effect on the [shimmer-an distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License. diff --git a/build.gradle.kts b/build.gradle.kts index 65bc391..9a7b506 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,16 +6,17 @@ plugins { java kotlin("jvm") `maven-publish` - id(Release.Bintray.plugin) version Release.Bintray.version + id(Release.Nexus.plugin) version Release.Nexus.version + id("org.jetbrains.dokka") version "1.5.0" apply false } + buildscript { apply(from = "buildSrc/extra.gradle.kts") repositories { google() mavenCentral() gradlePluginPortal() - jcenter() } dependencies { classpath(rootProject.extra["androidPlugin"].toString()) @@ -28,10 +29,11 @@ allprojects { repositories { google() mavenCentral() - jcenter() } } +apply(from ="${rootDir}/scripts/publish-root.gradle") + val androidModules = listOf("koleton-singleton", "koleton-base") val androidSampleModules = listOf("koleton-sample") @@ -109,18 +111,6 @@ subprojects { testOptions { unitTests.isReturnDefaultValues = true } - - val sourcesJar by tasks.registering(Jar::class) { - from(sourceSets["main"].java.srcDirs) - archiveClassifier.set("sources") - } - - val doc by tasks.creating(Javadoc::class) { - isFailOnError = false - source = sourceSets["main"].java.getSourceFiles() - classpath += files(bootClasspath.joinToString(File.pathSeparator)) - classpath.plus(configurations["compile"]) - } } if (!isSample) { @@ -130,7 +120,7 @@ subprojects { apply { plugin(Release.MavenPublish.plugin) - plugin(Release.Bintray.plugin) + plugin("org.jetbrains.dokka") } tasks.withType { @@ -144,89 +134,14 @@ subprojects { implementation(Kotlin.stdlib) } - bintray { - user = findProperty("bintrayUser") as? String - key = findProperty("bintrayKey") as? String - publish = !project.publishVersion.endsWith("SNAPSHOT") - setPublications(artifactName) - with(pkg) { - repo = Koleton.repository - name = artifactName - desc = Koleton.description - githubRepo = project.vcsUrl - userOrg = Developer.id - websiteUrl = project.vcsUrl - vcsUrl = project.vcsUrl - issueTrackerUrl = project.issueTrackerUrl - setLicenses(Koleton.licenseName) - with(version) { - name = project.publishVersion - vcsTag = "v${project.publishVersion}" - } - } + ext { + set("PUBLISH_GROUP_ID", project.groupId) + set("PUBLISH_VERSION", project.publishVersion) + set("PUBLISH_ARTIFACT_ID", artifactName) } - fun org.gradle.api.publish.maven.MavenPom.addDependencies() = withXml { - asNode().appendNode("dependencies").let { depNode -> - configurations.implementation.get().allDependencies.forEach { - depNode.appendNode("dependency").apply { - appendNode("groupId", it.group) - appendNode("artifactId", it.name) - appendNode("version", it.version) - } - } - } - } - - val javadocJar by tasks.creating(Jar::class) { - val doc by tasks - dependsOn(doc) - from(doc) - archiveClassifier.set("javadoc") - } + apply(from = "${rootProject.projectDir}/scripts/publish-module.gradle") - val sourcesJar by tasks - publishing { - publications { - register(artifactName, MavenPublication::class) { - if (project.hasProperty("android")) { - artifact("$buildDir/outputs/aar/${project.name}-release.aar") { - builtBy(tasks.getByPath("assemble")) - } - } else { - from(components["java"]) - } - groupId = project.groupId - artifactId = artifactName - version = project.publishVersion - artifact(sourcesJar) - artifact(javadocJar) - pom { - name.set(artifactName) - description.set(Koleton.description) - url.set(project.vcsUrl) - scm { url.set(project.vcsUrl) } - issueManagement { url.set(project.issueTrackerUrl) } - licenses { - license { - name.set(Koleton.licenseName) - url.set(Koleton.licenseUrl) - } - } - developers { - developer { - id.set(Developer.id) - name.set(Developer.name) - } - } - } - if (project.hasProperty("android")) { - pom.addDependencies() - } - } - } - } } } -} - +} \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 52f5daa..cc35ace 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -5,7 +5,6 @@ plugins { repositories { google() mavenCentral() - jcenter() } apply(from = "extra.gradle.kts") diff --git a/buildSrc/extra.gradle.kts b/buildSrc/extra.gradle.kts index d325ffa..8ed0ebf 100644 --- a/buildSrc/extra.gradle.kts +++ b/buildSrc/extra.gradle.kts @@ -1,4 +1,4 @@ rootProject.extra.apply { set("androidPlugin", "com.android.tools.build:gradle:4.1.1") - set("kotlinPlugin", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30") + set("kotlinPlugin", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 4bb3b51..2d6499f 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -34,7 +34,7 @@ object Versions { } object Kotlin { - const val version = "1.4.30" + const val version = "1.5.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val plugin = "kotlin" const val androidPlugin = "kotlin-android" @@ -50,15 +50,15 @@ object Release { const val plugin = "maven-publish" } - object Bintray { - const val version = "1.8.5" - const val plugin = "com.jfrog.bintray" + object Nexus { + const val version = "1.1.0" + const val plugin = "io.github.gradle-nexus.publish-plugin" } } object Developer { const val id = "ericktijerou" - const val name = "Erick Tijero" + const val fullName = "Erick Tijero" } object Koleton { diff --git a/gradle.properties b/gradle.properties index 978faee..357508d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,4 +27,4 @@ compileSdk=30 groupId=com.ericktijerou.koleton vcsUrl=https://github.com/ericktijerou/koleton issueTrackerUrl=https://github.com/ericktijerou/koleton/issues -publishVersion=0.8.8 \ No newline at end of file +publishVersion=1.0.0-beta01 \ No newline at end of file diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle new file mode 100644 index 0000000..dbe049d --- /dev/null +++ b/scripts/publish-module.gradle @@ -0,0 +1,85 @@ +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 = Koleton.description + url = project.vcsUrl + licenses { + license { + name = Koleton.licenseName + url = Koleton.licenseUrl + } + } + developers { + developer { + id = Developer.id + name = Developer.fullName + } + } + scm { + connection = 'scm:git:github.com/ericktijerou/koleton.git' + developerConnection = 'scm:git:ssh://github.com/ericktijerou/koleton.git' + url = 'https://github.com/ericktijerou/koleton/tree/main' + } + } + } + } + } +} + +signing { + useInMemoryPgpKeys( + rootProject.ext["signing.keyId"], + rootProject.ext["signing.key"], + rootProject.ext["signing.password"], + ) + sign publishing.publications +} \ No newline at end of file diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle new file mode 100644 index 0000000..4b02e19 --- /dev/null +++ b/scripts/publish-root.gradle @@ -0,0 +1,36 @@ +// Create variables with empty default values +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.key"] = '' + +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') +} + +// Set up Sonatype repository +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