Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into KT-64377/update-int…
Browse files Browse the repository at this point in the history
…egration-test-build-config
  • Loading branch information
adam-enko committed Jan 15, 2024
2 parents 28f4d7a + 155efa4 commit 7af0394
Show file tree
Hide file tree
Showing 13 changed files with 6,915 additions and 5,656 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import javax.inject.Inject
/**
* Common build properties used to build Dokka subprojects.
*
* This is an extension created by the [org.jetbrains.conventions.Base_gradle] convention plugin.
* This is an extension created by the `dokkabuild.base.gradle.kts` convention plugin.
*
* Default values are set in the root `gradle.properties`, and can be overridden via
* [project properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ internal val Project.libs : LibrariesForLibs
get() = extensions.getByType()

/**
* Retrieves the [dokkaBuild][org.jetbrains.DokkaBuildProperties] extension.
* Retrieves the [dokkaBuild][dokkabuild.DokkaBuildProperties] extension.
*/
internal val Project.dokkaBuild: DokkaBuildProperties
get() = extensions.getByType()

/**
* Configures the [dokkaBuild][org.jetbrains.DokkaBuildProperties] extension.
* Configures the [dokkaBuild][dokkabuild.DokkaBuildProperties] extension.
*/
internal fun Project.dokkaBuild(configure: DokkaBuildProperties.() -> Unit) =
extensions.configure(configure)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.setProperty
import org.jetbrains.dokka.*
import java.io.File
import java.net.URI
import java.net.URL

