forked from square/okhttp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to Vanniktech for Maven publishing (square#6929)
* Switch to Vanniktech for Maven publishing Steal configuration from Okio, which already works nicely. * Update mockwebserver-junit5/build.gradle.kts Co-authored-by: Benoît Quenaudon <[email protected]> Co-authored-by: Benoît Quenaudon <[email protected]>
- Loading branch information
1 parent
d0759a7
commit d9a65a8
Showing
25 changed files
with
206 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import java.net.URI | ||
import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
import java.net.URL | ||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
import org.jetbrains.dokka.gradle.DokkaTask | ||
|
@@ -18,6 +19,7 @@ buildscript { | |
classpath(Dependencies.animalsnifferPlugin) | ||
classpath(Dependencies.errorpronePlugin) | ||
classpath(Dependencies.spotlessPlugin) | ||
classpath(Dependencies.vanniktechPublishPlugin) | ||
} | ||
|
||
repositories { | ||
|
@@ -27,9 +29,10 @@ buildscript { | |
} | ||
} | ||
|
||
apply(plugin = "com.vanniktech.maven.publish.base") | ||
|
||
allprojects { | ||
group = "com.squareup.okhttp3" | ||
project.ext["artifactId"] = project.name.publishedArtifactId() | ||
version = "5.0.0-SNAPSHOT" | ||
|
||
repositories { | ||
|
@@ -176,102 +179,61 @@ subprojects { | |
sourceCompatibility = JavaVersion.VERSION_1_8.toString() | ||
targetCompatibility = JavaVersion.VERSION_1_8.toString() | ||
} | ||
} | ||
|
||
tasks.withType<DokkaTask> { | ||
configuration { | ||
reportUndocumented = false | ||
skipDeprecated = true | ||
jdkVersion = 8 | ||
/** Configure publishing and signing for published Java and JavaPlatform subprojects. */ | ||
subprojects { | ||
tasks.withType<DokkaTask>().configureEach { | ||
dokkaSourceSets.configureEach { | ||
reportUndocumented.set(false) | ||
skipDeprecated.set(true) | ||
jdkVersion.set(8) | ||
perPackageOption { | ||
prefix = "okhttp3.internal" | ||
suppress = true | ||
matchingRegex.set("okhttp3\\.internal.*") | ||
suppress.set(true) | ||
} | ||
perPackageOption { | ||
prefix = "mockwebserver3.internal" | ||
suppress = true | ||
matchingRegex.set("mockwebserver3\\.internal.*") | ||
suppress.set(true) | ||
} | ||
if (project.file("Module.md").exists()) { | ||
includes = listOf("Module.md") | ||
includes.from(project.file("Module.md")) | ||
} | ||
externalDocumentationLink { | ||
url = URL("https://square.github.io/okio/2.x/okio/") | ||
packageListUrl = URL("https://square.github.io/okio/2.x/okio/package-list") | ||
url.set(URL("https://square.github.io/okio/2.x/okio/")) | ||
packageListUrl.set(URL("https://square.github.io/okio/2.x/okio/package-list")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** Configure publishing and signing for published Java and JavaPlatform subprojects. */ | ||
subprojects { | ||
val project = this@subprojects | ||
if (project.ext.get("artifactId") == null) return@subprojects | ||
val bom = project.ext["artifactId"] == "okhttp-bom" | ||
|
||
if (bom) { | ||
apply(plugin = "java-platform") | ||
} | ||
|
||
apply(plugin = "maven-publish") | ||
apply(plugin = "signing") | ||
|
||
configure<PublishingExtension> { | ||
if (!bom) { | ||
configure<JavaPluginExtension> { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
} | ||
|
||
publications { | ||
create<MavenPublication>("maven") { | ||
groupId = project.group.toString() | ||
artifactId = project.ext["artifactId"].toString() | ||
version = project.version.toString() | ||
if (bom) { | ||
from(components["javaPlatform"]) | ||
} else { | ||
from(components["java"]) | ||
} | ||
pom { | ||
name.set(project.name) | ||
description.set("Square’s meticulous HTTP client for Java and Kotlin.") | ||
url.set("https://square.github.io/okhttp/") | ||
licenses { | ||
license { | ||
name.set("The Apache Software License, Version 2.0") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
} | ||
} | ||
developers { | ||
developer { | ||
name.set("Square, Inc.") | ||
} | ||
} | ||
scm { | ||
connection.set("scm:git:https://github.com/square/okhttp.git") | ||
developerConnection.set("scm:git:ssh:https://[email protected]/square/okhttp.git") | ||
url.set("https://github.com/square/okhttp") | ||
plugins.withId("com.vanniktech.maven.publish.base") { | ||
configure<MavenPublishBaseExtension> { | ||
publishToMavenCentral(SonatypeHost.DEFAULT) | ||
signAllPublications() | ||
pom { | ||
name.set(project.name) | ||
description.set("Square’s meticulous HTTP client for Java and Kotlin.") | ||
url.set("https://square.github.io/okhttp/") | ||
licenses { | ||
license { | ||
name.set("The Apache Software License, Version 2.0") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
distribution.set("repo") | ||
} | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
name = "mavencentral" | ||
url = URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
credentials { | ||
username = System.getenv("SONATYPE_NEXUS_USERNAME") | ||
password = System.getenv("SONATYPE_NEXUS_PASSWORD") | ||
scm { | ||
connection.set("scm:git:https://github.com/square/okhttp.git") | ||
developerConnection.set("scm:git:ssh:https://[email protected]/square/okhttp.git") | ||
url.set("https://github.com/square/okhttp") | ||
} | ||
developers { | ||
developer { | ||
name.set("Square, Inc.") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
val publishing = extensions.getByType<PublishingExtension>() | ||
configure<SigningExtension> { | ||
sign(publishing.publications["maven"]) | ||
} | ||
} | ||
|
||
tasks.withType<Wrapper> { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.