From 42a6272d9806b2b157e174326820bf5e7146a76f Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 26 May 2017 16:48:21 +0300 Subject: Fix serialization issues with gradle #KT-18114 fixed --- .../kotlin/org/jetbrains/dokka/configuration.kt | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'integration') diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt index 61f9376e..f9846a9e 100644 --- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt +++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt @@ -1,8 +1,22 @@ package org.jetbrains.dokka +import ru.yole.jkid.CustomSerializer +import ru.yole.jkid.ValueSerializer +import ru.yole.jkid.deserialization.JKidException +import java.io.Serializable import java.net.URL +class UrlSerializer : ValueSerializer { + override fun fromJsonValue(jsonValue: Any?): URL? { + if (jsonValue !is String?) + throw JKidException("Expected string representation of URL, got: $jsonValue") + return jsonValue?.let { URL(jsonValue) } + } + + override fun toJsonValue(value: URL?): Any? = value?.toExternalForm() +} + interface DokkaConfiguration { val moduleName: String val classpath: List @@ -43,13 +57,13 @@ interface DokkaConfiguration { } interface ExternalDocumentationLink { - val url: URL - val packageListUrl: URL + @CustomSerializer(UrlSerializer::class) val url: URL + @CustomSerializer(UrlSerializer::class) val packageListUrl: URL open class Builder(open var url: URL? = null, open var packageListUrl: URL? = null) { - constructor(root: String) : this(URL(root), null) + constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) }) fun build(): DokkaConfiguration.ExternalDocumentationLink = if (packageListUrl != null && url != null) @@ -83,5 +97,5 @@ data class SerializeOnlyDokkaConfiguration(override val moduleName: String, override val noStdlibLink: Boolean) : DokkaConfiguration -data class ExternalDocumentationLinkImpl internal constructor(override val url: URL, - override val packageListUrl: URL) : DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file +data class ExternalDocumentationLinkImpl(@CustomSerializer(UrlSerializer::class) override val url: URL, + @CustomSerializer(UrlSerializer::class) override val packageListUrl: URL) : Serializable, DokkaConfiguration.ExternalDocumentationLink \ No newline at end of file -- cgit