Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing as com.github.gmazzo.okhttp.mock:mock-client #39

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 0 additions & 8 deletions library/src/main/java/okhttp3/mock/HttpCodes.java

This file was deleted.

8 changes: 0 additions & 8 deletions library/src/main/java/okhttp3/mock/HttpMethods.java

This file was deleted.

2 changes: 1 addition & 1 deletion library/src/main/java/okhttp3/mock/Rule.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.*;
import java.util.regex.Pattern;

import static okhttp3.mock.HttpCodes.HTTP_200_OK;
import static okhttp3.mock.HttpCode.HTTP_200_OK;
import static okhttp3.mock.HttpMethod.*;
import static okhttp3.mock.MediaTypes.MEDIATYPE_RAW_DATA;
import static okhttp3.mock.MediaTypes.MEDIATYPE_TEXT;
Expand Down