aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main')
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/binaryCompatibility.kt29
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts22
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts12
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts75
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts13
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts29
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts30
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/publication.kt6
8 files changed, 185 insertions, 31 deletions
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/binaryCompatibility.kt b/buildSrc/src/main/kotlin/org/jetbrains/binaryCompatibility.kt
deleted file mode 100644
index 0b8386b6..00000000
--- a/buildSrc/src/main/kotlin/org/jetbrains/binaryCompatibility.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.jetbrains
-
-import kotlinx.validation.ApiValidationExtension
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.configure
-
-internal object BinaryCompatibilityConfig {
- val ignoredPublications = setOf("kotlinAnalysisIntelliJ", "kotlinAnalysis", "kotlinAnalysisCompiler")
- val ignoredSubprojects = setOf(
- "search-component",
- "compiler-dependency",
- "intellij-dependency",
- "kotlin-analysis",
- "frontend"
- )
-}
-
-internal fun Project.registerBinaryCompatibilityCheck(publicationName: String) {
- if (publicationName !in BinaryCompatibilityConfig.ignoredPublications) {
- if (tasks.findByName("apiBuild") == null) {
- plugins.apply(kotlinx.validation.BinaryCompatibilityValidatorPlugin::class.java)
- configure<ApiValidationExtension> {
- ignoredProjects.addAll(
- BinaryCompatibilityConfig.ignoredSubprojects.intersect(allprojects.map { it.name }.toSet())
- )
- }
- }
- }
-} \ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts b/buildSrc/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts
new file mode 100644
index 00000000..3addac74
--- /dev/null
+++ b/buildSrc/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts
@@ -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))
+ }
+}
+
+java {
+ withSourcesJar()
+}
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts b/buildSrc/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts
new file mode 100644
index 00000000..c4352d16
--- /dev/null
+++ b/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
+}
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts b/buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts
new file mode 100644
index 00000000..612502cd
--- /dev/null
+++ b/buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka-integration-test.gradle.kts
@@ -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)
+}
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts b/buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts
new file mode 100644
index 00000000..9a193cbb
--- /dev/null
+++ b/buildSrc/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts
@@ -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 })
+}
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts b/buildSrc/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts
new file mode 100644
index 00000000..bd33df22
--- /dev/null
+++ b/buildSrc/src/main/kotlin/org/jetbrains/conventions/kotlin-jvm.gradle.kts
@@ -0,0 +1,29 @@
+package org.jetbrains.conventions
+
+import org.jetbrains.configureDokkaVersion
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+plugins {
+ id("org.jetbrains.conventions.base")
+ id("org.jetbrains.conventions.base-java")
+ kotlin("jvm")
+}
+
+configureDokkaVersion()
+
+val language_version: String by project
+
+tasks.withType<KotlinCompile>().configureEach {
+ kotlinOptions {
+ 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
+ }
+}
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts b/buildSrc/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts
new file mode 100644
index 00000000..7007fd9e
--- /dev/null
+++ b/buildSrc/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts
@@ -0,0 +1,30 @@
+package org.jetbrains.conventions
+
+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)
+ }
+}
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/publication.kt b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
index eb45e255..60d91c33 100644
--- a/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
+++ b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
@@ -2,9 +2,13 @@ package org.jetbrains
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import org.gradle.api.Project
+import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
+import org.gradle.api.tasks.TaskContainer
+import org.gradle.api.tasks.TaskProvider
+import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.DokkaPublicationChannel.*
@@ -33,7 +37,6 @@ fun Project.registerDokkaArtifactPublication(publicationName: String, configure:
artifact(tasks["sourcesJar"])
}
}
- artifact(tasks["javadocJar"])
configurePom("Dokka ${project.name}")
}
}
@@ -42,7 +45,6 @@ fun Project.registerDokkaArtifactPublication(publicationName: String, configure:
configureSpacePublicationIfNecessary(publicationName)
configureSonatypePublicationIfNecessary(publicationName)
createDokkaPublishTaskIfNecessary()
- registerBinaryCompatibilityCheck(publicationName)
}
fun Project.configureSpacePublicationIfNecessary(vararg publications: String) {