Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Dokkatoo into Dokka Gradle Plugin #3695

Merged
merged 78 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift click to select a range
bf190e7
initial Dokkatoo import
adam-enko Jul 16, 2024
80796c9
Fixing Dokka plugin
adam-enko Jul 16, 2024
4093d0c
reduce logging in Gradle integration tests
adam-enko Jul 17, 2024
99ee898
disable stress test
adam-enko Jul 17, 2024
5d0f32c
refactor workaround for included-build task-selectors
adam-enko Jul 17, 2024
4ab1dd8
fix KGP tests
adam-enko Jul 17, 2024
54fabe9
disable info logging in Gradle tests
adam-enko Jul 17, 2024
fed9ec4
refactor dgp build conf
adam-enko Jul 17, 2024
7ed2808
delete DGP-classic
adam-enko Jul 17, 2024
6824893
tweak DGP build config
adam-enko Jul 17, 2024
b9c15f0
remove empty tests
adam-enko Jul 17, 2024
f9806ff
update dokkatoo package name
adam-enko Jul 18, 2024
c87f6b4
update TaskPathCollector workaround
adam-enko Jul 18, 2024
bea130d
build cache Versioning0IntegrationTest to try and make it faster
adam-enko Jul 18, 2024
2f566ad
fix LogHtmlPublicationLinkTask
adam-enko Jul 18, 2024
0d33a38
undo making dokka-subprojects an IB, instead remove DGP from build-lo…
adam-enko Jul 18, 2024
bd0978f
Specify language/api as Kotlin 1.4 for dokka-gradle-plugin (to be com…
adam-enko Jul 24, 2024
8af1d72
Add better up-to-date check for GitCheckoutTask
adam-enko Jul 24, 2024
b31e518
update Kotlin LV to 1.4 (to support Grade 7)
adam-enko Jul 24, 2024
af66287
remove debug logging
adam-enko Jul 24, 2024
03d8b9f
update api dump
adam-enko Jul 24, 2024
69d83c0
remove/tidy old config
adam-enko Jul 24, 2024
5a92608
use Java 21 to compile, but target Java 8
adam-enko Jul 24, 2024
9734c27
update formatting, add copyright header
adam-enko Jul 24, 2024
dd847ac
update formatting
adam-enko Jul 24, 2024
df43d03
remove duplicated 'Isolation' from WorkerIsolation subtypes, & fix test
adam-enko Jul 24, 2024
b23254d
renaming 'Dokkatoo' to 'Dokka'...
adam-enko Jul 24, 2024
ef83bbe
renaming 'Dokkatoo' to 'Dokka'...
adam-enko Jul 24, 2024
ead8e8a
fix ExperimentalFlags package
adam-enko Jul 24, 2024
6b8f97c
tidying, renaming 'Dokkatoo' to 'Dokka'...
adam-enko Jul 24, 2024
103a2d6
tidying, renaming 'Dokkatoo' to 'Dokka'...
adam-enko Jul 24, 2024
6829472
tidying, renaming 'Dokkatoo' to 'Dokka'...
adam-enko Jul 24, 2024
f8367d5
investigating build cache relocation failure...
adam-enko Jul 24, 2024
f14c51b
investigating build cache relocation failure...
adam-enko Jul 24, 2024
b523486
fix process isolation worker jvm args
adam-enko Jul 25, 2024
e17fc41
add 'min supported Gradle' warning
adam-enko Jul 25, 2024
26eba3f
fix DGP-classic Gradle 6 support
adam-enko Jul 25, 2024
cfe3388
fix forUseAtConfigurationTimeCompat?
adam-enko Jul 29, 2024
ad723ef
lazily fetch DokkaGradlePluginMode from `project.extra.properties`
adam-enko Jul 29, 2024
ed83fcb
Merge branch 'refs/heads/master' into adam/merge-dokkatoo
adam-enko Jul 29, 2024
bf9a32a
revert some changes to align with master
adam-enko Jul 29, 2024
1bdd991
formatting
adam-enko Jul 29, 2024
24c8fd3
tidy build config, use Java 21 to build, but target & test with Java 8
adam-enko Jul 29, 2024
99c2eeb
undo core/core-test-api rename
adam-enko Jul 29, 2024
52df9ad
re-add dokka-subprojects/build.gradle.kts
adam-enko Jul 29, 2024
c13ec10
add Gradle properties to gradle-plugin
adam-enko Jul 29, 2024
ff0f72a
Merge branch 'refs/heads/master' into adam/feat/OSIP-355/merge-dokkatoo
adam-enko Jul 30, 2024
9b505d3
bump node version
adam-enko Jul 30, 2024
a6aca9e
Merge branch 'refs/heads/master' into adam/feat/OSIP-355/merge-dokkatoo
adam-enko Jul 30, 2024
48ac207
revert log level changes
adam-enko Jul 30, 2024
9c77821
tidy
adam-enko Jul 30, 2024
b4d25e7
fixing KotlinNativeDistributionAccessor...
adam-enko Jul 30, 2024
6925b6f
fixing KotlinNativeDistributionAccessor...
adam-enko Jul 30, 2024
6cc5405
fix DGP group/version
adam-enko Jul 30, 2024
b1f4988
add copyright header
adam-enko Jul 30, 2024
18151ef
revert SequentialTasksExecutionStressTest
adam-enko Jul 30, 2024
2101027
Change BCV to official BCV
adam-enko Aug 1, 2024
315248f
fix `toLowerCase()` deprecation
adam-enko Aug 1, 2024
4fb3355
remove `dokka-gradle-plugin` from `libs.versions.toml` (it's no longe…
adam-enko Aug 1, 2024
e46fef6
set Kotlin api-version for DGP
adam-enko Aug 1, 2024
ed8e852
Use Java 8 toolchain for DGP compilation
adam-enko Aug 1, 2024
b85e97c
Merge branch 'refs/heads/master' into adam/feat/OSIP-355/merge-dokkatoo
adam-enko Aug 1, 2024
0e001f0
rename GradlePluginMode flag
adam-enko Aug 1, 2024
540cbb5
Merge branch 'refs/heads/master' into adam/feat/OSIP-355/merge-dokkatoo
adam-enko Aug 1, 2024
2bbd942
update opt-ins
adam-enko Aug 6, 2024
2330b53
remove duplicated plugin website/vcsUrl, move tags into specific Dokk…
adam-enko Aug 6, 2024
2cb3b64
update 'classic mode' log to warning, and add a short link
adam-enko Aug 6, 2024
2dc2fcd
remove redundant jvmTarget config. If jvmToolchain and jvmTarget are …
adam-enko Aug 6, 2024
da32fa6
Merge branch 'refs/heads/master' into adam/feat/OSIP-355/merge-dokkatoo
adam-enko Aug 6, 2024
28c3ada
remove unused test utils code
adam-enko Aug 6, 2024
4c86b2c
formatting
adam-enko Aug 6, 2024
7758651
Merge branch 'master' into adam/feat/OSIP-355/merge-dokkatoo
adam-enko Aug 7, 2024
f097480
tidy up config
adam-enko Aug 8, 2024
e338a86
de-dupe Java toolchain config
adam-enko Aug 8, 2024
35495a7
exclude Gradle's embedded-dependencies from DGP
adam-enko Aug 13, 2024
1edb668
remove extraneous leftover groups
adam-enko Aug 13, 2024
1a91447
tidy
adam-enko Aug 13, 2024
595b26b
Merge branch 'master' into adam/feat/OSIP-355/merge-dokkatoo
adam-enko Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 13,6 @@ kotlin {
}

dependencies {
implementation(libs.gradlePlugin.dokka)
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
implementation(libs.gradlePlugin.kotlin)
implementation(libs.gradlePlugin.shadow)
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion")
Expand Down
33 changes: 17 additions & 16 deletions build-logic/src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 2,35 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import dokkabuild.utils.excludeGradleEmbeddedDependencies
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("org.gradle.kotlin.kotlin-dsl")
id("dokkabuild.java")
kotlin("jvm")
id("dokkabuild.publish-gradle-plugin")
}

// org.gradle.kotlin.kotlin-dsl sets languageVersion and apiVersion to 1.8 by default starting from Gradle 8.
// As we need to be compatible with previous Gradle versions, we need to set it back to 1.4.
// Note: we should do it directly on tasks and not via top-level `kotlin.compilerOptions`
// because `kotlin-dsl plugin` declares them on task level, and so top-level config is overridden
tasks.withType<KotlinCompile>().configureEach {
kotlin {
compilerOptions {
languageVersion = dokkaBuild.kotlinLanguageLevel
apiVersion = dokkaBuild.kotlinLanguageLevel
// Must use Kotlin 1.4 to support Gradle 7
languageVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
apiVersion = @Suppress("DEPRECATION") KotlinVersion.KOTLIN_1_4
}
}

freeCompilerArgs.addAll(
// 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",
)
tasks.compileKotlin {
compilerOptions {
// `kotlin-dsl` plugin overrides the versions at the task level,
// which takes priority over the `kotlin` project extension.
// So, fix it by manually setting the LV per-task.
languageVersion.set(kotlin.compilerOptions.languageVersion)
apiVersion.set(kotlin.compilerOptions.apiVersion)
}
}

tasks.validatePlugins {
enableStricterValidation = true
}

excludeGradleEmbeddedDependencies(sourceSets.main)
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/dokkabuild.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 23,7 @@ tasks.withType<Test>().configureEach {
maxParallelForks = if (System.getenv("GITHUB_ACTIONS") != null) {
Runtime.getRuntime().availableProcessors()
} else {
(Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
(Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
}

javaLauncher = javaToolchains.launcherFor {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 1,68 @@
package dokkabuild.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.provider.MapProperty
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject

@CacheableTask
abstract class GenerateDokkaGradlePluginConstants @Inject constructor(
private val fs: FileSystemOperations
) : DefaultTask() {

@get:OutputDirectory
abstract val destinationDir: DirectoryProperty

@get:Input
abstract val properties: MapProperty<String, String>

init {
group = project.name
}

@TaskAction
fun action() {
val properties = properties.get()

// prepare temp dir
fs.delete { delete(temporaryDir) }

// generate file
val vals = properties.entries
.sortedBy { it.key }
.joinToString("\n") { (k, v) ->
"""const val $k = "$v""""
}.prependIndent(" ")

temporaryDir.resolve("DokkaConstants.kt").apply {
parentFile.mkdirs()
writeText(
"""
|/*
| * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
| */
|package org.jetbrains.dokka.gradle.internal
|
|@DokkaInternalApi
|object DokkaConstants {
|$vals
|}
|
""".trimMargin()
)
}

// sync file to output dir
fs.sync {
from(temporaryDir) {
into("org/jetbrains/dokka/gradle/internal/")
}
into(destinationDir)
}
}
}
70 changes: 69 additions & 1 deletion build-logic/src/main/kotlin/dokkabuild/utils/gradle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 4,18 @@

package dokkabuild.utils

import org.gradle.api.Action
import org.gradle.api.NamedDomainObjectProvider
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.attributes.*
import org.gradle.api.attributes.java.TargetJvmEnvironment
import org.gradle.api.component.AdhocComponentWithVariants
import org.gradle.api.model.ObjectFactory
import org.gradle.kotlin.dsl.named
import org.gradle.api.tasks.SourceSet
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.*


/**
Expand Down Expand Up @@ -87,3 94,64 @@ internal fun AttributeContainer.jvmJar(objects: ObjectFactory) {
attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named(TargetJvmEnvironment.STANDARD_JVM))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
}

/**
* Pretty-print the Java name.
*
* For Java 8 and below the version is prefixed with `1.`.
*/
fun JavaLanguageVersion.formattedName(): String =
if (asInt() <= 8) "1.${asInt()}" else asInt().toString()

/**
* Disable publishing of test fixtures (which causes warnings when publishing).
*
* https://docs.gradle.org/current/userguide/java_testing.html#publishing_test_fixtures
*/
fun Project.skipTestFixturesPublications() {
val javaComponent = components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
javaComponent.withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }
}

/**
* Exclude embedded Gradle dependencies from the given [SourceSet] configurations.
*
* The excluded dependencies are embedded into Gradle, they so should be excluded to prevent
* classpath ordering issues.
*/
// After extensive manual testing, it appears that these exclusions have no effect in dokka-gradle-plugin.
//
// DGP has no direct runtime dependencies on any of the conflicting dependencies, and Gradle has
// constraints that force the transitive dependencies to match the embedded versions.
// Unfortunately this means there is no way of testing if this config works, or can be safely removed.
// It was originally added because in previous versions DGP did have a direct dependency on
// kotlin-stdlib, but the buildscript has been re-written to correct this, meaning there are no
// longer conflicting dependencies.
//
// These exclusions have been kept due to an abundance of caution.
//
// See also:
// - https://youtrack.jetbrains.com/issue/KT-41142
// - https://github.com/JetBrains/kotlin/blob/2f41a05651e4709fcb6984bbac769af8e8f63935/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/SimpleKotlinGradleIT.kt#L180
// - https://github.com/Kotlin/dokka/pull/2570
fun Project.excludeGradleEmbeddedDependencies(sourceSet: NamedDomainObjectProvider<SourceSet>) {
val excludeAction = Action<Configuration> {
dependencies
.withType<ModuleDependency>()
.configureEach {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime")
}
}

sourceSet.configure {
configurations.named(implementationConfigurationName, excludeAction)
configurations.named(apiConfigurationName, excludeAction)
configurations.named(runtimeOnlyConfigurationName, excludeAction)
}
}
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 6,8 @@ plugins {
id("dokkabuild.base")
}

val publishedIncludedBuilds = listOf("runner-cli", "runner-gradle-plugin-classic", "runner-maven-plugin")
val gradlePluginIncludedBuilds = listOf("runner-gradle-plugin-classic")
val publishedIncludedBuilds = listOf("runner-cli", "dokka-gradle-plugin", "runner-maven-plugin")
val gradlePluginIncludedBuilds = listOf("dokka-gradle-plugin")

addDependencyOnSameTasksOfIncludedBuilds("assemble", "build", "clean", "check")

Expand All @@ -18,7 18,7 @@ registerParentGroupTasks(
"publishAllPublicationsToSnapshotRepository",
"publishAllPublicationsToSpaceDevRepository",
"publishAllPublicationsToSpaceTestRepository",
"publishToMavenLocal"
"publishToMavenLocal",
)
) {
it.name in publishedIncludedBuilds
Expand All @@ -27,7 27,7 @@ registerParentGroupTasks(
registerParentGroupTasks(
"gradle plugin", taskNames = listOf(
"publishPlugins",
"validatePlugins"
"validatePlugins",
)
) {
it.name in gradlePluginIncludedBuilds
Expand All @@ -37,15 37,15 @@ registerParentGroupTasks(
"bcv", taskNames = listOf(
"apiDump",
"apiCheck",
"apiBuild"
"apiBuild",
)
) {
it.name in publishedIncludedBuilds
}

registerParentGroupTasks(
"verification", taskNames = listOf(
"test"
"test",
)
)

Expand Down
2 changes: 1 addition & 1 deletion dokka-integration-tests/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 47,7 @@ dependencies {
devPublication("org.jetbrains.dokka:plugin-templating:$dokkaVersion")
devPublication("org.jetbrains.dokka:plugin-versioning:$dokkaVersion")

devPublication("org.jetbrains.dokka:runner-gradle-plugin-classic:$dokkaVersion")
devPublication("org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion")
}

kotlin {
Expand Down
2 changes: 1 addition & 1 deletion dokka-integration-tests/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 38,7 @@ dependencyResolutionManagement {
}
}

includeBuild("../dokka-runners/runner-gradle-plugin-classic")
includeBuild("../dokka-runners/dokka-gradle-plugin")
includeBuild("../dokka-runners/runner-maven-plugin")
includeBuild("../dokka-runners/runner-cli")
includeBuild("../.") // depend on the root project, so integration-tests can depend on projects in `dokka-subprojects/*`
Expand Down
Loading
Loading