From 5f377a87baa0e91ea96d578f25e20e2f3dd2d7db Mon Sep 17 00:00:00 2001 From: Yves Kalume <55670723+yveskalume@users.noreply.github.com> Date: Tue, 25 Jun 2024 22:59:18 +0300 Subject: [PATCH] Start publishing the library to maven central (#53) * setup publishing * fix compose version * update Docs to use maven central infos * update doc link in README.md --- README.md | 32 +++------- docs/index.md | 23 ++----- validable/build.gradle.kts | 60 ++++++++++++++----- .../devscast/validable/core/ValidatorTest.kt | 1 + 4 files changed, 59 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index aca27cf..3daff75 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ -![kotlin-version](https://img.shields.io/badge/kotlin-2.0.0-blue) -[![](https://jitpack.io/v/devscast/validable.svg)](https://jitpack.io/#devscast/validable) -[![Build](https://github.com/devscast/validable/actions/workflows/Build.yaml/badge.svg)](https://github.com/devscast/validable/actions/workflows/Build.yaml) - # validable +![Maven Central Version](https://img.shields.io/maven-central/v/tech.devscast/validable?color=blue) +[![build](https://github.com/devscast/validable/actions/workflows/build.yaml/badge.svg)](https://github.com/devscast/validable/actions/workflows/build.yaml) + Validating text fields when using jetpack compose can sometimes be challenging and verbose. Validable is an extensible library that allows you to validate your text fields in a simpler way while having a reusable code. @@ -53,33 +52,20 @@ fun MyScreen() { } ``` -## Installation - -**Step 1.** Add the JitPack repository to your build file +## Gradle setup -Add it in your root build.gradle at the end of repositories: - -```groovy -allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - } -} -``` +Include the **validable** dependency in your module `build.gradle` or `build.gradle.kts` : -**Step 2.** Add the dependency -```groovy +```kotlin dependencies { - implementation 'com.github.devscast:validable:{latest-version}' + implementation("tech.devscast:validable:") } ``` -The latest version of this library is [![](https://jitpack.io/v/devscast/validable.svg)](https://jitpack.io/#devscast/validable) +The latest version is ![Maven Central Version](https://img.shields.io/maven-central/v/tech.devscast/validable?color=blue) -## [Documentation](https://devscast.github.io/validable) -For more detailed information, visit the [doc](https://devscast.github.io/validable). +## For full documentation, check out [https://devscast.github.io/validable](https://devscast.github.io/validable) ## Contributing diff --git a/docs/index.md b/docs/index.md index 6492204..51d8e9d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,6 @@ # Validable -![kotlin-version](https://img.shields.io/badge/kotlin-2.0.0-blue) -[![](https://jitpack.io/v/devscast/validable.svg)](https://jitpack.io/#devscast/validable) +![Maven Central Version](https://img.shields.io/maven-central/v/tech.devscast/validable?color=blue) [![build](https://github.com/devscast/validable/actions/workflows/build.yaml/badge.svg)](https://github.com/devscast/validable/actions/workflows/build.yaml) Validating text fields when using jetpack compose can sometimes be challenging and verbose. @@ -49,26 +48,14 @@ fun MyScreen() { } ``` -## Installation +## Gradle setup -**Step 1.** Add the JitPack repository to your build file +Include the **validable** dependency in your module `build.gradle` or `build.gradle.kts` : -Add it in your root build.gradle at the end of repositories: -```groovy -allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - } -} -``` - -**Step 2.** Add the dependency - -```groovy +```kotlin dependencies { - implementation 'com.github.devscast:validable:{latest-version}' + implementation("tech.devscast:validable:") } ``` diff --git a/validable/build.gradle.kts b/validable/build.gradle.kts index 3f48a66..73b9116 100644 --- a/validable/build.gradle.kts +++ b/validable/build.gradle.kts @@ -1,10 +1,12 @@ +import com.vanniktech.maven.publish.SonatypeHost + plugins { id("com.android.library") id("org.jetbrains.kotlin.android") - id("maven-publish") id("io.gitlab.arturbosch.detekt") version "1.23.6" id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.14.0" id("org.jetbrains.kotlin.plugin.compose") + id("com.vanniktech.maven.publish") version "0.28.0" } android { @@ -54,24 +56,10 @@ dependencies { implementation("androidx.core:core-ktx:1.13.1") implementation(platform("androidx.compose:compose-bom:2024.06.00")) implementation("androidx.appcompat:appcompat:1.7.0") - implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui:1.6.8") testImplementation("junit:junit:4.13.2") } -publishing { - publications { - register("release") { - groupId = "com.github.devscast" - artifactId = "validable" - version = "2.0.0-alpha01" - - afterEvaluate { - from(components["release"]) - } - } - } -} - detekt { parallel = true @@ -84,4 +72,44 @@ detekt { // Specifying a baseline file. All findings stored in this file in subsequent runs of detekt. baseline = file("$rootDir/detekt/baseline.xml") +} + + +mavenPublishing { + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + signAllPublications() + + coordinates("tech.devscast", "validable", "2.0.0-alpha01") + + pom { + name.set("Validable") + description.set("An easy-to-use text field validator for Kotlin & Jetpack compose.") + inceptionYear.set("2021") + url.set("https://github.com/devscast/validable") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("yveskalume") + name.set("Yves Kalume") + url.set("https://github.com/yveskalume") + } + developer { + id.set("bernard-ng") + name.set("Bernard Ngandu") + url.set("https://github.com/bernard-ng") + } + } + + scm { + url.set("https://github.com/devscast/validable") + connection.set("scm:git:git://github.com/devscast/validable.git") + developerConnection.set("scm:git:ssh://git@github.com/devscast/validable.git") + } + } } \ No newline at end of file diff --git a/validable/src/test/java/tech/devscast/validable/core/ValidatorTest.kt b/validable/src/test/java/tech/devscast/validable/core/ValidatorTest.kt index a5f1841..e5bf007 100644 --- a/validable/src/test/java/tech/devscast/validable/core/ValidatorTest.kt +++ b/validable/src/test/java/tech/devscast/validable/core/ValidatorTest.kt @@ -23,6 +23,7 @@ class ValidatorTest { } @Test + fun `test validator when input are valid`(){ val validable1 = EmailValidable() validable1.value = "example@gmail.com"