From 32276336de066d20698fc4b6aa4ce4739f500af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Hu=CC=88sers?= Date: Fri, 2 Feb 2024 16:13:38 +0100 Subject: [PATCH] chore: Switch to gradle publish plugin --- .github/workflows/deploy-snapshot.yaml | 2 +- buildSrc/build.gradle.kts | 2 +- gradle/libs.versions.toml | 1 + vss-processor-plugin/build.gradle.kts | 112 ++++++++++-- .../src/main/kotlin/publish.gradle.kts | 163 +++++++++--------- vss-processor-plugin/settings.gradle.kts | 42 +++++ .../vssprocessor/plugin/VssProcessorPlugin.kt | 8 +- 7 files changed, 234 insertions(+), 96 deletions(-) create mode 100644 vss-processor-plugin/settings.gradle.kts diff --git a/.github/workflows/deploy-snapshot.yaml b/.github/workflows/deploy-snapshot.yaml index 89c05d83..e2288bb1 100644 --- a/.github/workflows/deploy-snapshot.yaml +++ b/.github/workflows/deploy-snapshot.yaml @@ -5,7 +5,7 @@ concurrency: snapshot on: push: branches: - - main + - feature-45-work jobs: deployment: diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index cf8e4b48..ebcfe519 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -8,7 +8,7 @@ * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the Lice nse is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6ca333f8..8565a265 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -71,3 +71,4 @@ grpc-protoc-java-gen = { group = "io.grpc", name = "protoc-gen-grpc-java", versi [plugins] dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" } +pluginPublishing = { id = "com.gradle.plugin-publish", version = "1.2.1" } diff --git a/vss-processor-plugin/build.gradle.kts b/vss-processor-plugin/build.gradle.kts index e373bab5..09ac1027 100644 --- a/vss-processor-plugin/build.gradle.kts +++ b/vss-processor-plugin/build.gradle.kts @@ -17,35 +17,119 @@ * */ -repositories { - gradlePluginPortal() - google() - mavenCentral() -} - plugins { + alias(libs.plugins.pluginPublishing) + signing `kotlin-dsl` - `java-gradle-plugin` - publish +// publish version } +group = "org.eclipse.kuksa" +version = rootProject.extra["projectVersion"].toString() + gradlePlugin { + website.set("https://github.com/eclipse-kuksa/kuksa-android-sdk") + vcsUrl.set("https://github.com/eclipse-kuksa/kuksa-android-sdk") plugins { create("VssProcessorPlugin") { id = "org.eclipse.kuksa.vss-processor-plugin" implementationClass = "org.eclipse.kuksa.vssprocessor.plugin.VssProcessorPlugin" + displayName = "Vss Processor Plugin" + tags.set(listOf("KUKSA", "Vehicle Signal Specification", "VSS", "android", "kotlin")) + description = "Vehicle Signal Specification (VSS) Plugin of the KUKSA SDK. This is used in combination " + + "with the KSP processor component 'KUKSA VSS Processor'. The plugin is configured to provide " + + "VSS Files to KSP processor. This is mandatory to use the 'KUKSA VSS Processor' component." } } } -group = "org.eclipse.kuksa" -version = rootProject.extra["projectVersion"].toString() +afterEvaluate { + publishing { + repositories { + maven { + name = "OSSRHRelease" -dependencies { - implementation(kotlin("stdlib")) + url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = System.getenv("ORG_OSSRH_USERNAME") + password = System.getenv("ORG_OSSRH_PASSWORD") + } + } + maven { + name = "OSSRHSnapshot" + + url = uri("https://oss.sonatype.org/content/repositories/snapshots/") + credentials { + username = System.getenv("ORG_OSSRH_USERNAME") + password = System.getenv("ORG_OSSRH_PASSWORD") + } + } + } + publications { + getByName("pluginMaven") { + pom { + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + name = "Mark Hüsers" + email = "mark.huesers@etas.com" + organization = "ETAS GmbH" + organizationUrl = "https://www.etas.com" + } + developer { + name = "Sebastian Schildt" + email = "sebastian.schildt@etas.com" + organization = "ETAS GmbH" + organizationUrl = "https://www.etas.com" + } + developer { + name = "Andre Weber" + email = "andre.weber3@etas.com" + organization = "ETAS GmbH" + organizationUrl = "https://www.etas.com" + } + } + scm { + connection.set("scm:git:github.com/eclipse-kuksa/kuksa-android-sdk.git") + developerConnection.set("scm:git:ssh://github.com/eclipse-kuksa/kuksa-android-sdk.git") + url.set("https://github.com/eclipse-kuksa/kuksa-android-sdk/tree/main") + } + } + } + } + } + + signing { + var keyId: String? = System.getenv("ORG_GPG_KEY_ID") + if (keyId != null && keyId.length > 8) { + keyId = keyId.takeLast(8) + } + val privateKey = System.getenv("ORG_GPG_PRIVATE_KEY") + val passphrase = System.getenv("ORG_GPG_PASSPHRASE") + + useInMemoryPgpKeys( + keyId, + privateKey, + passphrase, + ) + + sign(publishing.publications) + + setRequired({ + val publishToMavenLocalTask = gradle.taskGraph.allTasks.find { it.name.contains("ToMavenLocal") } + val isPublishingToMavenLocal = publishToMavenLocalTask != null + + !isPublishingToMavenLocal // disable signing when publishing to MavenLocal + }) + } } -publish { - description = "Vehicle Signal Specification (VSS) Plugin of the KUKSA SDK" +dependencies { + implementation(kotlin("stdlib")) } diff --git a/vss-processor-plugin/buildSrc/src/main/kotlin/publish.gradle.kts b/vss-processor-plugin/buildSrc/src/main/kotlin/publish.gradle.kts index 0c70a75f..c1ffd499 100644 --- a/vss-processor-plugin/buildSrc/src/main/kotlin/publish.gradle.kts +++ b/vss-processor-plugin/buildSrc/src/main/kotlin/publish.gradle.kts @@ -18,7 +18,7 @@ */ plugins { - `maven-publish` +// id("com.gradle.plugin-publish") signing } @@ -28,82 +28,87 @@ interface PublishPluginExtension { val extension = project.extensions.create("publish") -afterEvaluate { - publishing { - repositories { - maven { - name = "OSSRHRelease" +//afterEvaluate { +// publishing { +// repositories { +// maven { +// name = "OSSRHRelease" +// +// url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") +// credentials { +// username = System.getenv("ORG_OSSRH_USERNAME") +// password = System.getenv("ORG_OSSRH_PASSWORD") +// } +// } +// maven { +// name = "OSSRHSnapshot" +// +// url = uri("https://oss.sonatype.org/content/repositories/snapshots/") +// credentials { +// username = System.getenv("ORG_OSSRH_USERNAME") +// password = System.getenv("ORG_OSSRH_PASSWORD") +// } +// } +// } +// publications { +// getByName("pluginMaven") { +// pom { +// name = "${project.group}:${project.name}" +// description = extension.description.get() +// url = "https://github.com/eclipse-kuksa/kuksa-android-sdk" +// licenses { +// license { +// name.set("The Apache Software License, Version 2.0") +// url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") +// } +// } +// developers { +// developer { +// name = "Mark Hüsers" +// email = "mark.huesers@etas.com" +// organization = "ETAS GmbH" +// organizationUrl = "https://www.etas.com" +// } +// developer { +// name = "Sebastian Schildt" +// email = "sebastian.schildt@etas.com" +// organization = "ETAS GmbH" +// organizationUrl = "https://www.etas.com" +// } +// developer { +// name = "Andre Weber" +// email = "andre.weber3@etas.com" +// organization = "ETAS GmbH" +// organizationUrl = "https://www.etas.com" +// } +// } +// scm { +// connection.set("scm:git:github.com/eclipse-kuksa/kuksa-android-sdk.git") +// developerConnection.set("scm:git:ssh://github.com/eclipse-kuksa/kuksa-android-sdk.git") +// url.set("https://github.com/eclipse-kuksa/kuksa-android-sdk/tree/main") +// } +// } +// } +// } +// } +// +// signing { +// var keyId: String? = System.getenv("ORG_GPG_KEY_ID") +// if (keyId != null && keyId.length > 8) { +// keyId = keyId.takeLast(8) +// } +// val privateKey = System.getenv("ORG_GPG_PRIVATE_KEY") +// val passphrase = System.getenv("ORG_GPG_PASSPHRASE") +// +// useInMemoryPgpKeys( +// keyId, +// privateKey, +// passphrase, +// ) +// } +//} - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("ORG_OSSRH_USERNAME") - password = System.getenv("ORG_OSSRH_PASSWORD") - } - } - maven { - name = "OSSRHSnapshot" - - url = uri("https://oss.sonatype.org/content/repositories/snapshots/") - credentials { - username = System.getenv("ORG_OSSRH_USERNAME") - password = System.getenv("ORG_OSSRH_PASSWORD") - } - } - } - publications { - getByName("pluginMaven") { - pom { - name = "${project.group}:${project.name}" - description = extension.description.get() - url = "https://github.com/eclipse-kuksa/kuksa-android-sdk" - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - developers { - developer { - name = "Mark Hüsers" - email = "mark.huesers@etas.com" - organization = "ETAS GmbH" - organizationUrl = "https://www.etas.com" - } - developer { - name = "Sebastian Schildt" - email = "sebastian.schildt@etas.com" - organization = "ETAS GmbH" - organizationUrl = "https://www.etas.com" - } - developer { - name = "Andre Weber" - email = "andre.weber3@etas.com" - organization = "ETAS GmbH" - organizationUrl = "https://www.etas.com" - } - } - scm { - connection.set("scm:git:github.com/eclipse-kuksa/kuksa-android-sdk.git") - developerConnection.set("scm:git:ssh://github.com/eclipse-kuksa/kuksa-android-sdk.git") - url.set("https://github.com/eclipse-kuksa/kuksa-android-sdk/tree/main") - } - } - } - } - } - - signing { - var keyId: String? = System.getenv("ORG_GPG_KEY_ID") - if (keyId != null && keyId.length > 8) { - keyId = keyId.takeLast(8) - } - val privateKey = System.getenv("ORG_GPG_PRIVATE_KEY") - val passphrase = System.getenv("ORG_GPG_PASSPHRASE") - - useInMemoryPgpKeys( - keyId, - privateKey, - passphrase, - ) - } -} +//gradlePlugin { +// website = "" +// vcsUrl = "" +//} diff --git a/vss-processor-plugin/settings.gradle.kts b/vss-processor-plugin/settings.gradle.kts new file mode 100644 index 00000000..2f92194d --- /dev/null +++ b/vss-processor-plugin/settings.gradle.kts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + mavenLocal() + google() + mavenCentral() + } + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} + +rootProject.name = "vss-processor-plugin" diff --git a/vss-processor-plugin/src/main/java/org/eclipse/kuksa/vssprocessor/plugin/VssProcessorPlugin.kt b/vss-processor-plugin/src/main/java/org/eclipse/kuksa/vssprocessor/plugin/VssProcessorPlugin.kt index b55e9ad1..092b142d 100644 --- a/vss-processor-plugin/src/main/java/org/eclipse/kuksa/vssprocessor/plugin/VssProcessorPlugin.kt +++ b/vss-processor-plugin/src/main/java/org/eclipse/kuksa/vssprocessor/plugin/VssProcessorPlugin.kt @@ -36,9 +36,15 @@ open class VssProcessorPluginExtension @Inject internal constructor(objectFactory: ObjectFactory) { /** - * The default search path is the main assets folder. If + * The default search path is the main assets folder. The defined folder will be crawled for all compatible + * extension types by this plugin. */ val searchPath: Property = objectFactory.property(String::class.java).convention("") + + /** + * If no file name is provided then all compatible files inside the [searchPath] will be copied. Otherwise only + * the defined file will be used if available. + */ val fileName: Property = objectFactory.property(String::class.java).convention("") }