aboutsummaryrefslogtreecommitdiff
path: root/build-logic/src
diff options
context:
space:
mode:
authoraSemy <897017+aSemy@users.noreply.github.com>2023-03-17 15:27:03 +0100
committerGitHub <noreply@github.com>2023-03-17 15:27:03 +0100
commit8bb4f4a86b131e9740a8074cb5775930f8280019 (patch)
tree2fea9f93d621d1a2c72129358a45a565cca68e6c /build-logic/src
parent2a3917b7eb70b39360893b61f5cd7f580c41cfda (diff)
downloaddokka-8bb4f4a86b131e9740a8074cb5775930f8280019.tar.gz
dokka-8bb4f4a86b131e9740a8074cb5775930f8280019.tar.bz2
dokka-8bb4f4a86b131e9740a8074cb5775930f8280019.zip
Introduce Gradle Version Catalog with type-safe project dependencies (#2884)
Diffstat (limited to 'build-logic/src')
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/conventions/maven-cli-setup.gradle.kts18
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/internal/gradleKotlinDslAccessors.kt10
-rw-r--r--build-logic/src/main/kotlin/org/jetbrains/publication.kt16
3 files changed, 27 insertions, 17 deletions
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) }
}
}
}