Skip to content

Commit

Permalink
Build script tweaks (#3485)
Browse files Browse the repository at this point in the history
* Use simpler syntax to apply Kotlin compiler options
* Set property values with lazy property assignment = operator
* Limit scope of UnstableApiUsage suppressions
* Remove unnecessary suppressions
* Prioritise Maven Central ahead of Gradle Plugin Portal
  • Loading branch information
3flex committed Apr 25, 2024
1 parent 5503b93 commit 262e220
Show file tree
Hide file tree
Showing 23 changed files with 35 additions and 51 deletions.
4 changes: 2 additions & 2 deletions build-logic/settings.gradle.kts
Expand Up @@ -6,14 +6,14 @@ rootProject.name = "build-logic"

pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
gradlePluginPortal()
}
includeBuild("../build-settings-logic")
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
google()
Expand Down
Expand Up @@ -17,8 +17,8 @@ plugins {
// 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)
languageVersion = dokkaBuild.kotlinLanguageLevel
apiVersion = dokkaBuild.kotlinLanguageLevel

freeCompilerArgs.addAll(
// need 1.4 support, otherwise there might be problems
Expand All @@ -31,5 +31,5 @@ tasks.withType<KotlinCompile>().configureEach {
}

tasks.validatePlugins {
enableStricterValidation.set(true)
enableStricterValidation = true
}
8 changes: 4 additions & 4 deletions build-logic/src/main/kotlin/dokkabuild.java.gradle.kts
Expand Up @@ -13,7 +13,7 @@ plugins {

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

Expand All @@ -26,9 +26,9 @@ tasks.withType<Test>().configureEach {
(Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
}

javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(dokkaBuild.testJavaLauncherVersion)
})
javaLauncher = javaToolchains.launcherFor {
languageVersion = dokkaBuild.testJavaLauncherVersion
}
}

dependencies {
Expand Down
6 changes: 3 additions & 3 deletions build-logic/src/main/kotlin/dokkabuild.kotlin-jvm.gradle.kts
Expand Up @@ -12,9 +12,9 @@ val rootProjectsWithoutDependencyOnDokkaCore = listOf("dokka-integration-tests")
kotlin {
explicitApi()
compilerOptions {
allWarningsAsErrors.set(true)
languageVersion.set(dokkaBuild.kotlinLanguageLevel)
apiVersion.set(dokkaBuild.kotlinLanguageLevel)
allWarningsAsErrors = true
languageVersion = dokkaBuild.kotlinLanguageLevel
apiVersion = 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.
Expand Down
Expand Up @@ -11,8 +11,8 @@ plugins {

@Suppress("UnstableApiUsage")
gradlePlugin {
website.set("https://kotl.in/dokka")
vcsUrl.set("https://github.com/kotlin/dokka.git")
website = "https://kotl.in/dokka"
vcsUrl = "https://github.com/kotlin/dokka.git"
}

// com.gradle.plugin-publish configures publication in afterEvaluate block
Expand Down
Expand Up @@ -17,9 +17,9 @@ java {

tasks.shadowJar {
// separate directory because otherwise Gradle complains about multiple tasks writing into the same file
destinationDirectory.set(project.layout.buildDirectory.dir("shadowLibs"))
destinationDirectory = project.layout.buildDirectory.dir("shadowLibs")
// removes the `-all` classifier from the artifact name
archiveClassifier.set("")
archiveClassifier = ""
}

publishing.publications.register<MavenPublication>(PublicationName.JVM) {
Expand Down
2 changes: 1 addition & 1 deletion build-settings-logic/settings.gradle.kts
Expand Up @@ -15,7 +15,7 @@ pluginManagement {

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositoriesMode.set(PREFER_SETTINGS)
repositoriesMode = PREFER_SETTINGS
repositories {
mavenCentral()
gradlePluginPortal()
Expand Down
Expand Up @@ -2,7 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "template.settings.gradle.kts")
rootProject.name = "it-android-0"
Expand Up @@ -2,7 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "template.settings.gradle.kts")
rootProject.name = "it-basic-groovy"
Expand Up @@ -2,7 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "template.settings.gradle.kts")
rootProject.name = "it-basic"
Expand Up @@ -2,7 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "template.settings.gradle.kts")
rootProject.name = "it-js-ir-0"
Expand Up @@ -2,7 +2,5 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("LocalVariableName", "UnstableApiUsage")

apply(from = "template.settings.gradle.kts")
rootProject.name = "it-sequential-tasks-execution-stress"
Expand Up @@ -2,8 +2,6 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("LocalVariableName", "UnstableApiUsage")

pluginManagement {
val dokka_it_kotlin_version: String by settings
val dokka_it_dokka_version: String by settings
Expand Down
3 changes: 1 addition & 2 deletions dokka-integration-tests/settings.gradle.kts
Expand Up @@ -2,8 +2,6 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("UnstableApiUsage")

rootProject.name = "dokka-integration-tests"

pluginManagement {
Expand All @@ -22,6 +20,7 @@ plugins {
}

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide")
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide-plugin-dependencies")
Expand Down
3 changes: 1 addition & 2 deletions dokka-runners/runner-cli/settings.gradle.kts
Expand Up @@ -2,8 +2,6 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("UnstableApiUsage")

rootProject.name = "runner-cli"

pluginManagement {
Expand All @@ -22,6 +20,7 @@ plugins {
}

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
google()
Expand Down
Expand Up @@ -28,7 +28,6 @@ dependencies {
testImplementation("org.jetbrains.dokka:dokka-test-api:$version")
}

@Suppress("UnstableApiUsage")
gradlePlugin {
plugins {
create("dokka") {
Expand All @@ -37,6 +36,7 @@ gradlePlugin {

displayName = "Dokka plugin"
description = "Dokka is an API documentation engine for Kotlin"
@Suppress("UnstableApiUsage")
tags.addAll("dokka", "kotlin", "kdoc", "android", "documentation", "api")
}
}
Expand Down
Expand Up @@ -2,8 +2,6 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("UnstableApiUsage")

rootProject.name = "runner-gradle-plugin-classic"

pluginManagement {
Expand All @@ -22,6 +20,7 @@ plugins {
}

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
google()
Expand Down
3 changes: 1 addition & 2 deletions dokka-runners/runner-maven-plugin/settings.gradle.kts
Expand Up @@ -2,8 +2,6 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("UnstableApiUsage")

rootProject.name = "runner-maven-plugin"

pluginManagement {
Expand All @@ -22,6 +20,7 @@ plugins {
}

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
}
Expand Down
Expand Up @@ -63,8 +63,8 @@ val shadowDependenciesJar by tasks.registering(ShadowJar::class) {
group = "shadow"
description = "Create a shadow jar from dependencies without fastutil"

archiveClassifier.set("dependencies")
destinationDirectory.set(project.layout.buildDirectory.dir("shadowDependenciesLibs"))
archiveClassifier = "dependencies"
destinationDirectory = project.layout.buildDirectory.dir("shadowDependenciesLibs")

// we need to create JAR with dependencies, but without fastutil,
// so we include `runtimeClasspath` configuration (the same configuration which is used by default `shadowJar` task)
Expand Down
4 changes: 2 additions & 2 deletions dokka-subprojects/analysis-kotlin-symbols/build.gradle.kts
Expand Up @@ -125,8 +125,8 @@ val shadowDependenciesJar by tasks.registering(ShadowJar::class) {
group = "shadow"
description = "Create a shadow jar from dependencies without fastutil"

archiveClassifier.set("dependencies")
destinationDirectory.set(project.layout.buildDirectory.dir("shadowDependenciesLibs"))
archiveClassifier = "dependencies"
destinationDirectory = project.layout.buildDirectory.dir("shadowDependenciesLibs")

// we need to create JAR with dependencies, but without fastutil,
// so we include `runtimeClasspath` configuration (the same configuration which is used by default `shadowJar` task)
Expand Down
8 changes: 4 additions & 4 deletions dokka-subprojects/plugin-base-frontend/build.gradle.kts
Expand Up @@ -12,11 +12,11 @@ plugins {
}

node {
version.set(libs.versions.node)
version = libs.versions.node

// https://github.com/node-gradle/gradle-node-plugin/blob/3.5.1/docs/faq.md#is-this-plugin-compatible-with-centralized-repositories-declaration
download.set(true)
distBaseUrl.set(null as String?) // Strange cast to avoid overload ambiguity
download = true
distBaseUrl = null as String? // Strange cast to avoid overload ambiguity

// Stop Gradle from monitoring node_modules dir; it will be managed by NPM. This helps performance and task-avoidance.
fastNpmInstall = true
Expand All @@ -27,7 +27,7 @@ val distributionDirectory = layout.projectDirectory.dir("dist")
val npmRunBuild by tasks.registering(NpmTask::class) {
dependsOn(tasks.npmInstall)

npmCommand.set(parseSpaceSeparatedArgs("run build"))
npmCommand = parseSpaceSeparatedArgs("run build")

inputs.dir("src/main")
.withPropertyName("mainSources")
Expand Down
7 changes: 4 additions & 3 deletions examples/plugin/hide-internal-api/build.gradle.kts
Expand Up @@ -31,12 +31,13 @@ dependencies {
testImplementation("org.jetbrains.dokka:dokka-base-test-utils:$dokkaVersion")
}

kotlin {
compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
}

val dokkaOutputDir = "$buildDir/dokka"

tasks {
withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_1_8)
}
dokkaHtml {
outputDirectory.set(file(dokkaOutputDir))
}
Expand Down
3 changes: 1 addition & 2 deletions settings.gradle.kts
Expand Up @@ -2,8 +2,6 @@
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

@file:Suppress("UnstableApiUsage")

rootProject.name = "dokka"

pluginManagement {
Expand All @@ -17,6 +15,7 @@ pluginManagement {
}

dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide")
maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide-plugin-dependencies")
Expand Down

0 comments on commit 262e220

Please sign in to comment.