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 2585c23 commit 13d55ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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 13d55ae

Please sign in to comment.