From 277fd06dcb67a16d299d328f84bbcfcfce3cc18e Mon Sep 17 00:00:00 2001 From: Alexandr Gavrishev Date: Sat, 12 Aug 2023 12:07:03 +0300 Subject: [PATCH] Update publishing section --- README.md | 27 +++++++++++++------ ksp-dotenv/build.gradle.kts | 53 +++++++++++++++++++++++++++++++++++++ settings.gradle.kts | 2 -- 3 files changed, 72 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f5fd399..48a7b5d 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,23 @@ # ksp-dotenv Gradle KSP Multiplatform plugin to generate code from .env file -# Running example +# Example `./gradlew example:run` # Setup -1. Include "com.google.devtools.ksp" in case it's wasnt in the project yet -2. Update build.gradle.kts +1. Include [com.google.devtools.ksp](https://kotlinlang.org/docs/ksp-quickstart.html) in case it wasn't in the project yet +2. Add GitHup package repository following instructions https://github.com/anod/ksp-dotenv/packages/1921207 +3. Add dependencies to build.gradle.kts ```kotlin dependencies { - add("kspCommonMainMetadata", "info.anodsplace.dotenv") - add("kspJvm", project("info.anodsplace.dotenv")) + add("kspCommonMainMetadata", "info.anodsplace.dotenv:ksp-dotenv-jvm:$kspDotenvVersion") + add("kspJvm", project("info.anodsplace.dotenv:ksp-dotenv-jvm:$kspDotenvVersion")) } - + ``` +4. Configure the plugin inside build.gradle.kts + ```` ksp { arg("info.anodsplace.dotenv.path", project.rootDir.toString()) arg("info.anodsplace.dotenv.filename", "env.example") // default ".env" @@ -24,9 +27,17 @@ Gradle KSP Multiplatform plugin to generate code from .env file arg("info.anodsplace.dotenv.class", "DotEnvExample") } ``` -3. Use generated file +5. Build & use generated file ```kotlin println("[ksp-dotenv] ENDPOINT_FE=${DotEnvExample.endpointFe}") println("[ksp-dotenv] ENDPOINT_BE=${DotEnvExample.endpointBe}") println("[ksp-dotenv] ENV=${DotEnvExample.env}") - ``` \ No newline at end of file + ``` + +# Publish + + `./gradlew publish` + +# Author + +Alexandr Gavrishev, 2023 diff --git a/ksp-dotenv/build.gradle.kts b/ksp-dotenv/build.gradle.kts index 874abed..8f99000 100644 --- a/ksp-dotenv/build.gradle.kts +++ b/ksp-dotenv/build.gradle.kts @@ -10,6 +10,7 @@ version = "0.1.0" kotlin { jvm() + sourceSets { val jvmMain by getting { dependencies { @@ -22,4 +23,56 @@ kotlin { resources.srcDir("src/main/resources") } } + val publicationsFromMainHost = listOf(jvm()).map { it.name } + "kotlinMultiplatform" + publishing { + publications { + matching { it.name in publicationsFromMainHost }.all { + val targetPublication = this@all + tasks.withType() + .matching { it.publication == targetPublication } + .configureEach { onlyIf { findProperty("isMainHost") == "true" } } + } + } + } } + +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/anod/ksp-dotenv") + credentials { + username = project.findProperty("GITHUB_USER") as? String ?: System.getenv("GITHUB_USER") + password = project.findProperty("GITHUB_TOKEN") as? String ?: System.getenv("GITHUB_TOKEN") + } + } + } + publications { + register("github") { + groupId = project.group.toString() + artifactId = project.name + version = project.version.toString() + pom { + description.set( + "Gradle KSP Multiplatform plugin to generate code from .env file") + name.set(project.name) + url.set("https://github.com/anod/ksp-dotenv.git") + licenses { + license { + name.set("MIT License") + url.set("https://github.com/anod/ksp-dotenv/blob/main/LICENSE") + distribution.set("repo") + } + } + developers { + developer { + id.set("anodsplace.info") + name.set("Alexandr Gavrishev") + email.set("alex.gavrishev@gmail.com") + } + } + scm { url.set("scm:git:git@github.com:facebook/yoga.git") } + } + } + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 1ba8910..02b402e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,7 +6,6 @@ pluginManagement { kotlin("multiplatform") version kotlinVersion apply false } repositories { - mavenLocal() mavenCentral() gradlePluginPortal() } @@ -16,7 +15,6 @@ dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() - mavenLocal() } }