From e381bedd35e2c2bcb054d444d3e51fb69b40dcb9 Mon Sep 17 00:00:00 2001 From: Guillermo Mazzola Date: Fri, 17 Nov 2023 12:56:01 +0100 Subject: [PATCH] Added legacy coordinates --- README.md | 4 +-- .../kotlin/maven-central-publish.gradle.kts | 1 + library/build.gradle.kts | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a8e66f..c8b26b4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # okhttp-client-mock A simple OKHttp client mock, using a programmable request interceptor -[![Maven Central](https://img.shields.io/maven-central/v/com.github.gmazzo/okhttp-mock)](https://central.sonatype.com/artifact/com.github.gmazzo/okhttp-mock) +[![Maven Central](https://img.shields.io/maven-central/v/com.github.gmazzo.okhttp.mock/mock-client)](https://central.sonatype.com/artifact/com.github.gmazzo.okhttp.mock/mock-client) [![Build Status](https://github.com/gmazzo/okhttp-client-mock/actions/workflows/build.yaml/badge.svg)](https://github.com/gmazzo/okhttp-client-mock/actions/workflows/build.yaml) [![codecov](https://codecov.io/gh/gmazzo/okhttp-client-mock/branch/master/graph/badge.svg)](https://codecov.io/gh/gmazzo/okhttp-client-mock) @@ -9,7 +9,7 @@ A simple OKHttp client mock, using a programmable request interceptor On your `build.gradle` add: ```groovy dependencies { - testImplementation 'com.github.gmazzo:okhttp-mock:' + testImplementation 'com.github.gmazzo.okhttp.mock:mock-client:' } ``` diff --git a/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts b/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts index 338e208..1f69f72 100644 --- a/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/maven-central-publish.gradle.kts @@ -48,6 +48,7 @@ fun MavenPublication.setupMandatoryPOMAttributes() { .exec { commandLine("git", "remote", "get-url", "origin") } .standardOutput .asText + .map { it.trim() } name.set("${rootProject.name}-${project.name}") description.set(project.description) diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 509e7a6..d7ddf83 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -1,3 +1,6 @@ +import org.gradle.api.publish.maven.internal.publication.MavenPomInternal +import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal +import org.gradle.kotlin.dsl.support.serviceOf import org.jetbrains.kotlin.gradle.utils.extendsFrom plugins { @@ -10,6 +13,8 @@ description = "A simple OKHttp client mock, using a programmable request interce java.toolchain.languageVersion.set(JavaLanguageVersion.of(8)) +val legacyPOM by configurations.creating + dependencies { val compileOnlyAndTests by configurations.creating { isCanBeConsumed = true } configurations.compileOnly.configure { extendsFrom(compileOnlyAndTests) } @@ -21,10 +26,31 @@ dependencies { compileOnlyAndTests(libs.robolectric) testImplementation(libs.kotlin.test) + + legacyPOM(project) } publishing.publications { create("java") { from(components["java"]) } + + create("legacy") { + from(serviceOf().adhoc("legacy").apply { + addVariantsFromConfiguration(legacyPOM) { + mapToMavenScope("compile") + } + }) + groupId = "com.github.gmazzo" + artifactId = "okhttp-mock" + (this as MavenPublicationInternal).isAlias = true + pom { + name.set("${project.name} (deprecated)") + description.set("Deprecated: replaced by com.github.gmazzo.okhttp.mock:mock-client:$version") + } + } +} + +tasks.named("generateMetadataFileForLegacyPublication") { + enabled = false } tasks.check {