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

build config: Use buildSrc convention plugins to configure the Dokka subprojects #2704

Merged
merged 65 commits into from Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3f77497
try setting up buildSrc convention plugins
aSemy Oct 11, 2022
b591e34
finish creating buildSrc plugins
aSemy Oct 13, 2022
16657a2
Merge remote-tracking branch 'origin/master' into feat/buildsrc_conve…
aSemy Oct 13, 2022
a8abe34
create MavenProjectLocal helper
aSemy Oct 13, 2022
2dd31cf
dokka-gradle-plugin: warn on duplicate resources
aSemy Oct 13, 2022
58bc1c8
dokka-gradle-plugin: fix kotlin-dsl compatibility
aSemy Oct 13, 2022
89a504f
disable empty subproject :plugins:base:search-component
aSemy Oct 13, 2022
7a1a430
formatting
aSemy Oct 13, 2022
968a123
re-add dependencies that were in :dokka:plugins subproject {} block
aSemy Oct 13, 2022
63a7da4
re-add project(":integration-tests") dependency to integration-tests …
aSemy Oct 13, 2022
766af55
fix dokka-integration-test integrationTest configurations
aSemy Oct 13, 2022
770a27b
replace println with logger.lifecycle
aSemy Oct 18, 2022
ae0f4e1
update description for base plugin (else it provides a default descri…
aSemy Oct 18, 2022
bba37c7
rm commented out code
aSemy Oct 18, 2022
549c11c
update test code after applying kotlin-dsl plugin
aSemy Oct 18, 2022
9bfedff
tidy up gradle-plugin build.gradle.kts
aSemy Oct 18, 2022
54e68e3
add repositoriesMode
aSemy Oct 18, 2022
a1cfab1
move repositories to settings.gradle.kts
aSemy Oct 18, 2022
d2e05d0
Declare the Node.js & Yarn download repositories
aSemy Oct 18, 2022
572494c
[gradle plugin] revert applying kotlin-dsl plugin, do that in #2702
aSemy Oct 18, 2022
ae95fed
Merge branch 'master' into feat/buildsrc_convention_plugins
aSemy Jan 9, 2023
616a093
Merge remote-tracking branch 'origin/master' into feat/buildsrc_conve…
aSemy Jan 28, 2023
2c25467
simplify binary-compatibility-validator plugin config
aSemy Jan 29, 2023
452f141
update binary compatibility plugin version
aSemy Jan 29, 2023
8693c58
rm ./runners/build.gradle.kts
aSemy Jan 29, 2023
c40cd18
tidy up Maven runner build config
aSemy Jan 29, 2023
4510cb9
Merge remote-tracking branch 'origin/master' into feat/buildsrc_conve…
aSemy Feb 1, 2023
34d21e8
move 'pluginManagement' up a level
aSemy Feb 1, 2023
88b7cc3
ignoredProjects: use += instead of addAll
aSemy Feb 1, 2023
ebb3e3d
add link to explain the Node/Yarn repos
aSemy Feb 1, 2023
de9eff1
formatting
aSemy Feb 1, 2023
1711af3
update javadocJar task
aSemy Feb 1, 2023
75764f6
Merge remote-tracking branch 'origin/master' into feat/buildsrc_conve…
aSemy Feb 22, 2023
0264c73
remove NonCacheableIntegrationTest - moved to buildSrc convention
aSemy Feb 22, 2023
4d8649d
update Kotlin version
aSemy Feb 22, 2023
712d79f
update TODO
aSemy Feb 22, 2023
68895d0
add gradle-plugin api dump
aSemy Feb 23, 2023
33cb1d7
add api-dump project paths
aSemy Feb 23, 2023
05c284e
move respositories specific only to :kotlin-analysis:intellij-dependency
aSemy Feb 23, 2023
932b343
add NonCacheableIntegrationTest back (it was lost during a merge?)
aSemy Feb 23, 2023
a367a26
remove javadocJar task from gradle-plugin (it was moved to the conven…
aSemy Feb 23, 2023
1949bda
fix javadocJar in gradle-plugin
aSemy Feb 23, 2023
e2a8edd
restore gradle-plugin/gradle.properties
aSemy Feb 23, 2023
6603d55
tidy up javadoc/maven-publish build config
aSemy Feb 23, 2023
e488262
restrict the node/yarn repos to only supply node/yarn
aSemy Feb 23, 2023
de1250a
update repositoriesMode PREFER_SETTINGS & comment
aSemy Feb 23, 2023
4ed2fc0
update link to faq
aSemy Feb 23, 2023
7a25d7f
fix double javadoc jar artifact
aSemy Feb 23, 2023
e301770
fix tasks.register -> tasks.registering
aSemy Feb 23, 2023
d516114
rm old shadow plugin dependency
aSemy Feb 23, 2023
f348661
replace star import with explicit import
aSemy Feb 24, 2023
6801a77
restore Dokka version to 1.7.20
aSemy Feb 28, 2023
0b6a9db
move common Java config into a new convention plugin, and apply it in…
aSemy Feb 28, 2023
7c49e09
tidy up compiler args
aSemy Feb 28, 2023
27c639c
restore suppress-version-warnings
aSemy Feb 28, 2023
bccbdd7
Merge remote-tracking branch 'origin/master' into feat/buildsrc_conve…
aSemy Feb 28, 2023
7212695
remove unused import
aSemy Feb 28, 2023
f1dcf92
update API dump
aSemy Feb 28, 2023
8fb0319
remove unnecessary MavenPublishPlugin check
aSemy Mar 1, 2023
4024f36
centralise repos in buildSrc
aSemy Mar 7, 2023
ff45720
set jvmToolchain in buildSrc
aSemy Mar 7, 2023
2e78b7b
Merge branch 'master' into feat/buildsrc_convention_plugins
aSemy Mar 7, 2023
1bbbd9b
set test Java Launcher toolchain to 11
aSemy Mar 7, 2023
d06036f
rm unnecessary task (clean already deletes buildDir contents)
aSemy Mar 7, 2023
ac58931
change java-version from 12 to 11 in snapshot workflows
aSemy Mar 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/gh-actions-artifacts-snapshots.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 12
java-version: 11
cache: 'maven'
- name: Document coroutines
uses: gradle/gradle-build-action@v2
Expand All @@ -44,7 +44,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 12
java-version: 11
cache: 'maven'
- name: Document serialization
uses: gradle/gradle-build-action@v2
Expand All @@ -70,7 +70,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 12
java-version: 11
cache: 'maven'
- name: Document biojava-core
uses: gradle/gradle-build-action@v2
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/s3-snapshots.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 12
java-version: 11
cache: 'maven'
- name: Document coroutines
uses: gradle/gradle-build-action@v2
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 12
java-version: 11
cache: 'maven'
- name: Document serialization
uses: gradle/gradle-build-action@v2
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 12
java-version: 11
cache: 'maven'
- name: Document biojava-core
uses: gradle/gradle-build-action@v2
Expand Down
95 changes: 30 additions & 65 deletions build.gradle.kts
@@ -1,76 +1,21 @@
import org.jetbrains.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.ValidatePublications
import org.jetbrains.publicationChannels

plugins {
kotlin("jvm") apply false
id("java")
id("org.jetbrains.dokka") version "1.8.10"
org.jetbrains.conventions.base
id("org.jetbrains.dokka")
id("io.github.gradle-nexus.publish-plugin")
}

val dokka_version: String by project

allprojects {
configureDokkaVersion()

group = "org.jetbrains.dokka"
version = dokka_version


val language_version: String by project
tasks.withType(KotlinCompile::class).all {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
"-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"
)
allWarningsAsErrors = true
languageVersion = language_version
apiVersion = language_version
jvmTarget = "1.8"
}
}

repositories {
mavenCentral()
}
id("org.jetbrains.kotlinx.binary-compatibility-validator")
}

