diff options
11 files changed, 50 insertions, 17 deletions
@@ -96,6 +96,8 @@ dokka { targets = ["JVM"] // See platforms section of documentation + platform = "JVM" // Platform used for code analysis + // Manual adding files to classpath // This property not overrides classpath collected from kotlinTasks but appends to it classpath = [new File("$buildDir/other.jar")] @@ -175,6 +177,7 @@ dokka { multiplatform { js { // the name here is arbitrary targets = ["JS"] + platform = "js" sourceRoot { path = kotlin.sourceSets.jsMain.kotlin.srcDirs[0] } @@ -185,6 +188,7 @@ dokka { jvm { // the name here is arbitrary targets = ["JVM"] + platform = "jvm" sourceRoot { path = kotlin.sourceSets.jvmMain.kotlin.srcDirs[0] } diff --git a/core/testdata/format/inlineSuspendFunction.kt b/core/testdata/format/inlineSuspendFunction.kt index f2009eff..02b3094b 100644 --- a/core/testdata/format/inlineSuspendFunction.kt +++ b/core/testdata/format/inlineSuspendFunction.kt @@ -1,6 +1,6 @@ /** * returns 1 */ -inline suspend fun foo(): Int { +inline suspend fun foo(a: () -> String): Int { 1 } diff --git a/core/testdata/format/inlineSuspendFunction.md b/core/testdata/format/inlineSuspendFunction.md index 3bf196b6..e109039c 100644 --- a/core/testdata/format/inlineSuspendFunction.md +++ b/core/testdata/format/inlineSuspendFunction.md @@ -2,7 +2,7 @@ # foo -`suspend inline fun foo(): Int` +`suspend inline fun foo(a: () -> String): Int` returns 1 diff --git a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt index 49481089..7c6753d4 100644 --- a/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt +++ b/integration/src/main/kotlin/org/jetbrains/dokka/configuration.kt @@ -18,7 +18,7 @@ enum class Platform(val key: String) { js.key -> js native.key -> native common.key -> common - else -> TODO("write normal exception") + else -> throw IllegalArgumentException("Unrecognized platform: $key") } } } diff --git a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt index 367b9257..2d79013e 100644 --- a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt +++ b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt @@ -7,6 +7,9 @@ import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink.Builder import org.jetbrains.dokka.DokkaConfiguration.SourceRoot import java.io.File +internal const val CONFIGURATION_EXTENSION_NAME = "configuration" +internal const val MULTIPLATFORM_EXTENSION_NAME = "multiplatform" + open class DokkaAndroidPlugin : Plugin<Project> { override fun apply(project: Project) { DokkaVersion.loadFrom(javaClass.getResourceAsStream("/META-INF/gradle-plugins/org.jetbrains.dokka-android.properties")) @@ -15,6 +18,11 @@ open class DokkaAndroidPlugin : Plugin<Project> { moduleName = project.name outputDirectory = File(project.buildDir, "dokka").absolutePath } + project.tasks.withType(DokkaTask::class.java) { task -> + val passConfiguration = project.container(GradlePassConfigurationImpl::class.java) + task.extensions.add(MULTIPLATFORM_EXTENSION_NAME, passConfiguration) + task.extensions.create(CONFIGURATION_EXTENSION_NAME, GradlePassConfigurationImpl::class.java, "") + } } } diff --git a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/build.gradle b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/build.gradle index 0f27d365..82215a44 100644 --- a/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/build.gradle +++ b/runners/gradle-integration-tests/testData/androidLibDependsOnJavaLib/lib/build.gradle @@ -30,10 +30,11 @@ dependencies { } dokka { - dokkaFatJar = new File(dokka_fatjar) - - externalDocumentationLink { - url = new URL("https://example.com") - packageListUrl = file("$rootDir/package-list").toURI().toURL() + dokkaFatJar = files(dokka_fatjar) + configuration { + externalDocumentationLink { + url = new URL("https://example.com") + packageListUrl = file("$rootDir/package-list").toURI().toURL() + } } }
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/basic/build.gradle b/runners/gradle-integration-tests/testData/basic/build.gradle index a3116751..85e86748 100644 --- a/runners/gradle-integration-tests/testData/basic/build.gradle +++ b/runners/gradle-integration-tests/testData/basic/build.gradle @@ -35,6 +35,6 @@ dependencies { dokka { - dokkaFatJar = new File(dokka_fatjar) + dokkaFatJar = files(dokka_fatjar) classpath += files("$projectDir/classDir") }
\ No newline at end of file diff --git a/runners/gradle-integration-tests/testData/sourcesChange/build.gradle b/runners/gradle-integration-tests/testData/sourcesChange/build.gradle index 4627e8ef..f436afb4 100644 --- a/runners/gradle-integration-tests/testData/sourcesChange/build.gradle +++ b/runners/gradle-integration-tests/testData/sourcesChange/build.gradle @@ -35,5 +35,5 @@ dependencies { dokka { - dokkaFatJar = new File(dokka_fatjar) + dokkaFatJar = files(dokka_fatjar) }
\ No newline at end of file diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt index b7e859e1..d4eee4b2 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt @@ -14,6 +14,7 @@ import org.gradle.api.tasks.compile.AbstractCompile import org.jetbrains.dokka.DokkaBootstrap import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaConfiguration.SourceRoot +import org.jetbrains.dokka.Platform import org.jetbrains.dokka.ReflectDsl import org.jetbrains.dokka.ReflectDsl.isNotInstance import java.io.File @@ -49,7 +50,6 @@ open class DokkaTask : DefaultTask() { @Input var outputFormat: String = "html" - @OutputDirectory var outputDirectory: String = "" var dokkaRuntime: Configuration? = null @@ -61,7 +61,7 @@ open class DokkaTask : DefaultTask() { var sourceDirs: Iterable<File> = emptyList() @Input - var sourceRoots: MutableList<DokkaConfiguration.SourceRoot> = arrayListOf() + var sourceRoots: MutableList<SourceRoot> = arrayListOf() @Input var dokkaFatJar: Any = "org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}" @@ -241,11 +241,14 @@ open class DokkaTask : DefaultTask() { passConfig.collectInheritedExtensionsFromLibraries = collectInheritedExtensionsFromLibraries passConfig.suppressedFiles = collectSuppressedFiles(passConfig.sourceRoots) passConfig.externalDocumentationLinks.addAll(externalDocumentationLinks) + if(passConfig.platform.isNotEmpty()){ + passConfig.analysisPlatform = Platform.fromString(passConfig.platform) + } return passConfig } - private fun collectSourceRoots(): List<DokkaConfiguration.SourceRoot> { + private fun collectSourceRoots(): List<SourceRoot> { val sourceDirs = when { sourceDirs.any() -> { logger.info("Dokka: Taking source directories provided by the user") @@ -262,6 +265,22 @@ open class DokkaTask : DefaultTask() { return sourceRoots + (sourceDirs?.toSourceRoots() ?: emptyList()) } + /** + * Needed for Gradle incremental build + */ + @OutputDirectory + fun getOutputDirectoryAsFile(): File = project.file(outputDirectory) + + /** + * Needed for Gradle incremental build + */ + @InputFiles + fun getInputFiles(): FileCollection { + val (_, tasksSourceRoots) = extractClasspathAndSourceRootsFromKotlinTasks() + return project.files(tasksSourceRoots.map { project.fileTree(it) }) + + project.files(collectSourceRoots().map { project.fileTree(File(it.path)) }) + } + companion object { const val COLORS_ENABLED_PROPERTY = "kotlin.colors.enabled" const val ABSTRACT_KOTLIN_COMPILE = "org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile" diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt index 50412734..fd889d78 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt @@ -41,6 +41,7 @@ open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassCo override var suppressedFiles: List<String> = emptyList() override var collectInheritedExtensionsFromLibraries: Boolean = false override var analysisPlatform: Platform = Platform.DEFAULT + var platform: String = "" override var targets: List<String> = emptyList() override var sinceKotlin: String = "1.0" @@ -96,8 +97,8 @@ class GradleSourceLinkDefinitionImpl : SourceLinkDefinition { } class GradleExternalDocumentationLinkImpl : ExternalDocumentationLink { - override var url: URL = URL("") - override var packageListUrl: URL = URL("") + override var url: URL = URL("http://") + override var packageListUrl: URL = URL("http://") } class GradleDokkaConfigurationImpl: DokkaConfiguration { diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index cc661193..ca3a65fd 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -152,7 +152,7 @@ abstract class AbstractDokkaMojo : AbstractMojo() { @Parameter(required = true, defaultValue = "\${project.compileClasspathElements}") var classpath: List<String> = emptyList() - //todo remove + //TODO remove @Parameter(required = true, defaultValue = "\${project.compileSourceRoots}") var sourceDirectories: List<String> = emptyList() @Parameter(required = false, defaultValue = "6") @@ -207,7 +207,7 @@ abstract class AbstractDokkaMojo : AbstractMojo() { if(passConfig.platform.isNotEmpty()){ passConfig.analysisPlatform = Platform.fromString(passConfig.platform) } - // todo fix + // TODO fix passConfig.sourceRoots = sourceDirectories.map { val sourceRoot = SourceRoot() sourceRoot.path = it |