-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Co-authored-by: Oleg Yukhnevich <[email protected]>
- Loading branch information
1 parent
a44efd4
commit 8e5c63d
Showing
1,260 changed files
with
1,542 additions
and
1,495 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
[submodule "integration-tests/gradle/projects/coroutines/kotlinx-coroutines"] | ||
path = integration-tests/gradle/projects/coroutines/kotlinx-coroutines | ||
path = dokka-integration-tests/gradle/projects/coroutines/kotlinx-coroutines | ||
url = https://github.com/Kotlin/kotlinx.coroutines | ||
[submodule "integration-tests/gradle/projects/serialization/kotlinx-serialization"] | ||
path = integration-tests/gradle/projects/serialization/kotlinx-serialization | ||
path = dokka-integration-tests/gradle/projects/serialization/kotlinx-serialization | ||
url = https://github.com/Kotlin/kotlinx.serialization | ||
[submodule "integration-tests/maven/projects/biojava/biojava"] | ||
path = integration-tests/maven/projects/biojava/biojava | ||
path = dokka-integration-tests/maven/projects/biojava/biojava | ||
url = https://github.com/biojava/biojava |
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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
# About build-logic Module | ||
# build-logic | ||
|
||
This module aims to share common build logic for whole projects, previously we were using [buildSrc](https://docs.gradle.org/7.6/userguide/organizing_gradle_projects.html#sec:build_sources), | ||
but for some reasons like "A change in buildSrc causes the whole project to become out-of-date", we are migrating to [composite builds](https://docs.gradle.org/7.6/userguide/composite_builds.html), | ||
which avoids the side effects of buildSrc. | ||
This project aims to share common build logic between subprojects. | ||
|
||
For more information, you can ref https://proandroiddev.com/stop-using-gradle-buildsrc-use-composite-builds-instead-3c38ac7a2ab3. | ||
In principle, this is similar to `buildSrc`, but this project utilizes [composite builds][1] to avoid various | ||
[inconvenient side effects][2] of `buildSrc`. | ||
|
||
For more information, see [Sharing Build Logic between Subprojects][3] | ||
|
||
___ | ||
|
||
Note: the filename pattern used for convention plugins is inspired by how Gradle configures its | ||
own convention plugins; [example project here][4]. | ||
|
||
[1]: https://docs.gradle.org/7.6/userguide/composite_builds.html | ||
[2]: https://proandroiddev.com/stop-using-gradle-buildsrc-use-composite-builds-instead-3c38ac7a2ab3 | ||
[3]: https://docs.gradle.org/8.4/userguide/sharing_build_logic_between_subprojects.html | ||
[4]: https://github.com/gradle/gradle/tree/b165da7de15e70afb6cac564bf4aadf16aa157b3/build-logic/jvm/src/main/kotlin |
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
35 changes: 35 additions & 0 deletions
35
build-logic/src/main/kotlin/dokkabuild.gradle-plugin.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,35 @@ | ||
/* | ||
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("org.gradle.kotlin.kotlin-dsl") | ||
id("dokkabuild.java") | ||
kotlin("jvm") | ||
id("dokkabuild.publish-gradle-plugin") | ||
} | ||
|
||
// org.gradle.kotlin.kotlin-dsl sets languageVersion and apiVersion to 1.8 by default starting from Gradle 8. | ||
// As we need to be compatible with previous Gradle versions, we need to set it back to 1.4. | ||
// Note: we should do it directly on tasks and not via top-level `kotlin.compilerOptions` | ||
// because `kotlin-dsl plugin` declares them on task level, and so top-level config is overridden | ||
tasks.withType<KotlinCompile>().configureEach { | ||
compilerOptions { | ||
languageVersion.set(dokkaBuild.kotlinLanguageLevel) | ||
apiVersion.set(dokkaBuild.kotlinLanguageLevel) | ||
|
||
freeCompilerArgs.addAll( | ||
// 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", | ||
) | ||
} | ||
} | ||
|
||
tasks.validatePlugins { | ||
enableStricterValidation.set(true) | ||
} |
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
36 changes: 36 additions & 0 deletions
36
build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.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,36 @@ | ||
/* | ||
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
plugins { | ||
id("dokkabuild.java") | ||
kotlin("jvm") | ||
} | ||
|
||
val rootProjectsWithoutDependencyOnDokkaCore = listOf("dokka-integration-tests") | ||
|
||
kotlin { | ||
explicitApi() | ||
compilerOptions { | ||
allWarningsAsErrors.set(true) | ||
languageVersion.set(dokkaBuild.kotlinLanguageLevel) | ||
apiVersion.set(dokkaBuild.kotlinLanguageLevel) | ||
|
||
// These projects know nothing about the `@InternalDokkaApi` annotation, so the Kotlin compiler | ||
// will complain about an unresolved opt-in requirement marker and fail the build if it's not excluded. | ||
if (rootProject.name !in rootProjectsWithoutDependencyOnDokkaCore) { | ||
optIn.addAll( | ||
"kotlin.RequiresOptIn", | ||
"org.jetbrains.dokka.InternalDokkaApi" | ||
) | ||
} | ||
|
||
freeCompilerArgs.addAll( | ||
// 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", | ||
) | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
build-logic/src/main/kotlin/dokkabuild.publish-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,95 @@ | ||
/* | ||
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
plugins { | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "mavenCentral" | ||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
credentials { | ||
username = System.getenv("DOKKA_SONATYPE_USER") | ||
password = System.getenv("DOKKA_SONATYPE_PASSWORD") | ||
} | ||
} | ||
maven { | ||
name = "spaceDev" | ||
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") | ||
credentials { | ||
username = System.getenv("DOKKA_SPACE_PACKAGES_USER") | ||
password = System.getenv("DOKKA_SPACE_PACKAGES_SECRET") | ||
} | ||
} | ||
maven { | ||
name = "spaceTest" | ||
url = uri("https://maven.pkg.jetbrains.space/kotlin/p/dokka/test") | ||
credentials { | ||
username = System.getenv("DOKKA_SPACE_PACKAGES_USER") | ||
password = System.getenv("DOKKA_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") | ||
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") | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys( | ||
System.getenv("DOKKA_SIGN_KEY_ID")?.takeIf(String::isNotBlank), | ||
System.getenv("DOKKA_SIGN_KEY")?.takeIf(String::isNotBlank), | ||
System.getenv("DOKKA_SIGN_KEY_PASSPHRASE")?.takeIf(String::isNotBlank), | ||
) | ||
sign(publishing.publications) | ||
setRequired(provider { !project.version.toString().endsWith("-SNAPSHOT") }) | ||
} | ||
|
||
// This is a hack for a Gradle 8 problem, see https://github.com/gradle/gradle/issues/26091 | ||
// | ||
// Fails with the following error otherwise: | ||
// > Task ':runner-gradle-plugin-classic:publishDokkaPluginMarkerMavenPublicationToSpaceTestRepository' uses | ||
// > this output of task ':runner-gradle-plugin-classic:signPluginMavenPublication' without declaring an | ||
// > explicit or implicit dependency. | ||
tasks.withType<AbstractPublishToMaven>().configureEach { | ||
val signingTasks = tasks.withType<Sign>() | ||
mustRunAfter(signingTasks) | ||
} |
Oops, something went wrong.