Skip to content

Commit

Permalink
Refactor Integration Test project setup steps (#3492)
Browse files Browse the repository at this point in the history
* refactor Gradle IT project setups

- deduplicate project copying code
- move custom repos into template.settings.gradle.kts & remove redundant template.root.gradle.kts
- pass template.settings.gradle.kts as a Gradle task input, so the project-copying code can use it
- refactor `copyAndApplyGitDiff()` to try and make it a bit more legible
- update version logging in template.settings.gradle.kts
- move templateSettingsGradleKts to be inside testSuite util function
  • Loading branch information
adam-enko committed Feb 14, 2024
1 parent 1877ec4 commit d9f1efe
Show file tree
Hide file tree
Showing 58 changed files with 294 additions and 332 deletions.
15 changes: 14 additions & 1 deletion dokka-integration-tests/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@file:Suppress("UnstableApiUsage")

import dokkabuild.tasks.GitCheckoutTask
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED
Expand Down Expand Up @@ -38,6 +39,7 @@ kotlin {
}

val aggregatingProject = gradle.includedBuild("dokka")
val templateSettingsGradleKts = layout.projectDirectory.file("projects/template.settings.gradle.kts")
val templateProjectsDir = layout.projectDirectory.dir("projects")

tasks.integrationTestPreparation {
Expand Down Expand Up @@ -183,10 +185,21 @@ fun TestingExtension.registerTestProjectSuite(
targets.configureEach {
testTask.configure {
// Register the project dir as a specific input, so changes in other projects don't affect the caching of this test
inputs.dir(templateProjectDir).withPropertyName("templateProjectDir")
inputs.dir(templateProjectDir)
.withPropertyName("templateProjectDir")
.withPathSensitivity(RELATIVE)

// Pass the template dir in as a property, it is accessible in tests.
systemProperty("templateProjectDir", templateProjectDir.asFile.invariantSeparatorsPath)

inputs.file(templateSettingsGradleKts)
.withPropertyName("templateSettingsGradleKts")
.withPathSensitivity(RELATIVE)
systemProperty(
"templateSettingsGradleKts",
templateSettingsGradleKts.asFile.invariantSeparatorsPath,
)

if (jvm != null) {
javaLauncher = javaToolchains.launcherFor { languageVersion = jvm }
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ plugins {
kotlin("android")
}

apply(from = "../template.root.gradle.kts")

android {
defaultConfig {
minSdkVersion(21)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-android-0"

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ plugins {
id("org.jetbrains.dokka")
}

apply from: '../template.root.gradle.kts'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
Expand Down Expand Up @@ -52,4 +50,3 @@ dokkaGfm {
dokkaJekyll {
outputDirectory = new File(buildDir, "dokka/customJekyll")
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-basic-groovy"

31 changes: 26 additions & 5 deletions dokka-integration-tests/gradle/projects/it-basic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ plugins {

buildscript {
dependencies {
classpath("org.jetbrains.dokka:dokka-base:${System.getenv("DOKKA_VERSION")}")
classpath("org.jetbrains.dokka:dokka-base:${providers.gradleProperty("dokka_it_dokka_version").get()}")
}
}

version = "2.0.0-SNAPSHOT"

apply(from = "../template.root.gradle.kts")

dependencies {
testImplementation(kotlin("test-junit"))
}

tasks.withType<DokkaTask> {
tasks.withType<DokkaTask>().configureEach {
moduleName.set("Basic Project")
dokkaSourceSets {
configureEach {
Expand Down Expand Up @@ -63,5 +61,28 @@ tasks.withType<DokkaTask> {
}
suppressObviousFunctions.set(false)

pluginsMapConfiguration.set(mapOf(DokkaBase::class.qualifiedName to """{ "customStyleSheets": ["${file("../customResources/logo-styles.css").invariantSeparatorsPath}", "${file("../customResources/custom-style-to-add.css").invariantSeparatorsPath}"], "customAssets" : ["${file("../customResources/custom-resource.svg").invariantSeparatorsPath}"] }"""))
// register resources as inputs for Gradle up-to-date checks
val customResourcesDir = layout.projectDirectory.dir("customResources")
inputs.dir(customResourcesDir)
.withPropertyName("customResourcesDir")
.withPathSensitivity(PathSensitivity.RELATIVE)
.normalizeLineEndings()

val logoStylesCss = customResourcesDir.file("logo-styles.css").asFile.invariantSeparatorsPath
val customStyleToAddCss = customResourcesDir.file("custom-style-to-add.css").asFile.invariantSeparatorsPath
val customResourceSvg = customResourcesDir.file("custom-resource.svg").asFile.invariantSeparatorsPath

pluginsMapConfiguration.set(mapOf(DokkaBase::class.qualifiedName to """
{
"customStyleSheets": [
"$logoStylesCss",
"$customStyleToAddCss"
],
"customAssets" : [
"$customResourceSvg"
]
}
""".trimIndent()
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-basic"

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/*
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.root.gradle.kts")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-collector-0"
include(":moduleA")
include(":moduleA:moduleB")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ buildscript {

version = "2.0.0-SNAPSHOT"

apply(from = "../template.root.gradle.kts")

tasks.withType<DokkaTask> {
moduleName.set("Configuration Test Project")
dokkaSourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-configuration"

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ plugins {
kotlin("js")
}

apply(from = "../template.root.gradle.kts")

kotlin {
js(IR) {
browser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-js-ir-0"

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/*
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.root.gradle.kts")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-multimodule-0"
include(":moduleA")
include(":moduleA:moduleB")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ plugins {
id("org.jetbrains.dokka")
}

apply from: '../template.root.gradle.kts'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation project(':first')
implementation project(':second')
}


subprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.dokka'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-multimodule-1"
include(":first")
include(":second")
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/*
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.root.gradle.kts")
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-multimodule-inter-module-links"
include(":moduleA")
include(":moduleA:moduleB")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ plugins {
id("org.jetbrains.dokka")
}

apply from: '../template.root.gradle.kts'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
dokkaPlugin "org.jetbrains.dokka:versioning-plugin:${System.getenv("DOKKA_VERSION")}"
}


subprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.dokka'
Expand Down Expand Up @@ -40,4 +37,4 @@ tasks.register('dokkaHtmlMultiModuleNextVersion', DokkaMultiModuleTask){
outputDirectory.set(file(projectDir.toPath().resolve("dokkas").resolve("1.1")))
pluginsMapConfiguration.set(["org.jetbrains.dokka.versioning.VersioningPlugin": """{ "version": "1.1", "olderVersionsDir": "$projectDir/dokkas" }"""])
addChildTasks([project(":first"), project(":second")], "dokkaHtmlPartial")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-multimodule-versioning-0"
include(":first")
include(":second")
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ plugins {
id("org.jetbrains.dokka")
}

apply(from = "../template.root.gradle.kts")

kotlin {
jvm()
linuxX64("linux")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-multiplatform-0"
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ buildscript {
}
}

apply(from = "../template.root.gradle.kts")

fun createTask(name: String) {
tasks.register(name, org.jetbrains.dokka.gradle.DokkaTask::class) {
dokkaSourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-sequential-tasks-execution-stress"

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ plugins {
id("org.jetbrains.dokka")
}

apply(from = "../template.root.gradle.kts")

repositories {
// Remove it when wasm target will be published into public maven repository
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
}

kotlin {
wasm()
sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-wasm-basic"
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ plugins {
id("org.jetbrains.dokka")
}

apply(from = "../template.root.gradle.kts")

repositories {
// Remove it when wasm target will be published into public maven repository
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
}

kotlin {
wasmJs()
sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

apply(from = "../template.settings.gradle.kts")
apply(from = "template.settings.gradle.kts")
rootProject.name = "it-wasm-js-wasi-basic"

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions dokka-integration-tests/gradle/projects/template.root.gradle.kts

This file was deleted.

0 comments on commit d9f1efe

Please sign in to comment.