Skip to content

Commit

Permalink
Rip out publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Oct 19, 2023
1 parent 467fb3b commit 73ba7bb
Show file tree
Hide file tree
Showing 15 changed files with 8 additions and 354 deletions.

This file was deleted.

4 changes: 0 additions & 4 deletions build-logic/src/main/kotlin/org/jetbrains/DokkaVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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("-", ""))
}
12 changes: 0 additions & 12 deletions build-logic/src/main/kotlin/org/jetbrains/DokkaVersionType.kt

This file was deleted.

49 changes: 0 additions & 49 deletions build-logic/src/main/kotlin/org/jetbrains/ValidatePublications.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 {
Expand Down
88 changes: 4 additions & 84 deletions build-logic/src/main/kotlin/org/jetbrains/publication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<PublishingExtension> {
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<PublishToMavenRepository> {
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<SigningExtension>("signing") {
if (signingKeyId?.isNotBlank() == true) {
useInMemoryPgpKeys(signingKeyId, signingKey, signingKeyPassphrase)
} else {
useInMemoryPgpKeys(signingKey, signingKeyPassphrase)
}
publications.forEach { publicationName ->
extensions.getByType<PublishingExtension>()
.publications
.findByName(publicationName)
?.let { sign(it) }
}
}
}
}
26 changes: 0 additions & 26 deletions build-logic/src/main/kotlin/org/jetbrains/taskUtils.kt

This file was deleted.

39 changes: 0 additions & 39 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,17 @@
* 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

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


logger.lifecycle("Publication version: $dokka_version")
tasks.register<ValidatePublications>("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")
Expand All @@ -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
// )
//}
Loading

0 comments on commit 73ba7bb

Please sign in to comment.