From ed0eab355bfd61b9b1819951991c85a6bc2e3a52 Mon Sep 17 00:00:00 2001 From: makeevrserg Date: Thu, 30 May 2024 23:42:09 +0300 Subject: [PATCH] kmp signing plugin --- README.md | 1 + .../plugins/convention/build.gradle.kts | 7 +++++++ .../gradleplugin/SigningPublicationPlugin.kt | 20 +++++++++++++++++++ gradle/libs.versions.toml | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 build-logic/plugins/convention/src/main/kotlin/ru/astrainteractive/gradleplugin/SigningPublicationPlugin.kt diff --git a/README.md b/README.md index 52de9b6..12e7e27 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ klibs-gradle-dokka-module = { id = "ru.astrainteractive.gradleplugin.dokka.modul klibs-gradle-java-core = { id = "ru.astrainteractive.gradleplugin.java.core", version.ref = "klibs-gradleplugin" } klibs-gradle-stub-javadoc = { id = "ru.astrainteractive.gradleplugin.stub.javadoc", version.ref = "klibs-gradleplugin" } klibs-gradle-publication = { id = "ru.astrainteractive.gradleplugin.publication", version.ref = "klibs-gradleplugin" } +klibs-gradle-kmp-signing = { id = "ru.astrainteractive.gradleplugin.kmp-signing", version.ref = "klibs-gradleplugin" } klibs-gradle-rootinfo = { id = "ru.astrainteractive.gradleplugin.root.info", version.ref = "klibs-gradleplugin" } # klibs - android klibs-gradle-android-core = { id = "ru.astrainteractive.gradleplugin.android.core", version.ref = "klibs-gradleplugin" } diff --git a/build-logic/plugins/convention/build.gradle.kts b/build-logic/plugins/convention/build.gradle.kts index bb1c5a9..e3c03e8 100644 --- a/build-logic/plugins/convention/build.gradle.kts +++ b/build-logic/plugins/convention/build.gradle.kts @@ -77,5 +77,12 @@ gradlePlugin { description = "Default pulbication plugin" tags.set(listOf("klibs")) } + create("publication.kmp-signing") { + id = "$group.$name" + implementationClass = "$group.SigningPublicationPlugin" + displayName = "KLibs publication signing plugin" + description = "Default pulbication signing plugin" + tags.set(listOf("klibs")) + } } } diff --git a/build-logic/plugins/convention/src/main/kotlin/ru/astrainteractive/gradleplugin/SigningPublicationPlugin.kt b/build-logic/plugins/convention/src/main/kotlin/ru/astrainteractive/gradleplugin/SigningPublicationPlugin.kt new file mode 100644 index 0000000..7baafb5 --- /dev/null +++ b/build-logic/plugins/convention/src/main/kotlin/ru/astrainteractive/gradleplugin/SigningPublicationPlugin.kt @@ -0,0 +1,20 @@ +package ru.astrainteractive.gradleplugin + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven +import org.gradle.kotlin.dsl.withType +import org.gradle.plugins.signing.Sign + +class SigningPublicationPlugin : Plugin { + + override fun apply(target: Project) { + target.afterEvaluate { + target.tasks + .withType() + .forEach { publishTask -> + target.tasks.withType().forEach(publishTask::mustRunAfter) + } + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b7fdf10..de1f8a4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ project-description = "GradlePlugin for my kotlin projects" project-group = "ru.astrainteractive.gradleplugin" project-web = "https://github.com/makeevrserg/gradle-plugin" project-version-code = "4" -project-version-string = "1.1.2" +project-version-string = "1.2.0" # Kotlin kotlin-version = "2.0.0" # https://github.com/JetBrains/kotlin kotlin-dokka = "1.9.20" # https://github.com/Kotlin/dokka