diff options
Diffstat (limited to 'build-logic')
5 files changed, 39 insertions, 35 deletions
diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 0c054c5c..5272534d 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -1,5 +1,3 @@ -import java.util.* - plugins { `kotlin-dsl` } @@ -10,22 +8,12 @@ kotlin { } } -// TODO define versions in Gradle Version Catalog https://github.com/Kotlin/dokka/pull/2884 -val properties = file("../gradle.properties").inputStream().use { - Properties().apply { load(it) } -} - -val kotlinVersion = properties["kotlin_version"] - dependencies { - // Import Gradle Plugins that will be used in the buildSrc pre-compiled script plugins, and any `build.gradle.kts` - // files in the project. - // Use their Maven coordinates (plus versions), not Gradle plugin IDs! - // This should be the only place that Gradle plugin versions are defined, so they are aligned across all build scripts + implementation(libs.gradlePlugin.dokka) + implementation(libs.gradlePlugin.kotlin) + implementation(libs.gradlePlugin.shadow) - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") - implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2") - implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.12.1") - implementation("io.github.gradle-nexus:publish-plugin:1.1.0") - implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.10") + // workaround for accessing version-catalog in convention plugins + // https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 + implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) } diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index 55dfe5c1..ed31885b 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -14,4 +14,10 @@ dependencyResolutionManagement { google() gradlePluginPortal() } + + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } } diff --git a/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts b/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts index ec59da7b..4beeab21 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts +++ b/build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts @@ -15,7 +15,7 @@ plugins { base } -abstract class SetupMavenProperties { +abstract class MavenCliSetupExtension { abstract val mavenVersion: Property<String> abstract val mavenPluginToolsVersion: Property<String> abstract val mavenBuildDir: DirectoryProperty @@ -34,10 +34,10 @@ abstract class SetupMavenProperties { abstract val mvn: RegularFileProperty } -val setupMavenProperties = - extensions.create("setupMavenProperties", SetupMavenProperties::class).apply { - mavenVersion.convention(providers.gradleProperty("mavenVersion")) - mavenPluginToolsVersion.convention(providers.gradleProperty("mavenPluginToolsVersion")) +val mavenCliSetupExtension = + extensions.create("mavenCliSetup", MavenCliSetupExtension::class).apply { + mavenVersion.convention(libs.versions.apache.maven) + mavenPluginToolsVersion.convention(libs.versions.apache.mavenPluginTools) mavenBuildDir.convention(layout.buildDirectory.dir("maven")) mavenInstallDir.convention(layout.buildDirectory.dir("apache-maven")) @@ -64,7 +64,7 @@ val mavenBinary by configurations.registering { isVisible = false defaultDependencies { - addLater(setupMavenProperties.mavenVersion.map { mavenVersion -> + addLater(mavenCliSetupExtension.mavenVersion.map { mavenVersion -> project.dependencies.create( group = "org.apache.maven", name = "apache-maven", @@ -77,8 +77,8 @@ val mavenBinary by configurations.registering { } tasks.clean { - delete(setupMavenProperties.mavenBuildDir) - delete(setupMavenProperties.mavenInstallDir) + delete(mavenCliSetupExtension.mavenBuildDir) + delete(mavenCliSetupExtension.mavenInstallDir) } val installMavenBinary by tasks.registering(Sync::class) { @@ -99,5 +99,5 @@ val installMavenBinary by tasks.registering(Sync::class) { } includeEmptyDirs = false } - into(setupMavenProperties.mavenInstallDir) + into(mavenCliSetupExtension.mavenInstallDir) } diff --git a/build-logic/src/main/kotlin/org/jetbrains/internal/gradleKotlinDslAccessors.kt b/build-logic/src/main/kotlin/org/jetbrains/internal/gradleKotlinDslAccessors.kt index 78bbc568..cb8d0df8 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/internal/gradleKotlinDslAccessors.kt +++ b/build-logic/src/main/kotlin/org/jetbrains/internal/gradleKotlinDslAccessors.kt @@ -3,6 +3,7 @@ package org.gradle.kotlin.dsl // for convenience use a default package for gradle.kts scripts import org.gradle.api.Project +import org.gradle.accessors.dm.LibrariesForLibs import org.jetbrains.DokkaBuildProperties /* @@ -14,6 +15,15 @@ import org.jetbrains.DokkaBuildProperties * `internal` */ + +/** + * workaround for accessing version-catalog in convention plugins + * + * See https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 + */ +internal val Project.libs : LibrariesForLibs + get() = extensions.getByType() + /** * Retrieves the [dokkaBuild][org.jetbrains.DokkaBuildProperties] extension. */ diff --git a/build-logic/src/main/kotlin/org/jetbrains/publication.kt b/build-logic/src/main/kotlin/org/jetbrains/publication.kt index 60d91c33..32e34dca 100644 --- a/build-logic/src/main/kotlin/org/jetbrains/publication.kt +++ b/build-logic/src/main/kotlin/org/jetbrains/publication.kt @@ -2,13 +2,9 @@ package org.jetbrains import com.github.jengelman.gradle.plugins.shadow.ShadowExtension import org.gradle.api.Project -import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.publish.maven.tasks.PublishToMavenRepository -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Jar import org.gradle.kotlin.dsl.* import org.gradle.plugins.signing.SigningExtension import org.jetbrains.DokkaPublicationChannel.* @@ -24,7 +20,10 @@ class DokkaPublicationBuilder { } -fun Project.registerDokkaArtifactPublication(publicationName: String, configure: DokkaPublicationBuilder.() -> Unit) { +fun Project.registerDokkaArtifactPublication( + publicationName: String, + configure: DokkaPublicationBuilder.() -> Unit +) { configure<PublishingExtension> { publications { register<MavenPublication>(publicationName) { @@ -143,9 +142,10 @@ private fun Project.signPublicationsIfKeyPresent(vararg publications: String) { useInMemoryPgpKeys(signingKey, signingKeyPassphrase) } publications.forEach { publicationName -> - extensions.findByType(PublishingExtension::class)!!.publications.findByName(publicationName)?.let { - sign(it) - } + extensions.getByType<PublishingExtension>() + .publications + .findByName(publicationName) + ?.let { sign(it) } } } } |