@@ -5,7 +5,7 @@ import com.vanniktech.maven.publish.MavenPublishBaseExtension
55import java.net.URI
66import kotlinx.validation.ApiValidationExtension
77import org.gradle.api.tasks.testing.logging.TestExceptionFormat
8- import org.jetbrains.dokka.gradle.DokkaTaskPartial
8+ import org.jetbrains.dokka.gradle.DokkaExtension
99import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1010import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
1111import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -38,7 +38,14 @@ buildscript {
3838 }
3939}
4040
41- apply (plugin = " org.jetbrains.dokka" )
41+ val okhttpDokka: String by project
42+ val dokkaBuild = okhttpDokka.toBoolean()
43+ val platform = System .getProperty(" okhttp.platform" , " jdk9" )
44+ val testJavaVersion = System .getProperty(" test.java.version" , " 21" ).toInt()
45+
46+ if (dokkaBuild) {
47+ apply (plugin = " org.jetbrains.dokka" )
48+ }
4249apply (plugin = " com.diffplug.spotless" )
4350
4451configure<SpotlessExtension > {
@@ -78,8 +85,7 @@ allprojects {
7885 }
7986}
8087
81- val platform = System .getProperty(" okhttp.platform" , " jdk9" )
82- val testJavaVersion = System .getProperty(" test.java.version" , " 21" ).toInt()
88+
8389
8490/* * Configure building for Java+Kotlin projects. */
8591subprojects {
@@ -197,8 +203,7 @@ subprojects {
197203 }
198204 }
199205
200- val platform = System .getProperty(" okhttp.platform" , " jdk9" )
201- val testJavaVersion = System .getProperty(" test.java.version" , " 21" ).toInt()
206+
202207
203208 if (project.name != " okhttp" ) {
204209 val testRuntimeOnly: Configuration by configurations.getting
@@ -304,26 +309,39 @@ subprojects {
304309
305310/* * Configure publishing and signing for published Java and JavaPlatform subprojects. */
306311subprojects {
307- tasks.withType<DokkaTaskPartial >().configureEach {
308- dokkaSourceSets.configureEach {
309- reportUndocumented.set(false )
310- skipDeprecated.set(true )
311- jdkVersion.set(8 )
312- perPackageOption {
313- matchingRegex.set(" .*\\ .internal.*" )
314- suppress.set(true )
315- }
316- if (project.file(" Module.md" ).exists()) {
317- includes.from(project.file(" Module.md" ))
318- }
319- externalDocumentationLink {
320- url.set(URI .create(" https://square.github.io/okio/3.x/okio/" ).toURL())
321- packageListUrl.set(URI .create(" https://square.github.io/okio/3.x/okio/okio/package-list" ).toURL())
312+ plugins.withId(" com.vanniktech.maven.publish.base" ) {
313+ if (dokkaBuild) {
314+ apply (plugin = " org.jetbrains.dokka" )
315+
316+ extensions.configure<DokkaExtension > {
317+ dokkaSourceSets.configureEach {
318+ reportUndocumented.set(false )
319+ skipDeprecated.set(true )
320+ jdkVersion.set(21 )
321+ perPackageOption {
322+ matchingRegex.set(" .*\\ .internal.*" )
323+ suppress.set(true )
324+ }
325+ if (project.file(" Module.md" ).exists()) {
326+ includes.from(project.file(" Module.md" ))
327+ }
328+ externalDocumentationLinks.register(" okio" ) {
329+ url.set(URI .create(" https://square.github.io/okio/3.x/okio/" ))
330+ packageListUrl.set(URI .create(" https://square.github.io/okio/3.x/okio/okio/package-list" ))
331+ }
332+
333+ externalDocumentationLinks.named(" jdk" ) {
334+ url.set(URI .create(" https://docs.oracle.com/en/java/javase/21/docs/api/" ))
335+ packageListUrl.set(URI .create(" https://docs.oracle.com/en/java/javase/21/docs/api/element-list" ))
336+ }
337+ externalDocumentationLinks.register(" androidRef" ) {
338+ url.set(URI .create(" https://developer.android.com/reference/" ))
339+ packageListUrl.set(URI .create(" https://developer.android.com/reference/package-list" ))
340+ }
341+ }
322342 }
323343 }
324- }
325344
326- plugins.withId(" com.vanniktech.maven.publish.base" ) {
327345 configure<MavenPublishBaseExtension > {
328346 publishToMavenCentral(automaticRelease = true )
329347 signAllPublications()
@@ -376,3 +394,22 @@ plugins.withId("org.jetbrains.kotlin.jvm") {
376394tasks.wrapper {
377395 distributionType = Wrapper .DistributionType .ALL
378396}
397+
398+ if (dokkaBuild) {
399+ dependencies {
400+ add(" dokka" , project(" :okhttp" ))
401+ add(" dokka" , project(" :okhttp-brotli" ))
402+ add(" dokka" , project(" :okhttp-coroutines" ))
403+ add(" dokka" , project(" :okhttp-dnsoverhttps" ))
404+ add(" dokka" , project(" :okhttp-java-net-cookiejar" ))
405+ add(" dokka" , project(" :logging-interceptor" ))
406+ add(" dokka" , project(" :okhttp-sse" ))
407+ add(" dokka" , project(" :okhttp-tls" ))
408+ add(" dokka" , project(" :okhttp-urlconnection" ))
409+ add(" dokka" , project(" :okhttp-zstd" ))
410+ add(" dokka" , project(" :mockwebserver" ))
411+ add(" dokka" , project(" :mockwebserver3" ))
412+ add(" dokka" , project(" :mockwebserver3-junit4" ))
413+ add(" dokka" , project(" :mockwebserver3-junit5" ))
414+ }
415+ }
0 commit comments