Skip to content

Commit

Permalink
Merge branch 'master' into KT-64377/maven-dev-publish
Browse files Browse the repository at this point in the history
# Conflicts:
#	dokka-integration-tests/gradle/projects/it-android-0/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-basic-groovy/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-basic/build.gradle.kts
#	dokka-integration-tests/gradle/projects/it-basic/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-collector-0/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-configuration/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-js-ir-0/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-multimodule-0/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-multimodule-1/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-multimodule-inter-module-links/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-multimodule-versioning-0/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-multiplatform-0/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-sequential-tasks-execution-stress/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-wasm-basic/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/it-wasm-js-wasi-basic/settings.gradle.kts
#	dokka-integration-tests/gradle/projects/template.settings.gradle.kts
#	dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt
#	dokka-integration-tests/gradle/src/testExternalProjectKotlinxSerialization/kotlin/SerializationGradleIntegrationTest.kt
#	dokka-integration-tests/gradle/src/testTemplateProjectBasic/kotlin/AbstractGradleCachingIntegrationTest.kt
#	dokka-integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/BiojavaIntegrationTest.kt
#	dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/systemProperties.kt
  • Loading branch information
adam-enko committed Feb 14, 2024
2 parents 7bb6270 + d9f1efe commit 916d07c
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 103 deletions.
25 changes: 20 additions & 5 deletions build-logic/src/main/kotlin/dokkabuild.setup-maven-cli.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import dokkabuild.tasks.MvnExec
import org.gradle.kotlin.dsl.support.serviceOf

/**
Expand Down Expand Up @@ -33,6 +34,10 @@ abstract class MavenCliSetupExtension {
* * Unix: `$mavenInstallDir/bin/mvn`
*/
abstract val mvn: RegularFileProperty

companion object {
const val MAVEN_PLUGIN_GROUP = "maven plugin"
}
}

