diff --git a/build-logic/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt b/build-logic/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt deleted file mode 100644 index 349813021a..0000000000 --- a/build-logic/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -@file:Suppress("LocalVariableName") - -package org.jetbrains - -import org.gradle.api.Project - -enum class DokkaPublicationChannel { - SPACE_DOKKA_DEV, - MAVEN_CENTRAL, - MAVEN_CENTRAL_SNAPSHOT, - GRADLE_PLUGIN_PORTAL; - - val acceptedDokkaVersionTypes: List - get() = when(this) { - MAVEN_CENTRAL -> listOf(DokkaVersionType.RELEASE, DokkaVersionType.RC) - MAVEN_CENTRAL_SNAPSHOT -> listOf(DokkaVersionType.SNAPSHOT) - SPACE_DOKKA_DEV -> listOf(DokkaVersionType.RELEASE, DokkaVersionType.RC, DokkaVersionType.DEV, DokkaVersionType.SNAPSHOT) - GRADLE_PLUGIN_PORTAL -> listOf(DokkaVersionType.RELEASE, DokkaVersionType.RC) - } - - fun isSpaceRepository() = this == SPACE_DOKKA_DEV - - fun isMavenRepository() = this == MAVEN_CENTRAL || this == MAVEN_CENTRAL_SNAPSHOT - - fun isGradlePluginPortal() = this == GRADLE_PLUGIN_PORTAL - - companion object { - fun fromPropertyString(value: String): DokkaPublicationChannel = when (value) { - "space-dokka-dev" -> SPACE_DOKKA_DEV - "maven-central-release" -> MAVEN_CENTRAL - "maven-central-snapshot" -> MAVEN_CENTRAL_SNAPSHOT - "gradle-plugin-portal" -> GRADLE_PLUGIN_PORTAL - else -> throw IllegalArgumentException("Unknown dokka_publication_channel=$value") - } - } -} - -val Project.publicationChannels: Set - get() { - val publicationChannel = this.properties["dokka_publication_channel"]?.toString() - val publicationChannels = this.properties["dokka_publication_channels"]?.toString() - if (publicationChannel != null && publicationChannels != null) { - throw IllegalArgumentException( - "Only one of dokka_publication_channel and dokka_publication_channel*s* can be set. Found: \n" + - "dokka_publication_channel=$publicationChannel\n" + - "dokka_publication_channels=$publicationChannels" - ) - } - - if (publicationChannel != null) { - return setOf(DokkaPublicationChannel.fromPropertyString(publicationChannel)) - } - - if (publicationChannels != null) { - return publicationChannels.split("&").map { channel -> - DokkaPublicationChannel.fromPropertyString(channel) - }.toSet() - } - - return emptySet() - } - diff --git a/build-logic/src/main/kotlin/org/jetbrains/DokkaVersion.kt b/build-logic/src/main/kotlin/org/jetbrains/DokkaVersion.kt index 9028e8cf0c..cd715ecf84 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/DokkaVersion.kt +++ b/build-logic/src/main/kotlin/org/jetbrains/DokkaVersion.kt @@ -17,7 +17,3 @@ fun Project.configureDokkaVersion(): String { val Project.dokkaVersion: String get() = configureDokkaVersion() -val Project.dokkaVersionType: DokkaVersionType? - get() = DokkaVersionType.values().find { - it.suffix.matches(dokkaVersion.substringAfter("-", "")) - } diff --git a/build-logic/src/main/kotlin/org/jetbrains/DokkaVersionType.kt b/build-logic/src/main/kotlin/org/jetbrains/DokkaVersionType.kt deleted file mode 100644 index 7ceb595bdd..0000000000 --- a/build-logic/src/main/kotlin/org/jetbrains/DokkaVersionType.kt +++ /dev/null @@ -1,12 +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 - -enum class DokkaVersionType(val suffix: Regex) { - RELEASE("^$".toRegex()), - RC("RC\\d?".toRegex()), - SNAPSHOT("SNAPSHOT".toRegex()), - DEV("dev-\\d+".toRegex()); -} diff --git a/build-logic/src/main/kotlin/org/jetbrains/ValidatePublications.kt b/build-logic/src/main/kotlin/org/jetbrains/ValidatePublications.kt deleted file mode 100644 index 293ae96bd2..0000000000 --- a/build-logic/src/main/kotlin/org/jetbrains/ValidatePublications.kt +++ /dev/null @@ -1,49 +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 - -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.Project -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.TaskAction -import org.gradle.kotlin.dsl.findByType - -open class ValidatePublications : DefaultTask() { - - init { - group = "verification" - project.tasks.named("check") { - dependsOn(this@ValidatePublications) - } - } - - @TaskAction - fun validatePublicationConfiguration() { - project.subprojects.forEach { subProject -> - val publishing = subProject.extensions.findByType() ?: return@forEach - publishing.publications - .filterIsInstance() - .filter { it.version == project.dokkaVersion } - .forEach { _ -> - subProject.assertPublicationVersion() - } - } - } - - private fun Project.assertPublicationVersion() { - val versionTypeMatchesPublicationChannels = publicationChannels.all { publicationChannel -> - publicationChannel.acceptedDokkaVersionTypes.any { acceptedVersionType -> - acceptedVersionType == dokkaVersionType - } - } - if (!versionTypeMatchesPublicationChannels) { - throw AssertionError("Wrong version $dokkaVersion for configured publication channels $publicationChannels") - } - } -} 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 index 5abd85750d..25be4ff704 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/dokka.gradle.kts @@ -5,13 +5,11 @@ 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/maven-publish.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-publish.gradle.kts index a5ab6b9112..7dac4e803d 100644 --- 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 @@ -10,57 +10,6 @@ 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().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().configureEach { diff --git a/build-logic/src/main/kotlin/org/jetbrains/publication.kt b/build-logic/src/main/kotlin/org/jetbrains/publication.kt index 2a6b7a617d..8612cda104 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/publication.kt +++ b/build-logic/src/main/kotlin/org/jetbrains/publication.kt @@ -8,11 +8,10 @@ import com.github.jengelman.gradle.plugins.shadow.ShadowExtension import org.gradle.api.Project import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.publish.maven.tasks.PublishToMavenRepository -import org.gradle.kotlin.dsl.* -import org.gradle.plugins.signing.SigningExtension -import org.jetbrains.DokkaPublicationChannel.* -import java.net.URI +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.register class DokkaPublicationBuilder { enum class Component { @@ -43,83 +42,4 @@ fun Project.registerDokkaArtifactPublication( } } } - - configureSpacePublicationIfNecessary(publicationName) - configureSonatypePublicationIfNecessary(publicationName) - createDokkaPublishTaskIfNecessary() -} - -fun Project.configureSpacePublicationIfNecessary(vararg publications: String) { - if (SPACE_DOKKA_DEV in this.publicationChannels) { - configure { - repositories { - /* already registered */ - findByName(SPACE_DOKKA_DEV.name)?.let { return@repositories } - maven { - name = SPACE_DOKKA_DEV.name - url = URI.create("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") - credentials { - username = System.getenv("SPACE_PACKAGES_USER") - password = System.getenv("SPACE_PACKAGES_SECRET") - } - } - } - } - } - - whenEvaluated { - tasks.withType { - if (this.repository.name == SPACE_DOKKA_DEV.name) { - this.isEnabled = this.isEnabled && publication.name in publications - if (!this.isEnabled) { - this.group = "disabled" - } - } - } - } -} - -fun Project.createDokkaPublishTaskIfNecessary() { - tasks.maybeCreate("dokkaPublish").run { - if (publicationChannels.any { it.isSpaceRepository() }) { - dependsOn(tasks.named("publish")) - } - - if (publicationChannels.any { it.isMavenRepository() }) { - dependsOn(tasks.named("publishToSonatype")) - } - - if (publicationChannels.any { it.isGradlePluginPortal() }) { - dependsOn(tasks.named("publishPlugins")) - } - } -} - -fun Project.configureSonatypePublicationIfNecessary(vararg publications: String) { - if (publicationChannels.any { it.isMavenRepository() }) { - signPublicationsIfKeyPresent(*publications) - } -} - -@Suppress("UnstableApiUsage") -private fun Project.signPublicationsIfKeyPresent(vararg publications: String) { - val signingKeyId: String? = System.getenv("SIGN_KEY_ID") - val signingKey: String? = System.getenv("SIGN_KEY") - val signingKeyPassphrase: String? = System.getenv("SIGN_KEY_PASSPHRASE") - - if (!signingKey.isNullOrBlank()) { - extensions.configure("signing") { - if (signingKeyId?.isNotBlank() == true) { - useInMemoryPgpKeys(signingKeyId, signingKey, signingKeyPassphrase) - } else { - useInMemoryPgpKeys(signingKey, signingKeyPassphrase) - } - publications.forEach { publicationName -> - extensions.getByType() - .publications - .findByName(publicationName) - ?.let { sign(it) } - } - } - } } diff --git a/build-logic/src/main/kotlin/org/jetbrains/taskUtils.kt b/build-logic/src/main/kotlin/org/jetbrains/taskUtils.kt deleted file mode 100644 index b492d9a96e..0000000000 --- a/build-logic/src/main/kotlin/org/jetbrains/taskUtils.kt +++ /dev/null @@ -1,26 +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 - -import org.gradle.api.Project -import org.gradle.api.Task - -fun Task.dependsOnMavenLocalPublication() { - project.rootProject.allprojects.forEach { otherProject -> - otherProject.invokeWhenEvaluated { evaluatedProject -> - evaluatedProject.tasks.findByName("publishToMavenLocal")?.let { publishingTask -> - this.dependsOn(publishingTask) - } - } - } -} - -val Project.isLocalPublication: Boolean - get() = gradle.startParameter.taskNames.any { - it.endsWith("publishToMavenLocal", ignoreCase = true) || - it.endsWith("integrationTest", ignoreCase = true) || - it.endsWith("check", ignoreCase = true) || - it.endsWith("test", ignoreCase = true) - } diff --git a/build.gradle.kts b/build.gradle.kts index c4d6e13556..8256e40b6e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,17 +2,10 @@ * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.ValidatePublications -import org.jetbrains.publicationChannels - @Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 https://github.com/gradle/gradle/pull/23639 plugins { id("org.jetbrains.conventions.base") id("org.jetbrains.conventions.dokka") - -// TODO [structure-refactoring] enable -// alias(libs.plugins.kotlinx.binaryCompatibilityValidator) - alias(libs.plugins.nexusPublish) } val dokka_version: String by project @@ -20,25 +13,6 @@ val dokka_version: String by project group = "org.jetbrains.dokka" version = dokka_version - -logger.lifecycle("Publication version: $dokka_version") -tasks.register("validatePublications") - -nexusPublishing { - repositories { - sonatype { - username.set(System.getenv("SONATYPE_USER")) - password.set(System.getenv("SONATYPE_PASSWORD")) - } - } -} - -val dokkaPublish by tasks.registering { - if (publicationChannels.any { it.isMavenRepository() }) { - finalizedBy(tasks.named("closeAndReleaseSonatypeStagingRepository")) - } -} - addDependencyOnSameTaskOfIncludedBuilds("assemble") addDependencyOnSameTaskOfIncludedBuilds("build") addDependencyOnSameTaskOfIncludedBuilds("clean") @@ -59,16 +33,3 @@ fun registerParentTaskOfIncludedBuilds(taskName: String, groupName: String) { dependsOn(gradle.includedBuilds.map { it.task(":$taskName") }) } } - -//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 -// "frontend", // :plugins:base:frontend -// -// "integration-tests", // :integration-tests -// "gradle", // :integration-tests:gradle -// "cli", // :integration-tests:cli -// "maven", // integration-tests:maven -// ) -//} diff --git a/docs-developer/build.gradle.kts b/docs-developer/build.gradle.kts index 1d3bd687a3..aa86bca4f4 100644 --- a/docs-developer/build.gradle.kts +++ b/docs-developer/build.gradle.kts @@ -9,11 +9,12 @@ plugins { id("ru.vyarus.mkdocs") version "2.4.0" } -if (dokkaVersionType != DokkaVersionType.RELEASE) { +// TODO [structure-refactoring] check that it's not snapshot, no suffix +//if (dokkaVersionType != DokkaVersionType.RELEASE) { // Do not generate the root index.html file with the redirect // to a non-release version, otherwise GitHub pages based documentation // will always lead to the non-stable documentation. // For more details, see https://github.com/Kotlin/dokka/issues/2869. // For configuration details, see https://xvik.github.io/gradle-mkdocs-plugin/3.0.0/examples/#simple-multi-version. mkdocs.publish.rootRedirect = false -} +//} diff --git a/dokka-integration-tests/gradle/build.gradle.kts b/dokka-integration-tests/gradle/build.gradle.kts index ad4b93f494..d2d82d50cf 100644 --- a/dokka-integration-tests/gradle/build.gradle.kts +++ b/dokka-integration-tests/gradle/build.gradle.kts @@ -2,7 +2,6 @@ * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.dependsOnMavenLocalPublication plugins { id("org.jetbrains.conventions.dokka-integration-test") @@ -24,7 +23,6 @@ tasks.integrationTest { val dokka_version: String by project environment("DOKKA_VERSION", dokka_version) inputs.dir(file("projects")) - dependsOnMavenLocalPublication() javaLauncher.set(javaToolchains.launcherFor { // kotlinx.coroutines requires Java 11+ diff --git a/dokka-integration-tests/maven/build.gradle.kts b/dokka-integration-tests/maven/build.gradle.kts index dd1b889046..22c28dcb8a 100644 --- a/dokka-integration-tests/maven/build.gradle.kts +++ b/dokka-integration-tests/maven/build.gradle.kts @@ -2,8 +2,6 @@ * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.dependsOnMavenLocalPublication - plugins { id("org.jetbrains.conventions.dokka-integration-test") id("org.jetbrains.conventions.maven-cli-setup") @@ -16,8 +14,6 @@ dependencies { } tasks.integrationTest { - dependsOnMavenLocalPublication() - dependsOn(tasks.installMavenBinary) val mvn = mavenCliSetup.mvn inputs.file(mvn) diff --git a/dokka-runners/gradle-plugin-classic/build.gradle.kts b/dokka-runners/gradle-plugin-classic/build.gradle.kts index d29258d6ec..76612fdd4f 100644 --- a/dokka-runners/gradle-plugin-classic/build.gradle.kts +++ b/dokka-runners/gradle-plugin-classic/build.gradle.kts @@ -87,16 +87,6 @@ tasks.validatePlugins { enableStricterValidation.set(true) } -tasks.withType().configureEach { - onlyIf { publication != publishing.publications["dokkaGradlePluginForIntegrationTests"] } -} - -afterEvaluate { // Workaround for an interesting design choice https://github.com/gradle/gradle/blob/c4f935f77377f1783f70ec05381c8182b3ade3ea/subprojects/plugin-development/src/main/java/org/gradle/plugin/devel/plugins/MavenPluginPublishPlugin.java#L49 - configureSpacePublicationIfNecessary("pluginMaven", "dokkaGradlePluginPluginMarkerMaven") - configureSonatypePublicationIfNecessary("pluginMaven", "dokkaGradlePluginPluginMarkerMaven") - createDokkaPublishTaskIfNecessary() -} - tasks.processResources { duplicatesStrategy = DuplicatesStrategy.WARN } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a39d1c0818..a303a631e2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,7 +48,6 @@ node = "16.13.0" ## Publishing gradlePlugin-shadow = "7.1.2" -gradlePlugin-nexusPublish = "1.1.0" gradlePlugin-gradlePluginPublish = "0.20.0" gradlePlugin-gradleNode = "3.5.1" @@ -148,5 +147,4 @@ kotest-assertionsJson = { module = "io.kotest:kotest-assertions-json" } # and define the Maven coordinates above to be used in build-logic/build.gradle.kts) kotlinx-binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinx-bcv" } -nexusPublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradlePlugin-nexusPublish" } gradleNode = { id = "com.github.node-gradle.node", version.ref = "gradlePlugin-gradleNode" } diff --git a/settings.gradle.kts b/settings.gradle.kts index da48f13172..b37598f9d5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -62,7 +62,7 @@ plugins { //includeBuild("dokka-integration-tests") includeBuild("dokka-subprojects") // gradle-plugin should sync, but might not be buildable yet -//includeBuild("dokka-runners/gradle-plugin") +includeBuild("dokka-runners/gradle-plugin") includeBuild("dokka-runners/gradle-plugin-classic") includeBuild("dokka-runners/maven-plugin") includeBuild("dokka-runners/cli")