From c0ce35627413103d64845ca3c56b9ceab0606b6b Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 1 Jul 2020 14:30:49 +0200 Subject: Re-implement first basic gradle integration test --- integration-tests/gradle/projects/it-basic/gradle.properties | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 integration-tests/gradle/projects/it-basic/gradle.properties (limited to 'integration-tests/gradle/projects/it-basic/gradle.properties') diff --git a/integration-tests/gradle/projects/it-basic/gradle.properties b/integration-tests/gradle/projects/it-basic/gradle.properties new file mode 100644 index 00000000..625ff49c --- /dev/null +++ b/integration-tests/gradle/projects/it-basic/gradle.properties @@ -0,0 +1,2 @@ +kotlin_version=1.4-M2-eap-70 +dokka_version=0.11.0-SNAPSHOT -- cgit From 2e02e56818609c683f95ba4f17fa749eb9e1c705 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 1 Jul 2020 16:38:56 +0200 Subject: runner:gradle-plugin: Apply `java-gradle-plugin` --- core/build.gradle.kts | 13 ++++++++++ core/src/main/kotlin/DokkaVersion.kt | 10 ++++++++ .../META-INF/dokka/dokka-version.properties | 1 + integration-tests/gradle/build.gradle.kts | 1 + .../gradle/projects/it-basic/build.gradle.kts | 2 +- .../gradle/projects/it-basic/gradle.properties | 2 -- .../gradle/projects/it-basic/settings.gradle.kts | 14 ++++------- runners/gradle-plugin/build.gradle.kts | 28 ++++++++++------------ .../main/kotlin/org/jetbrains/dokka/gradle/main.kt | 18 ++------------ 9 files changed, 44 insertions(+), 45 deletions(-) create mode 100644 core/src/main/kotlin/DokkaVersion.kt create mode 100644 core/src/main/resources/META-INF/dokka/dokka-version.properties delete mode 100644 integration-tests/gradle/projects/it-basic/gradle.properties (limited to 'integration-tests/gradle/projects/it-basic/gradle.properties') 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) + } + } + } + } +} + publishing { publications { register("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= 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("", 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 { 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 { ) } - 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 { } } -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 +} -- cgit From 012190fbfd049f56637b1039f4ae1f69becea881 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 1 Jul 2020 17:38:49 +0200 Subject: Gradle integration tests: Use dokka_it_kotlin_version over kotlin_version --- .../src/main/kotlin/org/jetbrains/DokkaVersion.kt | 20 ++++++++++++-------- .../testData/androidApp/app/build.gradle | 2 +- .../gradle/projects/it-basic/build.gradle.kts | 4 +--- .../gradle/projects/it-basic/gradle.properties | 1 + .../gradle/projects/it-basic/settings.gradle.kts | 4 ++-- .../dokka/it/gradle/AbstractGradleIntegrationTest.kt | 6 +++++- 6 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 integration-tests/gradle/projects/it-basic/gradle.properties (limited to 'integration-tests/gradle/projects/it-basic/gradle.properties') diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt index 5bd35415..d5fd3e78 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/DokkaVersion.kt @@ -7,13 +7,17 @@ import org.gradle.kotlin.dsl.provideDelegate fun Project.configureDokkaVersion(): String { var dokka_version: String? by this.extra if (dokka_version == null) { - val buildNumber = System.getenv("BUILD_NUMBER") val dokka_version_base: String by this - dokka_version = dokka_version_base + if (buildNumber == null || System.getenv("FORCE_SNAPSHOT") != null) { - "-SNAPSHOT" - } else { - "-$buildNumber" - } + dokka_version = dokkaVersionFromBase(dokka_version_base) } - return dokka_version!! -} \ No newline at end of file + return checkNotNull(dokka_version) +} + +private fun dokkaVersionFromBase(baseVersion: String): String { + val buildNumber = System.getenv("BUILD_NUMBER") + val forceSnapshot = System.getenv("FORCE_SNAPSHOT") != null + if (forceSnapshot || buildNumber == null) { + return "$baseVersion-SNAPSHOT" + } + return "$baseVersion-$buildNumber" +} diff --git a/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle b/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle index 2420107c..0092b76c 100644 --- a/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle +++ b/integration-tests/gradle-integration-tests/testData/androidApp/app/build.gradle @@ -42,4 +42,4 @@ android { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$test_kotlin_version" dokkaRuntime files(dokka_fatjar) -} \ No newline at end of file +} diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts index 3e451fd3..80c2bbea 100644 --- a/integration-tests/gradle/projects/it-basic/build.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.dokka.gradle.dokka - plugins { kotlin("jvm") id("org.jetbrains.dokka") @@ -18,5 +16,5 @@ dependencies { afterEvaluate { logger.quiet("Gradle version: ${gradle.gradleVersion}") - logger.quiet("Kotlin version: ${findProperty("kotlin_version")}") + logger.quiet("Kotlin version: ${properties["dokka_it_kotlin_version"]}") } diff --git a/integration-tests/gradle/projects/it-basic/gradle.properties b/integration-tests/gradle/projects/it-basic/gradle.properties new file mode 100644 index 00000000..7ebac3ad --- /dev/null +++ b/integration-tests/gradle/projects/it-basic/gradle.properties @@ -0,0 +1 @@ +dokka_it_kotlin_version=1.3.72 diff --git a/integration-tests/gradle/projects/it-basic/settings.gradle.kts b/integration-tests/gradle/projects/it-basic/settings.gradle.kts index 9bfd026f..10447365 100644 --- a/integration-tests/gradle/projects/it-basic/settings.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/settings.gradle.kts @@ -1,11 +1,11 @@ @file:Suppress("LocalVariableName", "UnstableApiUsage") pluginManagement { - val kotlin_version = "1.3.72" + val dokka_it_kotlin_version: String by settings val dokka_version = "0.11.0-SNAPSHOT" plugins { - id("org.jetbrains.kotlin.jvm") version kotlin_version + id("org.jetbrains.kotlin.jvm") version dokka_it_kotlin_version id("org.jetbrains.dokka") version dokka_version } diff --git a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt index 34114c74..d8a9a60f 100644 --- a/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt @@ -23,7 +23,11 @@ abstract class AbstractGradleIntegrationTest { .withProjectDir(projectDir) .withGradleVersion(buildVersions.gradleVersion) .forwardOutput() - .withArguments("-Pkotlin_version=${buildVersions.kotlinVersion}", *arguments) + .withArguments( + "-Pkotlin_version=${buildVersions.kotlinVersion}", + "-Pdokka_it_kotlin_version=${buildVersions.kotlinVersion}", + * arguments + ) .withDebug(true) } -- cgit