Skip to content

Commit

Permalink
Added legacy coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzo committed Nov 17, 2023
1 parent 18f679f commit 01f9503
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# 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)

## Import
On your `build.gradle` add:
```groovy
dependencies {
testImplementation 'com.github.gmazzo:okhttp-mock:<version>'
testImplementation 'com.github.gmazzo.okhttp.mock:mock-client:<version>'
}
```

Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/maven-central-publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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) }
Expand All @@ -21,10 +26,31 @@ dependencies {
compileOnlyAndTests(libs.robolectric)

testImplementation(libs.kotlin.test)

legacyPOM(project)
}

publishing.publications {
create<MavenPublication>("java") { from(components["java"]) }

create<MavenPublication>("legacy") {
from(serviceOf<SoftwareComponentFactory>().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 {
Expand Down

0 comments on commit 01f9503

Please sign in to comment.