/**
Expand Down Expand Up @@ -462,7 +463,7 @@ open class GradleDokkaSourceSetBuilder(
* Convenient override to **append** external documentation links to [externalDocumentationLinks].
*/
fun externalDocumentationLink(url: String, packageListUrl: String? = null) {
externalDocumentationLink(URL(url), packageListUrl = packageListUrl?.let(::URL))
externalDocumentationLink(URI(url).toURL(), packageListUrl = packageListUrl?.let(::URI)?.toURL())
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import java.net.URL
*
* ```kotlin
* externalDocumentationLink {
* url.set(URL("https://kotlinlang.org/api/kotlinx.serialization/"))
* url.set(URI("https://kotlinlang.org/api/kotlinx.serialization/").toURL())
* packageListUrl.set(
* rootProject.projectDir.resolve("serialization.package.list").toURL()
* rootProject.projectDir.resolve("serialization.package.list").toURI().toURL()
* )
* }
* ```
Expand All @@ -53,13 +53,13 @@ class GradleExternalDocumentationLinkBuilder(
* Example:
*
* ```kotlin
* java.net.URL("https://kotlinlang.org/api/kotlinx.serialization/")
* java.net.URI("https://kotlinlang.org/api/kotlinx.serialization/").toURL()
* ```
*/
@Internal
val url: Property<URL> = project.objects.property()

@Input // URL is deprecated in gradle inputs
@Input // URL is deprecated in Gradle inputs
internal fun getUrlString() = url.map(URL::toString)

/**
Expand All @@ -69,13 +69,13 @@ class GradleExternalDocumentationLinkBuilder(
* Example:
*
* ```kotlin
* rootProject.projectDir.resolve("serialization.package.list").toURL()
* rootProject.projectDir.resolve("serialization.package.list").toURI().toURL()
* ```
*/
@Internal
val packageListUrl: Property<URL> = project.objects.property()

@Input // URL is deprecated in gradle inputs
@Input // URL is deprecated in Gradle inputs
@Optional
internal fun getPackageListUrlString() = packageListUrl.map(URL::toString)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import java.net.URL
* ```kotlin
* sourceLink {
* localDirectory.set(projectDir.resolve("src"))
* remoteUrl.set(URL("https://github.com/kotlin/dokka/tree/master/src"))
* remoteUrl.set(URI("https://github.com/kotlin/dokka/tree/master/src").toURL())
* remoteLineSuffix.set("#L")
* }
* ```
Expand Down Expand Up @@ -68,13 +68,13 @@ class GradleSourceLinkBuilder(
* Example:
*
* ```kotlin
* java.net.URL("https://github.com/username/projectname/tree/master/src"))
* java.net.URI("https://github.com/username/projectname/tree/master/src").toURL()
* ```
*/
@Internal
val remoteUrl: Property<URL> = project.objects.property()

@Input // TODO: URL is deprecated in grapdle inputs
@Input // URL is deprecated in Gradle inputs
internal fun getRemoteUrlString() = remoteUrl.map(URL::toString)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.jetbrains.dokka.gradle.utils.externalDocumentationLink_
import org.jetbrains.dokka.gradle.utils.withDependencies_
import org.jetbrains.dokka.toCompactJsonString
import java.io.File
import java.net.URL
import java.net.URI
import kotlin.test.Test
import kotlin.test.assertEquals

Expand Down Expand Up @@ -50,8 +50,8 @@ class DokkaConfigurationJsonTest {
reportUndocumented.set(true)

externalDocumentationLink_ {
packageListUrl.set(URL("http://some.url"))
url.set(URL("http://some.other.url"))
packageListUrl.set(URI("http://some.url").toURL())
url.set(URI("http://some.other.url").toURL())
}
perPackageOption {
includeNonPublic.set(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.junit.jupiter.api.io.TempDir
import java.io.File
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.net.URL
import java.net.URI
import kotlin.test.Test
import kotlin.test.assertEquals

Expand Down Expand Up @@ -51,8 +51,8 @@ class DokkaConfigurationSerializableTest {
reportUndocumented.set(true)

externalDocumentationLink_ {
packageListUrl.set(URL("http://some.url"))
url.set(URL("http://some.other.url"))
packageListUrl.set(URI("http://some.url").toURL())
url.set(URI("http://some.other.url").toURL())
}

perPackageOption {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.gradle.kotlin.dsl.closureOf
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.*
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
import java.net.URL
import java.net.URI
import kotlin.test.*

class GradleDokkaSourceSetBuilderTest {
Expand Down Expand Up @@ -222,37 +222,37 @@ class GradleDokkaSourceSetBuilderTest {
GradleSourceLinkBuilder(project).apply {
this.remoteLineSuffix.set("ls1")
this.localDirectory.set(project.file("p1"))
this.remoteUrl.set(URL("https://u1"))
this.remoteUrl.set(URI("https://u1").toURL())
})

sourceSet.sourceLink {
remoteLineSuffix.set("ls2")
localDirectory.set(project.file("p2"))
remoteUrl.set(URL("https://u2"))
remoteUrl.set(URI("https://u2").toURL())
}

sourceSet.sourceLink(project.closureOf<GradleSourceLinkBuilder> {
this.remoteLineSuffix.set("ls3")
this.localDirectory.set(project.file("p3"))
this.remoteUrl.set(URL("https://u3"))
this.remoteUrl.set(URI("https://u3").toURL())
})

assertEquals(
setOf(
SourceLinkDefinitionImpl(
remoteLineSuffix = "ls1",
localDirectory = project.file("p1").absolutePath,
remoteUrl = URL("https://u1")
remoteUrl = URI("https://u1").toURL()
),
SourceLinkDefinitionImpl(
remoteLineSuffix = "ls2",
localDirectory = project.file("p2").absolutePath,
remoteUrl = URL("https://u2")
remoteUrl = URI("https://u2").toURL()
),
SourceLinkDefinitionImpl(
remoteLineSuffix = "ls3",
localDirectory = project.file("p3").absolutePath,
remoteUrl = URL("https://u3")
remoteUrl = URI("https://u3").toURL()
)
),
sourceSet.build().sourceLinks,
Expand Down Expand Up @@ -306,29 +306,29 @@ class GradleDokkaSourceSetBuilderTest {

sourceSet.externalDocumentationLinks.add(
GradleExternalDocumentationLinkBuilder(project).apply {
this.url.set(URL("https://u1"))
this.packageListUrl.set(URL("https://pl1"))
this.url.set(URI("https://u1").toURL())
this.packageListUrl.set(URI("https://pl1").toURL())
}
)

sourceSet.externalDocumentationLink {
url.set(URL("https://u2"))
url.set(URI("https://u2").toURL())
}

sourceSet.externalDocumentationLink(project.closureOf<GradleExternalDocumentationLinkBuilder> {
url.set(URL("https://u3"))
url.set(URI("https://u3").toURL())
})

sourceSet.externalDocumentationLink(url = "https://u4", packageListUrl = "https://pl4")
sourceSet.externalDocumentationLink(url = URL("https://u5"))
sourceSet.externalDocumentationLink(url = URI("https://u5").toURL())

assertEquals(
setOf(
ExternalDocumentationLinkImpl(URL("https://u1"), URL("https://pl1")),
ExternalDocumentationLinkImpl(URL("https://u2"), URL("https://u2/package-list")),
ExternalDocumentationLinkImpl(URL("https://u3"), URL("https://u3/package-list")),
ExternalDocumentationLinkImpl(URL("https://u4"), URL("https://pl4")),
ExternalDocumentationLinkImpl(URL("https://u5"), URL("https://u5/package-list"))
ExternalDocumentationLinkImpl(URI("https://u1").toURL(), URI("https://pl1").toURL()),
ExternalDocumentationLinkImpl(URI("https://u2").toURL(), URI("https://u2/package-list").toURL()),
ExternalDocumentationLinkImpl(URI("https://u3").toURL(), URI("https://u3/package-list").toURL()),
ExternalDocumentationLinkImpl(URI("https://u4").toURL(), URI("https://pl4").toURL()),
ExternalDocumentationLinkImpl(URI("https://u5").toURL(), URI("https://u5/package-list").toURL())
),
sourceSet.build().externalDocumentationLinks,
"Expected all external documentation links being present after build"
Expand Down
Loading

0 comments on commit 7af0394

Please sign in to comment.