From b8b944ef0385fc84a2bd6f1635be6bfcd45bf90e Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Fri, 20 Oct 2023 19:09:02 +0300 Subject: [PATCH] restore gradle integration tests --- .../conventions/kotlin-jvm.gradle.kts | 44 +++++-------------- build.gradle.kts | 3 +- dokka-integration-tests/build.gradle.kts | 4 -- dokka-integration-tests/gradle.properties | 7 ++- .../gradle/build.gradle.kts | 21 ++++++++- .../gradle/projects/template.root.gradle.kts | 6 ++- .../projects/template.settings.gradle.kts | 13 +++++- .../jetbrains/dokka/it/gitSubmoduleUtils.kt | 4 +- dokka-integration-tests/settings.gradle.kts | 8 +++- settings.gradle.kts | 2 +- 10 files changed, 60 insertions(+), 52 deletions(-) diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts index f5c03fc030..9bef064f0a 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts @@ -4,52 +4,30 @@ package org.jetbrains.conventions -import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { id("org.jetbrains.conventions.base-java") kotlin("jvm") } kotlin { - explicitApi = ExplicitApiMode.Strict - + explicitApi() compilerOptions { allWarningsAsErrors.set(true) languageVersion.set(dokkaBuild.kotlinLanguageLevel) apiVersion.set(dokkaBuild.kotlinLanguageLevel) freeCompilerArgs.addAll( - listOf( - // need 1.4 support, otherwise there might be problems - // with Gradle 6.x (it's bundling Kotlin 1.4) - "-Xsuppress-version-warnings", - "-Xjsr305=strict", - "-Xskip-metadata-version-check", - ) + // need 1.4 support, otherwise there might be problems + // with Gradle 6.x (it's bundling Kotlin 1.4) + "-Xsuppress-version-warnings", + "-Xjsr305=strict", + "-Xskip-metadata-version-check", ) - } -} - -val projectsWithoutInternalDokkaApiUsage = setOf( - ":integration-tests", - ":integration-tests:gradle", - ":integration-tests:maven", - ":integration-tests:cli" -) - -tasks.withType().configureEach { - // By path because Dokka has multiple projects with the same name (i.e. 'cli') - if (project.path in projectsWithoutInternalDokkaApiUsage) { - return@configureEach - } - compilerOptions { - freeCompilerArgs.addAll( - listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.jetbrains.dokka.InternalDokkaApi", + if (rootProject.name != "dokka-integration-tests") { + optIn.addAll( + "kotlin.RequiresOptIn", + "org.jetbrains.dokka.InternalDokkaApi" ) - ) + } } } diff --git a/build.gradle.kts b/build.gradle.kts index cc9657b37f..007d88a909 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,8 +4,7 @@ @Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 https://github.com/gradle/gradle/pull/23639 plugins { - id("org.jetbrains.conventions.base") - id("org.jetbrains.conventions.dokka") + base } addDependencyOnSameTaskOfIncludedBuilds("assemble") diff --git a/dokka-integration-tests/build.gradle.kts b/dokka-integration-tests/build.gradle.kts index 4ec1f77acb..1c9ba4de73 100644 --- a/dokka-integration-tests/build.gradle.kts +++ b/dokka-integration-tests/build.gradle.kts @@ -1,7 +1,3 @@ /* * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ - -plugins { - id("org.jetbrains.conventions.base") -} diff --git a/dokka-integration-tests/gradle.properties b/dokka-integration-tests/gradle.properties index 1d52104ed6..9e0b4b9ba0 100644 --- a/dokka-integration-tests/gradle.properties +++ b/dokka-integration-tests/gradle.properties @@ -3,8 +3,11 @@ # # Project Settings -# TODO remove 'dokka_version' - it doesn't need to be mandatory for non-published subprojects -dokka_version=1.9.20-SNAPSHOT +# while integration tests module isn't published, +# the version here should be in sync with other versions. +# it's used to resolve dependencies +version=1.9.20-SNAPSHOT + org.jetbrains.dokka.javaToolchain.mainCompiler=8 org.jetbrains.dokka.javaToolchain.testLauncher=8 dokka_integration_test_parallelism=2 diff --git a/dokka-integration-tests/gradle/build.gradle.kts b/dokka-integration-tests/gradle/build.gradle.kts index d2d82d50cf..fa1242c0c2 100644 --- a/dokka-integration-tests/gradle/build.gradle.kts +++ b/dokka-integration-tests/gradle/build.gradle.kts @@ -19,9 +19,26 @@ dependencies { implementation(libs.jsoup) } +val dokkaSubprojects = gradle.includedBuild("dokka-subprojects") +val gradlePluginClassic = gradle.includedBuild("gradle-plugin-classic") + tasks.integrationTest { - val dokka_version: String by project - environment("DOKKA_VERSION", dokka_version) + dependsOn( + dokkaSubprojects.task(":publishAllPublicationsToProjectLocalRepository"), + gradlePluginClassic.task(":publishAllPublicationsToProjectLocalRepository"), + ) + environment( + "DOKKA_VERSION", + project.version + ) + environment( + "DOKKA_LOCAL_REPOSITORY_SUBPROJECTS", + dokkaSubprojects.projectDir.resolve("build/maven-project-local") + ) + environment( + "DOKKA_LOCAL_REPOSITORY_GRADLE_PLUGIN", + gradlePluginClassic.projectDir.resolve("build/maven-project-local") + ) inputs.dir(file("projects")) javaLauncher.set(javaToolchains.launcherFor { diff --git a/dokka-integration-tests/gradle/projects/template.root.gradle.kts b/dokka-integration-tests/gradle/projects/template.root.gradle.kts index a7fc4bf833..2e2e078c90 100644 --- a/dokka-integration-tests/gradle/projects/template.root.gradle.kts +++ b/dokka-integration-tests/gradle/projects/template.root.gradle.kts @@ -4,7 +4,11 @@ allprojects { repositories { - mavenLocal() + maven(System.getenv("DOKKA_LOCAL_REPOSITORY_SUBPROJECTS")) { + content { + includeGroup("org.jetbrains.dokka") + } + } mavenCentral() google() maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") { diff --git a/dokka-integration-tests/gradle/projects/template.settings.gradle.kts b/dokka-integration-tests/gradle/projects/template.settings.gradle.kts index aa6ee1966d..8c232e62f5 100644 --- a/dokka-integration-tests/gradle/projects/template.settings.gradle.kts +++ b/dokka-integration-tests/gradle/projects/template.settings.gradle.kts @@ -18,7 +18,7 @@ pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.id == "org.jetbrains.dokka") { - useModule("org.jetbrains.dokka:dokka-gradle-plugin:for-integration-tests-SNAPSHOT") + useModule("org.jetbrains.dokka:dokka-gradle-plugin:${System.getenv("DOKKA_VERSION")}") } if (requested.id.id == "com.android.library") { @@ -31,7 +31,16 @@ pluginManagement { } } repositories { - mavenLocal() + maven(System.getenv("DOKKA_LOCAL_REPOSITORY_GRADLE_PLUGIN")) { + content { + includeGroup("org.jetbrains.dokka") + } + } + maven(System.getenv("DOKKA_LOCAL_REPOSITORY_SUBPROJECTS")) { + content { + includeGroup("org.jetbrains.dokka") + } + } mavenCentral() gradlePluginPortal() google() diff --git a/dokka-integration-tests/integration-test-utilities/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt b/dokka-integration-tests/integration-test-utilities/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt index b4c633301d..f8f103be2f 100644 --- a/dokka-integration-tests/integration-test-utilities/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt +++ b/dokka-integration-tests/integration-test-utilities/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt @@ -39,7 +39,5 @@ public fun AbstractIntegrationTest.applyGitDiffFromFile(diffFile: File) { private fun removeGitFile(repository: Path) = repository.toFile() .listFiles().orEmpty() - .filter { it.name.toLowerCase() == ".git" } + .filter { it.name.equals(".git", ignoreCase = true) } .forEach { it.delete() } - - diff --git a/dokka-integration-tests/settings.gradle.kts b/dokka-integration-tests/settings.gradle.kts index 2e2b0f7a8b..762d444e55 100644 --- a/dokka-integration-tests/settings.gradle.kts +++ b/dokka-integration-tests/settings.gradle.kts @@ -29,9 +29,13 @@ dependencyResolutionManagement { enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") +includeBuild("../dokka-runners/gradle-plugin-classic") +includeBuild("../dokka-runners/cli") +includeBuild("../dokka-subprojects") + include( - ":cli", +// ":cli", ":gradle", - ":maven", +// ":maven", ":integration-test-utilities", ) diff --git a/settings.gradle.kts b/settings.gradle.kts index da48f13172..613d800358 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -59,7 +59,7 @@ plugins { } // TODO [structure-refactoring] enable all -//includeBuild("dokka-integration-tests") +includeBuild("dokka-integration-tests") includeBuild("dokka-subprojects") // gradle-plugin should sync, but might not be buildable yet //includeBuild("dokka-runners/gradle-plugin")