Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor project structure and introduce composite builds #3174

Merged
merged 81 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
81d1f43
Initial included-build refactor (#3161)
aSemy Sep 5, 2023
1885d5c
Move CLI & Maven runners (#3163)
IgnatBeresnev Sep 5, 2023
4457660
Move the Gradle runner (#3164)
IgnatBeresnev Sep 5, 2023
dbde733
Move integration tests (#3165)
IgnatBeresnev Sep 5, 2023
bc6fd59
Move analysis-kotlin-api, analysis-java and analysis-markdown (#3166)
IgnatBeresnev Sep 5, 2023
d95e4b3
Move descriptor analysis modules
IgnatBeresnev Sep 5, 2023
a10a0cb
Move symbols analysis module
IgnatBeresnev Sep 5, 2023
e830b86
Move core test API (#3167)
IgnatBeresnev Sep 5, 2023
ef0dcbf
Move smaller plugins (#3168)
IgnatBeresnev Sep 5, 2023
8ef36fa
Move the base plugin (#3169)
IgnatBeresnev Sep 5, 2023
e826ebc
Move markdown plugins (#3170)
IgnatBeresnev Sep 5, 2023
49e4eb0
Move and adapt the README
IgnatBeresnev Sep 5, 2023
7ac239e
Move the javadoc plugin (#3171)
IgnatBeresnev Sep 5, 2023
ec41cc1
Move dokka-core (#3173)
IgnatBeresnev Sep 5, 2023
91ab2df
Add version-catalog def in integration-tests (#3175)
aSemy Sep 6, 2023
66da09a
Move integration test utils into a separate subproject (#3176)
aSemy Sep 6, 2023
85d05b2
Add Gradle properties to included builds (#3177)
aSemy Oct 18, 2023
ccb7e2b
Merge remote-tracking branch 'origin/master' into project-structure-r…
IgnatBeresnev Oct 18, 2023
c802c59
Remove irrelevant project properties
IgnatBeresnev Oct 18, 2023
fedd09b
Update dokka_version to 1.9.20-SNAPSHOT
IgnatBeresnev Oct 18, 2023
e150c5f
Fix Gradle sync problems
IgnatBeresnev Oct 19, 2023
d075fb4
Add composite build parent tasks
IgnatBeresnev Oct 19, 2023
66809dc
Align included build toolchain and language versions
IgnatBeresnev Oct 19, 2023
cdd1fed
Merge remote-tracking branch 'origin/master' into project-structure-r…
IgnatBeresnev Oct 19, 2023
e7565b4
Move parts of Dokkatoo into gradle-plugin
IgnatBeresnev Oct 19, 2023
0beee0e
Align gradle-plugin's formatting with the rest of the project
IgnatBeresnev Oct 19, 2023
744cf9c
Rip out non-essential dependencies in gradle-plugin
IgnatBeresnev Oct 19, 2023
3cab9b4
Move gradle-plugin's versions into the common catalog
IgnatBeresnev Oct 19, 2023
1f50760
Fix `dokka-core` artifact name for runners
whyoleg Oct 19, 2023
3c70ac2
Merge remote-tracking branch 'origin/project-structure-refactoring' i…
IgnatBeresnev Oct 19, 2023
467fb3b
Rip out non essentials
IgnatBeresnev Oct 19, 2023
73ba7bb
Rip out publishing
IgnatBeresnev Oct 19, 2023
07dbe69
Setup publishing to multiple repositories (gradle-plugin publishing i…
whyoleg Oct 19, 2023
02fab9b
Correct publishing env properties
IgnatBeresnev Oct 19, 2023
2bb8290
Add parent composite build tasks
IgnatBeresnev Oct 19, 2023
e0780bf
Correct publishing information
IgnatBeresnev Oct 19, 2023
7619929
cleanup build scripts
whyoleg Oct 20, 2023
02fcac2
fix publishing of Gradle plugin and it markers
whyoleg Oct 20, 2023
f39f5a4
remove todos
whyoleg Oct 20, 2023
b8b944e
restore gradle integration tests
whyoleg Oct 20, 2023
0dad2cd
rollback gradle integration tests to use mavenLocal for now
whyoleg Oct 23, 2023
48fb9a6
maven integration tests
whyoleg Oct 23, 2023
b5d971c
fix maven plugin POM
whyoleg Oct 23, 2023
bf27c4f
cli integration tests
whyoleg Oct 23, 2023
f06e47a
add parent tasks to dokka-integration-tests
whyoleg Oct 23, 2023
95c7ff6
update gradle to 8.4 (not fully yet)
whyoleg Oct 23, 2023
d19865a
fix workflows
whyoleg Oct 23, 2023
487c7c7
restore BCV
whyoleg Oct 23, 2023
2905c85
fix gradle plugin compatibility
whyoleg Oct 23, 2023
1c57d44
ignore some tests for now
whyoleg Oct 23, 2023
c0f9c5e
run clean task separately
whyoleg Oct 23, 2023
1003938
fix s3 script path
whyoleg Oct 23, 2023
0ab2f67
Replace deprecated API
IgnatBeresnev Oct 26, 2023
1ac627a
Remove check's dependency on integration tests
IgnatBeresnev Oct 26, 2023
1fe4987
Rename convention plugins
IgnatBeresnev Oct 26, 2023
8c6a479
Rename integration test utilities subproject
IgnatBeresnev Oct 26, 2023
ca4c3e2
Minor convention plugin refactoring
IgnatBeresnev Oct 26, 2023
f173958
Minor build scripts refactoring
IgnatBeresnev Oct 26, 2023
25d2eab
Remove `gradle-plugin` subproject to minimize diff
IgnatBeresnev Oct 26, 2023
b393a12
Enable parent publishPlugins task
IgnatBeresnev Oct 26, 2023
b3913d0
Make integration tests runnable from IDEA
IgnatBeresnev Oct 27, 2023
c3f4f75
Return a lost `@Optional` annotation
IgnatBeresnev Oct 27, 2023
1f9bb7d
Merge remote-tracking branch 'origin/master' into project-structure-r…
IgnatBeresnev Oct 30, 2023
63ef755
Finish the merge of master
IgnatBeresnev Oct 30, 2023
ea32148
Align file locations with package directives
IgnatBeresnev Oct 31, 2023
cbb3b98
Make dokka-subproject a non-included build
IgnatBeresnev Oct 31, 2023
d4c2058
Rename runner included builds by moving
IgnatBeresnev Oct 31, 2023
dc02ecc
Merge remote-tracking branch 'origin/master' into project-structure-r…
IgnatBeresnev Oct 31, 2023
f90f681
Fix CLI integration tests
IgnatBeresnev Oct 31, 2023
e369c6f
Add parent validatePlugins task
IgnatBeresnev Oct 31, 2023
c08b7ae
Fix publishing after the update to Gradle 8
IgnatBeresnev Nov 1, 2023
a8e53e0
Fix integration tests
IgnatBeresnev Nov 1, 2023
8346ca0
Fix Dokka version in coroutines and serialization tests
IgnatBeresnev Nov 1, 2023
f2dd017
Update coroutine's diff
IgnatBeresnev Nov 1, 2023
b0f2297
Merge remote-tracking branch 'origin/master' into project-structure-r…
IgnatBeresnev Nov 9, 2023
496c0e3
Rename runner included builds
IgnatBeresnev Nov 9, 2023
ee62c25
Update hardcoded project paths
IgnatBeresnev Nov 9, 2023
2bc0ee2
Fix wrong automatic merge conflict resolution
IgnatBeresnev Nov 9, 2023
dae52a1
Remove unneeded configuration and copyrights
IgnatBeresnev Nov 10, 2023
b8fa480
Merge remote-tracking branch 'origin/master' into project-structure-r…
IgnatBeresnev Nov 10, 2023
fc8b3f0
Move wasm-js-wasi test into the new included build
IgnatBeresnev Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/preview-publish-ga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
arguments: :dokka-integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
env:
DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/coroutines
- name: Copy files to GitHub Actions Artifacts
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
arguments: :dokka-integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
env:
DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/serialization
- name: Copy files to GitHub Actions Artifacts
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: :integration-tests:maven:integrationTest --tests org.jetbrains.dokka.it.maven.BiojavaIntegrationTest --stacktrace
arguments: :dokka-integration-tests:maven:integrationTest --tests org.jetbrains.dokka.it.maven.BiojavaIntegrationTest --stacktrace
env:
DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/biojava
- name: Copy files to GitHub Actions Artifacts
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/preview-publish-web-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
arguments: :dokka-integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.CoroutinesGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
env:
DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/coroutines
- name: Configure AWS credentials for S3 access
Expand All @@ -34,7 +34,7 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Copy files to dokka's S3 bucket
run: ./integration-tests/aws_sync.sh s3://${{ env.bucket-name }} coroutines ../coroutines
run: ./dokka-integration-tests/aws_sync.sh s3://${{ env.bucket-name }} coroutines ../coroutines
- name: Print link
run: echo https://dokka-snapshots.s3.eu-central-1.amazonaws.com/${{ env.branch-name }}/coroutines/${GITHUB_SHA::7}/index.html

Expand All @@ -55,7 +55,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: :integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
arguments: :dokka-integration-tests:gradle:integrationTest --tests org.jetbrains.dokka.it.gradle.kotlin.SerializationGradleIntegrationTest --stacktrace "-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=500m"
env:
DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/serialization
- name: Configure AWS credentials for S3 access
Expand All @@ -65,7 +65,7 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Copy files to dokka's S3 bucket
run: ./integration-tests/aws_sync.sh s3://${{ env.bucket-name }} serialization ../serialization
run: ./dokka-integration-tests/aws_sync.sh s3://${{ env.bucket-name }} serialization ../serialization
- name: Print link
run: echo https://dokka-snapshots.s3.eu-central-1.amazonaws.com/${{ env.branch-name }}/serialization/${GITHUB_SHA::7}/index.html

Expand All @@ -86,7 +86,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: :integration-tests:maven:integrationTest --tests org.jetbrains.dokka.it.maven.BiojavaIntegrationTest --stacktrace
arguments: :dokka-integration-tests:maven:integrationTest --tests org.jetbrains.dokka.it.maven.BiojavaIntegrationTest --stacktrace
env:
DOKKA_TEST_OUTPUT_PATH: /home/runner/work/dokka/biojava
- name: Configure AWS credentials for S3 access
Expand All @@ -96,6 +96,6 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Copy files to dokka's S3 bucket
run: ./integration-tests/aws_sync.sh s3://${{ env.bucket-name }} biojava ../biojava
run: ./dokka-integration-tests/aws_sync.sh s3://${{ env.bucket-name }} biojava ../biojava
- name: Print link
run: echo https://dokka-snapshots.s3.eu-central-1.amazonaws.com/${{ env.branch-name }}/biojava/${GITHUB_SHA::7}/index.html
5 changes: 3 additions & 2 deletions .github/workflows/tests-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ jobs:
- uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: clean
- name: Run tests under Windows
if: matrix.os == 'windows-latest'
# Running tests with the Gradle daemon on windows agents leads to some very strange
# JVM crashes for some reason. Most likely a problem of Gradle/GitHub/Windows server
run: >
./gradlew clean test --stacktrace --no-daemon --no-parallel
./gradlew test --stacktrace --no-daemon --no-parallel
"-Dorg.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=500m"
"-Porg.jetbrains.dokka.javaToolchain.testLauncher=${{ env.JAVA_TEST_VERSION }}"
- name: Run tests under Ubuntu
if: matrix.os != 'windows-latest'
run: >
./gradlew clean test --stacktrace
./gradlew test --stacktrace
"-Porg.jetbrains.dokka.javaToolchain.testLauncher=${{ env.JAVA_TEST_VERSION }}"
5 changes: 3 additions & 2 deletions .github/workflows/tests-thorough.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ jobs:
- uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: clean
- name: Run tests under Windows
if: matrix.os == 'windows-latest'
# Running tests with the Gradle daemon on windows agents leads to some very strange
# JVM crashes for some reason. Most likely a problem of Gradle/GitHub/Windows server
run: >
./gradlew clean test --stacktrace --no-daemon --no-parallel
./gradlew test --stacktrace --no-daemon --no-parallel
"-Dorg.gradle.jvmargs=-Xmx1g -XX:MaxMetaspaceSize=500m"
"-Porg.jetbrains.dokka.javaToolchain.testLauncher=${{ matrix.javaVersion }}"
- name: Run tests under Ubuntu/Macos
if: matrix.os != 'windows-latest'
run: >
./gradlew clean test --stacktrace
./gradlew test --stacktrace
"-Porg.jetbrains.dokka.javaToolchain.testLauncher=${{ matrix.javaVersion }}"
6 changes: 3 additions & 3 deletions .gitmodules
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
21 changes: 16 additions & 5 deletions build-logic/README.md
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
* 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.jetbrains.DokkaBuildProperties
import dokkabuild.DokkaBuildProperties

/**
* A convention plugin that sets up common config and sensible defaults for all subprojects.
Expand All @@ -16,12 +14,7 @@ plugins {
base
}

val dokkaBuildProperties: DokkaBuildProperties = extensions.create(DokkaBuildProperties.EXTENSION_NAME)

if (project != rootProject) {
project.group = rootProject.group
project.version = rootProject.version
}
extensions.create<DokkaBuildProperties>(DokkaBuildProperties.EXTENSION_NAME)

tasks.withType<AbstractArchiveTask>().configureEach {
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
Expand Down
35 changes: 35 additions & 0 deletions build-logic/src/main/kotlin/dokkabuild.gradle-plugin.gradle.kts
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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

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).
* Base configuration for Java/JVM projects.
*/

plugins {
id("org.jetbrains.conventions.base")
id("dokkabuild.base")
java
}

java {
toolchain {
languageVersion.set(dokkaBuild.mainJavaVersion)
}
withSourcesJar()
}

tasks.withType<Test>().configureEach {
Expand All @@ -40,3 +34,7 @@ tasks.withType<Test>().configureEach {
dependencies {
testImplementation(platform(libs.junit.bom))
}

tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.FAIL
}
36 changes: 36 additions & 0 deletions build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts
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 build-logic/src/main/kotlin/dokkabuild.publish-base.gradle.kts
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)
}