diff options
9 files changed, 44 insertions, 45 deletions
diff --git a/core/build.gradle.kts b/core/build.gradle.kts index fc62b73d..45ddccf3 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -21,6 +21,19 @@ val sourceJar by tasks.registering(Jar::class) { from(sourceSets["main"].allSource) } +tasks { + processResources { + val dokka_version: String by project + eachFile { + if (name == "dokka-version.properties") { + filter { line -> + line.replace("<dokka-version>", dokka_version) + } + } + } + } +} + publishing { publications { register<MavenPublication>("dokkaCore") { diff --git a/core/src/main/kotlin/DokkaVersion.kt b/core/src/main/kotlin/DokkaVersion.kt new file mode 100644 index 00000000..410058f3 --- /dev/null +++ b/core/src/main/kotlin/DokkaVersion.kt @@ -0,0 +1,10 @@ +package org.jetbrains.dokka + +import java.util.* + +object DokkaVersion { + val version: String by lazy { + val stream = javaClass.getResourceAsStream("/META-INF/dokka/dokka-version.properties") + Properties().apply { load(stream) }.getProperty("dokka-version") + } +} diff --git a/core/src/main/resources/META-INF/dokka/dokka-version.properties b/core/src/main/resources/META-INF/dokka/dokka-version.properties new file mode 100644 index 00000000..6b2e2bcd --- /dev/null +++ b/core/src/main/resources/META-INF/dokka/dokka-version.properties @@ -0,0 +1 @@ +dokka-version=<dokka-version> diff --git a/integration-tests/gradle/build.gradle.kts b/integration-tests/gradle/build.gradle.kts index 3f5baa7b..fb5e5739 100644 --- a/integration-tests/gradle/build.gradle.kts +++ b/integration-tests/gradle/build.gradle.kts @@ -7,6 +7,7 @@ dependencies { tasks { test { inputs.dir(file("projects")) + rootProject.allprojects .mapNotNull { project -> project.tasks.findByName("publishToMavenLocal") } .forEach { publishTask -> this.dependsOn(publishTask) } diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts index bdb59279..3e451fd3 100644 --- a/integration-tests/gradle/projects/it-basic/build.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts @@ -18,5 +18,5 @@ dependencies { afterEvaluate { logger.quiet("Gradle version: ${gradle.gradleVersion}") - logger.quiet("Kotlin version: ${property("kotlin_version")}") + logger.quiet("Kotlin version: ${findProperty("kotlin_version")}") } diff --git a/integration-tests/gradle/projects/it-basic/gradle.properties b/integration-tests/gradle/projects/it-basic/gradle.properties deleted file mode 100644 index 625ff49c..00000000 --- a/integration-tests/gradle/projects/it-basic/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -kotlin_version=1.4-M2-eap-70 -dokka_version=0.11.0-SNAPSHOT diff --git a/integration-tests/gradle/projects/it-basic/settings.gradle.kts b/integration-tests/gradle/projects/it-basic/settings.gradle.kts index 4ee17dee..9bfd026f 100644 --- a/integration-tests/gradle/projects/it-basic/settings.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/settings.gradle.kts @@ -1,19 +1,12 @@ @file:Suppress("LocalVariableName", "UnstableApiUsage") pluginManagement { - val kotlin_version: String by settings - val dokka_version: String by settings + val kotlin_version = "1.3.72" + val dokka_version = "0.11.0-SNAPSHOT" plugins { id("org.jetbrains.kotlin.jvm") version kotlin_version - } - - resolutionStrategy { - eachPlugin { - if (requested.id.id == "org.jetbrains.dokka") { - useModule("org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version") - } - } + id("org.jetbrains.dokka") version dokka_version } repositories { @@ -26,3 +19,4 @@ pluginManagement { } rootProject.name = "it-basic" + diff --git a/runners/gradle-plugin/build.gradle.kts b/runners/gradle-plugin/build.gradle.kts index d2e9eccd..e0241f67 100644 --- a/runners/gradle-plugin/build.gradle.kts +++ b/runners/gradle-plugin/build.gradle.kts @@ -2,6 +2,7 @@ import org.jetbrains.configureBintrayPublication plugins { id("com.gradle.plugin-publish") + `java-gradle-plugin` } repositories { @@ -26,19 +27,6 @@ dependencies { } } -tasks { - processResources { - val dokka_version: String by project - eachFile { - if (name == "org.jetbrains.dokka.properties") { - filter { line -> - line.replace("<version>", dokka_version) - } - } - } - } -} - val sourceJar by tasks.registering(Jar::class) { archiveClassifier.set("sources") from(sourceSets["main"].allSource) @@ -56,6 +44,15 @@ publishing { configureBintrayPublication("dokkaGradlePlugin") // TODO check if this publishes correctly +gradlePlugin { + plugins { + create("dokkaGradlePlugin") { + id = "org.jetbrains.dokka" + implementationClass = "org.jetbrains.dokka.gradle.DokkaPlugin" + } + } +} + pluginBundle { // TODO check if this publishes correctly website = "https://www.kotlinlang.org/" @@ -64,8 +61,7 @@ pluginBundle { tags = listOf("dokka", "kotlin", "kdoc", "android") plugins { - create("dokkaGradlePlugin") { - id = "org.jetbrains.dokka" + getByName("dokkaGradlePlugin") { displayName = "Dokka plugin" } } @@ -74,4 +70,4 @@ pluginBundle { groupId = "org.jetbrains.dokka" artifactId = "dokka-gradle-plugin" } -}
\ No newline at end of file +} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index 2b076fd0..92d63a40 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -5,9 +5,8 @@ import org.gradle.api.Project import org.gradle.api.artifacts.Configuration import org.gradle.api.attributes.Usage import org.gradle.util.GradleVersion +import org.jetbrains.dokka.DokkaVersion import java.io.File -import java.io.InputStream -import java.util.* internal const val SOURCE_SETS_EXTENSION_NAME = "dokkaSourceSets" internal const val DOKKA_TASK_NAME = "dokka" @@ -16,7 +15,6 @@ internal const val DOKKA_MULTIMODULE_TASK_NAME = "dokkaMultimodule" open class DokkaPlugin : Plugin<Project> { override fun apply(project: Project) { - loadDokkaVersion() val dokkaRuntimeConfiguration = addConfiguration(project) val pluginsConfiguration = project.configurations.create("dokkaPlugins").apply { dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-base:${DokkaVersion.version}")) @@ -35,8 +33,6 @@ open class DokkaPlugin : Plugin<Project> { ) } - private fun loadDokkaVersion() = - DokkaVersion.loadFrom(javaClass.getResourceAsStream("/META-INF/gradle-plugins/org.jetbrains.dokka.properties")) private fun addConfiguration(project: Project) = project.configurations.create("dokkaRuntime").apply { @@ -99,17 +95,7 @@ open class DokkaPlugin : Plugin<Project> { } } -object DokkaVersion { - var version: String? = null - - fun loadFrom(stream: InputStream) { - version = Properties().apply { - load(stream) - }.getProperty("dokka-version") - } -} - internal object ClassloaderContainer { @JvmField var coreClassLoader: ClassLoader? = null -}
\ No newline at end of file +} |