-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup publishing to multiple repositories (gradle-plugin publishing i…
…s not supported yet)
- Loading branch information
Showing
29 changed files
with
305 additions
and
179 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
build-logic/src/main/kotlin/org/jetbrains/conventions/publishing-base.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* 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 { | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
// TODO: recheck ENV variables - may be replace them with dokka specific renaming to DOKKA_* | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "mavenCentral" | ||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
credentials { | ||
// TODO: recheck credentials | ||
username = System.getenv("SONATYPE_USER") | ||
password = System.getenv("SONATYPE_PASSWORD") | ||
} | ||
} | ||
maven { | ||
// TODO: recheck if we need it at all | ||
name = "snapshot" | ||
url = uri("https://oss.sonatype.org/content/repositories/snapshots/") | ||
credentials { | ||
username = System.getenv("SONATYPE_USER") | ||
password = System.getenv("SONATYPE_PASSWORD") | ||
} | ||
} | ||
maven { | ||
name = "spaceDev" | ||
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") | ||
credentials { | ||
username = System.getenv("SPACE_PACKAGES_USER") | ||
password = System.getenv("SPACE_PACKAGES_SECRET") | ||
} | ||
} | ||
maven { | ||
name = "spaceTest" | ||
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/dokka/test") | ||
credentials { | ||
// TODO: should it be different credentials from dev? | ||
username = System.getenv("SPACE_PACKAGES_USER") | ||
password = System.getenv("SPACE_PACKAGES_SECRET") | ||
} | ||
} | ||
// Publish to a project-local Maven directory, for verification. To test, run: | ||
// ./gradlew publishAllPublicationsToProjectLocalRepository | ||
// and check $rootDir/build/maven-project-local | ||
maven { | ||
name = "projectLocal" | ||
url = uri(rootProject.layout.buildDirectory.dir("maven-project-local")) | ||
} | ||
} | ||
|
||
publications.withType<MavenPublication>().configureEach { | ||
pom { | ||
name.convention("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") | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys( | ||
System.getenv("SIGN_KEY_ID")?.takeIf(String::isNotBlank), | ||
System.getenv("SIGN_KEY")?.takeIf(String::isNotBlank), | ||
System.getenv("SIGN_KEY_PASSPHRASE")?.takeIf(String::isNotBlank), | ||
) | ||
sign(publishing.publications) | ||
setRequired(provider { !project.version.toString().endsWith("-SNAPSHOT") }) | ||
} |
25 changes: 25 additions & 0 deletions
25
build-logic/src/main/kotlin/org/jetbrains/conventions/publishing-default.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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.jvm.tasks.Jar | ||
import org.jetbrains.MAVEN_PUBLICATION_NAME | ||
|
||
plugins { | ||
id("org.jetbrains.conventions.publishing-base") | ||
} | ||
|
||
val javadocJar by tasks.registering(Jar::class) { | ||
group = JavaBasePlugin.DOCUMENTATION_GROUP | ||
archiveClassifier.set("javadoc") | ||
// TODO: decide if we really need dokka html in javadoc jar | ||
// description = "Assembles a Javadoc JAR using Dokka HTML" | ||
// from(tasks.dokkaHtml) | ||
} | ||
|
||
publishing.publications.register<MavenPublication>(MAVEN_PUBLICATION_NAME) { | ||
artifact(javadocJar) | ||
from(components["java"]) | ||
} |
10 changes: 10 additions & 0 deletions
10
build-logic/src/main/kotlin/org/jetbrains/conventions/publishing-gradle.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* 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.jetbrains.conventions.publishing-base") | ||
// TODO: gradle-publish-plugin | ||
} |
59 changes: 59 additions & 0 deletions
59
build-logic/src/main/kotlin/org/jetbrains/conventions/publishing-shadow.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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.jvm.tasks.Jar | ||
import org.jetbrains.MAVEN_PUBLICATION_NAME | ||
|
||
plugins { | ||
id("org.jetbrains.conventions.publishing-base") | ||
id("com.github.johnrengelman.shadow") | ||
} | ||
|
||
val javadocJar by tasks.registering(Jar::class) { | ||
group = JavaBasePlugin.DOCUMENTATION_GROUP | ||
archiveClassifier.set("javadoc") | ||
// TODO: decide if we really need dokka html in javadoc jar | ||
// description = "Assembles a Javadoc JAR using Dokka HTML" | ||
// from(tasks.dokkaHtml) | ||
} | ||
|
||
publishing.publications.register<MavenPublication>(MAVEN_PUBLICATION_NAME) { | ||
artifact(javadocJar) | ||
shadow.component(this) | ||
artifact(tasks["sourcesJar"]) | ||
} | ||
|
||
// 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 behavior 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() } | ||
|
||
// TODO: recheck, may be it's not needed as we remove shadowRuntimeElements? | ||
// TODO: configure it here | ||
//tasks { | ||
// // There are several reasons for shadowing all dependencies in one place: | ||
// // 1. Some of the artifacts Dokka depends on, like com.jetbrains.intellij.java:java-psi, are not | ||
// // published to Maven Central, so the users would need to add custom repositories to their build scripts. | ||
// // 2. There are many intertwining transitive dependencies of different versions, as well as direct copy-paste, | ||
// // that can lead to runtime errors due to classpath conflicts, so it's best to let Gradle take care of | ||
// // dependency resolution, and then pack everything into a single jar in a single place that can be tuned. | ||
// // 3. The compiler and ide modules are internal details that are likely to change, so packing everything into | ||
// // a single jar provides some stability for the CLI users, while not exposing too many internals. Publishing | ||
// // the compiler, ide and other subprojects separately would make it difficult to refactor the project structure. | ||
// shadowJar { | ||
// val dokka_version: String by project | ||
// | ||
// // cannot be named exactly like the artifact (i.e analysis-kotlin-descriptors-VER.jar), | ||
// // otherwise leads to obscure test failures when run via CLI, but not via IJ | ||
// archiveFileName.set("analysis-kotlin-descriptors-all-$dokka_version.jar") | ||
// archiveClassifier.set("") | ||
// | ||
// // service files are merged to make sure all Dokka plugins | ||
// // from the dependencies are loaded, and not just a single one. | ||
// mergeServiceFiles() | ||
// } | ||
//} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* 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.provider.Provider | ||
import org.gradle.api.provider.ProviderFactory | ||
|
||
fun ProviderFactory.dokkaProperty(name: String): Provider<String> = | ||
gradleProperty("org.jetbrains.dokka.$name") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.