subprojects {
apply {
plugin("org.jetbrains.kotlin.jvm")
plugin("java")
plugin("signing")
plugin("org.jetbrains.dokka")
}

// Gradle metadata
java {
@Suppress("UnstableApiUsage")
withSourcesJar()
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks {
val dokkaOutputDir = "$buildDir/dokka"
val dokka_version: String by project

dokkaHtml {
onlyIf { !isLocalPublication }
outputDirectory.set(file(dokkaOutputDir))
}
group = "org.jetbrains.dokka"
version = dokka_version

register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
dependsOn(dokkaHtml)
from(dokkaOutputDir)
}
}
}

println("Publication version: $dokka_version")
logger.lifecycle("Publication version: $dokka_version")
tasks.register<ValidatePublications>("validatePublications")

nexusPublishing {
Expand All @@ -82,8 +27,28 @@ nexusPublishing {
}
}

tasks.maybeCreate("dokkaPublish").run {
val dokkaPublish by tasks.registering {
if (publicationChannels.any { it.isMavenRepository() }) {
finalizedBy(tasks.named("closeAndReleaseSonatypeStagingRepository"))
}
}

apiValidation {
// note that subprojects are ignored by their name, not their path https://github.com/Kotlin/binary-compatibility-validator/issues/16
ignoredProjects += setOf(
// NAME PATH
"search-component", // :plugins:search-component
"frontend", // :plugins:base:frontend

"kotlin-analysis", // :kotlin-analysis
"compiler-dependency", // :kotlin-analysis:compiler-dependency
"intellij-dependency", // :kotlin-analysis:intellij-dependency

"integration-tests", // :integration-tests
"gradle", // :integration-tests:gradle
"cli", // :integration-tests:cli
"maven", // integration-tests:maven

"test-utils", // :test-utils
)
}
27 changes: 23 additions & 4 deletions buildSrc/build.gradle.kts
@@ -1,13 +1,32 @@
import java.util.*
aSemy marked this conversation as resolved.
Show resolved Hide resolved

plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}

// TODO define versions in Gradle Version Catalog https://github.com/Kotlin/dokka/pull/2884
val properties = file("../gradle.properties").inputStream().use {
Properties().apply { load(it) }
}