val mavenCliSetupExtension =
Expand Down Expand Up @@ -84,11 +89,12 @@ val installMavenBinary by tasks.registering(Sync::class) {
val archives = serviceOf<ArchiveOperations>()
from(
mavenBinary.flatMap { conf ->
val resolvedArtifacts = conf.incoming.artifacts.resolvedArtifacts

resolvedArtifacts.map { artifacts ->
artifacts.map { archives.zipTree(it.file) }
}
conf.incoming
.artifacts
.resolvedArtifacts
.map { artifacts ->
artifacts.map { archives.zipTree(it.file) }
}
}
) {
eachFile {
Expand All @@ -99,3 +105,12 @@ val installMavenBinary by tasks.registering(Sync::class) {
}
into(mavenCliSetupExtension.mavenInstallDir)
}

tasks.withType<MvnExec>().configureEach {
group = MavenCliSetupExtension.MAVEN_PLUGIN_GROUP
dependsOn(installMavenBinary)
mvnCli.convention(mavenCliSetupExtension.mvn)
workDirectory.convention(layout.dir(provider { temporaryDir }))
showErrors.convention(true)
batchMode.convention(true)
}
107 changes: 107 additions & 0 deletions build-logic/src/main/kotlin/dokkabuild/tasks/MvnExec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package dokkabuild.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.PathSensitivity.NONE
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.process.ExecOperations
import org.gradle.work.NormalizeLineEndings
import java.util.*
import javax.inject.Inject

/**
* Runs a Maven task.
*
* See `dokkabuild.setup-maven-cli.gradle.kts` for details on the Maven CLI installation.
*/
@CacheableTask
abstract class MvnExec
@Inject
constructor(
private val exec: ExecOperations,
private val fs: FileSystemOperations,
) : DefaultTask() {

/**
* Work directory.
*
* Be aware that any existing content will be replaced by [inputFiles].
*/
@get:OutputDirectory
abstract val workDirectory: DirectoryProperty

/** Input files - will be synced to [workDirectory]. */
@get:InputFiles
@get:PathSensitive(RELATIVE)
@get:NormalizeLineEndings
abstract val inputFiles: ConfigurableFileCollection

@get:InputFile
@get:PathSensitive(NONE)
abstract val mvnCli: RegularFileProperty

@get:Input
abstract val arguments: ListProperty<String>

/** `-e` - Produce execution error messages. */
@get:Input
@get:Optional
abstract val showErrors: Property<Boolean>

/** `-B` - Run in non-interactive (batch) mode. */
@get:Input
@get:Optional
abstract val batchMode: Property<Boolean>

@TaskAction
fun exec() {
fs.sync {
from(inputFiles)
into(workDirectory)
}

val arguments = buildList {
addAll(arguments.get())
if (showErrors.orNull == true) add("--errors")
if (batchMode.orNull == true) add("--batch-mode")
}

exec.exec {
workingDir(workDirectory)
executable(mvnCli.get())
args(arguments)
}

makePropertiesFilesReproducible()
}

/**
* Remove non-reproducible timestamps from any generated [Properties] files.
*/
private fun makePropertiesFilesReproducible() {
workDirectory.get().asFile.walk()
.filter { it.isFile && it.extension == "properties" }
.forEach { file ->
logger.info("[MvnExec $path] removing timestamp from $file")
// drop the last comment - java.util.Properties always adds a timestamp, which is not-reproducible.
val comments = file.readLines()
.takeWhile { it.startsWith('#') }
.dropLast(1)

val properties = file.readLines().dropWhile { it.startsWith('#') }

val updatedProperties = (comments + properties).joinToString("\n")
file.writeText(updatedProperties)
}
}
}
14 changes: 13 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 @@ -213,10 +214,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
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")
rootProject.name = "it-android-0"

apply(from = "./template.settings.gradle.kts")
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")
rootProject.name = "it-basic-groovy"

apply(from = "./template.settings.gradle.kts")
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ tasks.withType<DokkaTask>().configureEach {
}
suppressObviousFunctions.set(false)

// register resources as inputs for Gradle up-to-date checks
val customResourcesDir = layout.projectDirectory.dir("customResources")
inputs.dir(customResourcesDir)
.withPropertyName("customResourcesDir")
Expand All @@ -82,6 +83,5 @@ tasks.withType<DokkaTask>().configureEach {
]
}
""".trimIndent()
)
)
))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

rootProject.name = "it-basic"
@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
Expand Up @@ -2,10 +2,8 @@
* 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")
rootProject.name = "it-collector-0"

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

include(":moduleA")
include(":moduleA:moduleB")
include(":moduleA:moduleC")
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")
rootProject.name = "it-configuration"

apply(from = "./template.settings.gradle.kts")
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")
rootProject.name = "it-js-ir-0"

apply(from = "./template.settings.gradle.kts")
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
* 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")
rootProject.name = "it-multimodule-0"

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

include(":moduleA")
include(":moduleA:moduleB")
include(":moduleA:moduleC")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies {
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,9 +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")
rootProject.name = "it-multimodule-1"

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

include(":first")
include(":second")
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 @@ -10,7 +10,6 @@ dependencies {
dokkaPlugin "org.jetbrains.dokka:versioning-plugin:${System.getenv("dokka_it_dokka_version")}"
}


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,9 +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")
rootProject.name = "it-multimodule-versioning-0"

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

include(":first")
include(":second")
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")
rootProject.name = "it-multiplatform-0"

apply(from = "./template.settings.gradle.kts")
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")
rootProject.name = "it-sequential-tasks-execution-stress"

apply(from = "./template.settings.gradle.kts")
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")
rootProject.name = "it-wasm-basic"

apply(from = "./template.settings.gradle.kts")
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")
rootProject.name = "it-wasm-js-wasi-basic"

apply(from = "./template.settings.gradle.kts")
29 changes: 0 additions & 29 deletions dokka-integration-tests/gradle/projects/template.root.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ pluginManagement {
val dokka_it_dokka_version: String by settings
val dokka_it_android_gradle_plugin_version: String? by settings

logger.quiet("Gradle version: ${gradle.gradleVersion}")
logger.quiet("Kotlin version: $dokka_it_kotlin_version")
logger.quiet("Dokka version: $dokka_it_dokka_version")
logger.quiet("Android version: $dokka_it_android_gradle_plugin_version")

plugins {
id("org.jetbrains.kotlin.js") version dokka_it_kotlin_version
id("org.jetbrains.kotlin.jvm") version dokka_it_kotlin_version
Expand Down
Loading

0 comments on commit 916d07c

Please sign in to comment.