aboutsummaryrefslogtreecommitdiff
path: root/build-logic/src/main/kotlin/org/jetbrains/conventions
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /build-logic/src/main/kotlin/org/jetbrains/conventions
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'build-logic/src/main/kotlin/org/jetbrains/conventions')
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts42
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/base-unit-test.gradle.kts43
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts30
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-html-frontend-files.gradle.kts35
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts81
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts17
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts13
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts58
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts104
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts72
10 files changed, 0 insertions, 495 deletions
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts
deleted file mode 100644
index 9270be47..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-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 {
- id("org.jetbrains.conventions.base")
- java
-}
-
-java {
- toolchain {
- languageVersion.set(dokkaBuild.mainJavaVersion)
- }
- withSourcesJar()
-}
-
-tasks.withType<Test>().configureEach {
- useJUnitPlatform()
-
- maxParallelForks = if (System.getenv("GITHUB_ACTIONS") != null) {
- Runtime.getRuntime().availableProcessors()
- } else {
- (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
- }
-
- javaLauncher.set(javaToolchains.launcherFor {
- languageVersion.set(dokkaBuild.testJavaLauncherVersion)
- })
-}
-
-dependencies {
- testImplementation(platform(libs.junit.bom))
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-unit-test.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/base-unit-test.gradle.kts
deleted file mode 100644
index 4911499d..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/base-unit-test.gradle.kts
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.conventions
-
-/**
- * Utility to run ynit tests for K1 and K2 (analysis API).
- */
-
-plugins {
- id("org.jetbrains.conventions.base")
- id("org.jetbrains.conventions.base-java")
-}
-
-val descriptorsTestConfiguration: Configuration by configurations.creating {
- extendsFrom(configurations.testImplementation.get())
-}
-val symbolsTestConfiguration: Configuration by configurations.creating {
- extendsFrom(configurations.testImplementation.get())
-}
-
-val symbolsTest = tasks.register<Test>("symbolsTest") {
- useJUnitPlatform {
- excludeTags("onlyDescriptors", "onlyDescriptorsMPP")
- }
- classpath += symbolsTestConfiguration
-}
-// run symbols and descriptors tests
-tasks.test {
- //enabled = false
- classpath += descriptorsTestConfiguration
- dependsOn(symbolsTest)
-}
-
-val descriptorsTest = tasks.register<Test>("descriptorsTest") {
- classpath += descriptorsTestConfiguration
-}
-
-tasks.check {
- dependsOn(symbolsTest)
-}
-
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts
deleted file mode 100644
index b485520a..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.conventions
-
-import org.jetbrains.DokkaBuildProperties
-
-/**
- * A convention plugin that sets up common config and sensible defaults for all subprojects.
- *
- * It provides the [DokkaBuildProperties] extension, for accessing common build properties.
- */
-
-plugins {
- base
-}
-
-val dokkaBuildProperties: DokkaBuildProperties = extensions.create(DokkaBuildProperties.EXTENSION_NAME)
-
-if (project != rootProject) {
- project.group = rootProject.group
- project.version = rootProject.version
-}
-
-tasks.withType<AbstractArchiveTask>().configureEach {
- // https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
- isPreserveFileTimestamps = false
- isReproducibleFileOrder = true
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-html-frontend-files.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-html-frontend-files.gradle.kts
deleted file mode 100644
index 198194b1..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-html-frontend-files.gradle.kts
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.conventions
-
-import org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE
-
-/**
- * Utility for sharing the Dokka HTML frontend files between subprojects in a safe, cacheable way.
- */
-
-plugins {
- id("org.jetbrains.conventions.base")
-}
-
-/** Apply a distinct attribute to the incoming/outgoing configuration */
-fun AttributeContainer.dokkaHtmlFrontendFilesAttribute() =
- attribute(USAGE_ATTRIBUTE, objects.named("org.jetbrains.dokka.html-frontend-files"))
-
-// incoming configuration
-val dokkaHtmlFrontendFiles by configurations.registering {
- description = "Retrieve Dokka HTML frontend files from other subprojects"
- isCanBeConsumed = false
- isCanBeResolved = true
- attributes { dokkaHtmlFrontendFilesAttribute() }
-}
-
-// outgoing configuration
-val dokkaHtmlFrontendFilesElements by configurations.registering {
- description = "Provide Dokka HTML frontend files to other subprojects"
- isCanBeConsumed = true
- isCanBeResolved = false
- attributes { dokkaHtmlFrontendFilesAttribute() }
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts
deleted file mode 100644
index 75e27a62..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-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: SourceSet = sourceSets.create("integrationTest") {
- compileClasspath += sourceSets.main.get().output
- runtimeClasspath += sourceSets.main.get().output
-}
-
-val integrationTestImplementation: Configuration by configurations.getting {
- extendsFrom(configurations.implementation.get())
-}
-
-val integrationTestRuntimeOnly: Configuration 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"
- testClassesDirs = integrationTestSourceSet.output.classesDirs
- classpath = integrationTestSourceSet.runtimeClasspath
-
- useJUnitPlatform()
-
- 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)
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts
deleted file mode 100644
index 5abd8575..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-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"))
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts
deleted file mode 100644
index fb2ca119..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/gradle-plugin.gradle.kts
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.conventions
-
-plugins {
- id("org.gradle.kotlin.kotlin-dsl")
- id("org.jetbrains.conventions.maven-publish")
- id("com.gradle.plugin-publish")
- id("org.jetbrains.conventions.base-java")
- kotlin("jvm")
-}
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
deleted file mode 100644
index d2425ce3..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.conventions
-
-import org.jetbrains.configureDokkaVersion
-import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
-plugins {
- id("org.jetbrains.conventions.base-java")
- kotlin("jvm")
-}
-
-configureDokkaVersion()
-
-kotlin {
- explicitApi = ExplicitApiMode.Strict
-
- 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",
- )
- )
- }
-}
-
-val projectsWithoutInternalDokkaApiUsage = setOf(
- ":integration-tests",
- ":integration-tests:gradle",
- ":integration-tests:maven",
- ":integration-tests:cli"
-)
-
-tasks.withType<KotlinCompile>().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",
- )
- )
- }
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts
deleted file mode 100644
index f07ff98d..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.conventions
-
-import org.gradle.kotlin.dsl.support.serviceOf
-
-/**
- * Utility for downloading and installing a Maven binary.
- *
- * Provides the `setupMavenProperties` extension that contains the default versions and locations
- * of the Maven binary.
- *
- * The task [installMavenBinary] will download and unzip the Maven bianry.
- */
-
-plugins {
- base
-}
-
-abstract class MavenCliSetupExtension {
- abstract val mavenVersion: Property<String>
- abstract val mavenPluginToolsVersion: Property<String>
-
- /** Directory that will contain the unpacked Apache Maven dependency */
- abstract val mavenInstallDir: DirectoryProperty
-
- /**
- * Path to the Maven executable.
- *
- * This should be different per OS:
- *
- * * Windows: `$mavenInstallDir/bin/mvn.cmd`
- * * Unix: `$mavenInstallDir/bin/mvn`
- */
- abstract val mvn: RegularFileProperty
-}
-
-val mavenCliSetupExtension =
- extensions.create("mavenCliSetup", MavenCliSetupExtension::class).apply {
- mavenVersion.convention(libs.versions.apacheMaven.core)
- mavenPluginToolsVersion.convention(libs.versions.apacheMaven.pluginTools)
-
- mavenInstallDir.convention(layout.buildDirectory.dir("apache-maven"))
-
- val isWindowsProvider =
- providers.systemProperty("os.name").map { "win" in it.toLowerCase() }
-
- mvn.convention(
- providers.zip(mavenInstallDir, isWindowsProvider) { mavenInstallDir, isWindows ->
- mavenInstallDir.file(
- when {
- isWindows -> "bin/mvn.cmd"
- else -> "bin/mvn"
- }
- )
- }
- )
- }
-
-val mavenBinary by configurations.registering {
- description = "used to download the Maven binary"
- isCanBeResolved = true
- isCanBeConsumed = false
- isVisible = false
-
- defaultDependencies {
- addLater(mavenCliSetupExtension.mavenVersion.map { mavenVersion ->
- project.dependencies.create(
- group = "org.apache.maven",
- name = "apache-maven",
- version = mavenVersion,
- classifier = "bin",
- ext = "zip"
- )
- })
- }
-}
-
-tasks.clean {
- delete(mavenCliSetupExtension.mavenInstallDir)
-}
-
-val installMavenBinary by tasks.registering(Sync::class) {
- val archives = serviceOf<ArchiveOperations>()
- from(
- mavenBinary.flatMap { conf ->
- @Suppress("UnstableApiUsage")
- val resolvedArtifacts = conf.incoming.artifacts.resolvedArtifacts
-
- resolvedArtifacts.map { artifacts ->
- artifacts.map { archives.zipTree(it.file) }
- }
- }
- ) {
- eachFile {
- // drop the first directory inside the zipped Maven bin (apache-maven-$version)
- relativePath = RelativePath(true, *relativePath.segments.drop(1).toTypedArray())
- }
- includeEmptyDirs = false
- }
- into(mavenCliSetupExtension.mavenInstallDir)
-}
diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts
deleted file mode 100644
index a5ab6b91..00000000
--- a/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package org.jetbrains.conventions
-
-import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
-
-plugins {
- id("org.jetbrains.conventions.base")
- `maven-publish`
- signing
- id("org.jetbrains.conventions.dokka")
-}
-
-val javadocJar by tasks.registering(Jar::class) {
- group = JavaBasePlugin.DOCUMENTATION_GROUP
- description = "Assembles a Javadoc JAR using Dokka HTML"
- archiveClassifier.set("javadoc")
- from(tasks.dokkaHtml)
-}
-
-publishing {
- repositories {
- // Publish to a project-local Maven directory, for verification. To test, run:
- // ./gradlew publishAllPublicationsToMavenProjectLocalRepository
- // and check $rootDir/build/maven-project-local
- maven(rootProject.layout.buildDirectory.dir("maven-project-local")) {
- name = "MavenProjectLocal"
- }
- }
-
- publications.withType<MavenPublication>().configureEach {
- artifact(javadocJar)
-
- pom {
- name.convention(provider { "Dokka ${project.name}" })
- description.convention("Dokka is an API documentation engine for Kotlin and Java, performing the same function as Javadoc for Java")
- url.convention("https://github.com/Kotlin/dokka")
-
- licenses {
- license {
- name.convention("The Apache Software License, Version 2.0")
- url.convention("https://www.apache.org/licenses/LICENSE-2.0.txt")
- distribution.convention("repo")
- }
- }
-
- developers {
- developer {
- id.convention("JetBrains")
- name.convention("JetBrains Team")
- organization.convention("JetBrains")
- organizationUrl.convention("https://www.jetbrains.com")
- }
- }
-
- scm {
- connection.convention("scm:git:git://github.com/Kotlin/dokka.git")
- url.convention("https://github.com/Kotlin/dokka/tree/master")
- }
- }
- }
-}
-
-plugins.withType<ShadowPlugin>().configureEach {
- // manually disable publication of Shadow elements https://github.com/johnrengelman/shadow/issues/651#issue-839148311
- // This is done to preserve compatibility and have the same behaviour as previous versions of Dokka.
- // For more details, see https://github.com/Kotlin/dokka/pull/2704#issuecomment-1499517930
- val javaComponent = components["java"] as AdhocComponentWithVariants
- javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() }
-}