val kotlinVersion = properties["kotlin_version"]

dependencies {
implementation("com.github.jengelman.gradle.plugins:shadow:2.0.4")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.10.1")
// Import Gradle Plugins that will be used in the buildSrc pre-compiled script plugins, and any `build.gradle.kts`
// files in the project.
// Use their Maven coordinates (plus versions), not Gradle plugin IDs!
// This should be the only place that Gradle plugin versions are defined, so they are aligned across all build scripts

implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.12.1")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.12.1")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.13.0")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not opposed to bumping this, but I want to try and limit this PR as much as possible. I think it would be better to update in a separate PR.

implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.10")
implementation("com.gradle.publish:plugin-publish-plugin:0.20.0")
}
17 changes: 17 additions & 0 deletions buildSrc/settings.gradle.kts
@@ -0,0 +1,17 @@
rootProject.name = "buildSrc"

pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
}
29 changes: 0 additions & 29 deletions buildSrc/src/main/kotlin/org/jetbrains/binaryCompatibility.kt

This file was deleted.

@@ -0,0 +1,22 @@
package org.jetbrains.conventions

/**
* Base configuration for Java projects.
*
* This convention plugin contains shared Java config for both the [KotlinJvmPlugin] convention plugin and
* the Gradle Plugin subproject (which cannot have the `kotlin("jvm")` plugin applied).
*/

plugins {
`java`
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
Comment on lines +14 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we apply toolchain for all modules, they'll run tests on Java 8 instead of the JDK matrix on CI, we need to apply more toolchains in Test which will slow down the build, I believe we should not use toolchain for now. Check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Toolchains can still help with this though, because it's possible to set them per-task. I did something similar for MockK - I'll put together a PR.

Copy link
Contributor

@Goooler Goooler Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, yes that would be slower. I agree, using GitHub parallel workflows is best, not multiple Gradle tasks.


java {
withSourcesJar()
}
12 changes: 12 additions & 0 deletions buildSrc/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts
@@ -0,0 +1,12 @@
package org.jetbrains.conventions

plugins {
base
}

// common Gradle configuration that should be applied to all projects

if (project != rootProject) {
project.group = rootProject.group
project.version = rootProject.version
}
aSemy marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1,75 @@
package org.jetbrains.conventions

import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
id("org.jetbrains.conventions.kotlin-jvm")
}

val integrationTestSourceSet = sourceSets.create("integrationTest") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}

val integrationTestImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}

val integrationTestRuntimeOnly by configurations.getting {
extendsFrom(configurations.runtimeOnly.get())
}

/**
* Dokka's integration test task is not cacheable because the HTML outputs
* it produces when running the tests are used for showcasing resulting documentation,
* which does not work well with caching.
*
* At the moment there are two problems that do not allow to make it cacheable:
*
* 1. The task's inputs are such that changes in Dokka's code do not invalidate the cache,
* because it is run with the same version of Dokka (`"DOKKA_VERSION"`) on the same
* test project inputs.
* 2. The tests generate HTML output which is then used to showcase documentation.
* The outputs are usually copied to a location from which it will be served.
* However, if the test is cacheable, it produces no outputs, so no documentation
* to showcase. It needs to be broken into two separate tasks: one cacheable for running
* the tests and producing HTML output, and another non-cacheable for copying the output.
*
* @see [org.jetbrains.dokka.it.TestOutputCopier] for more details on showcasing documentation
*/
@DisableCachingByDefault(because = "Contains incorrect inputs/outputs configuration, see the KDoc for details")
abstract class NonCacheableIntegrationTest : Test()

val integrationTest by tasks.registering(NonCacheableIntegrationTest::class) {
maxHeapSize = "2G"
description = "Runs integration tests."
group = "verification"
useJUnit()

testClassesDirs = integrationTestSourceSet.output.classesDirs
classpath = integrationTestSourceSet.runtimeClasspath

setForkEvery(1)
project.properties["dokka_integration_test_parallelism"]?.toString()?.toIntOrNull()?.let { parallelism ->
maxParallelForks = parallelism
}
environment(
"isExhaustive",
project.properties["dokka_integration_test_is_exhaustive"]?.toString()?.toBoolean()
?: System.getenv("DOKKA_INTEGRATION_TEST_IS_EXHAUSTIVE")?.toBoolean()
?: false.toString()
)

testLogging {
exceptionFormat = TestExceptionFormat.FULL
events(TestLogEvent.SKIPPED, TestLogEvent.FAILED)
showExceptions = true
showCauses = true
showStackTraces = true
}
}

tasks.check {
dependsOn(integrationTest)
}
@@ -0,0 +1,13 @@
package org.jetbrains.conventions

import org.gradle.kotlin.dsl.invoke
import org.jetbrains.isLocalPublication

plugins {
id("org.jetbrains.dokka")
}

tasks.dokkaHtml {
onlyIf { !isLocalPublication }
outputDirectory.set(layout.buildDirectory.dir("dokka").map { it.asFile })
}