Skip to content

Commit

Permalink
chore: Switch to gradle publish plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrylo committed Feb 2, 2024
1 parent e997a91 commit 3227633
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ concurrency: snapshot
on:
push:
branches:
- main
- feature-45-work

jobs:
deployment:
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
112 changes: 98 additions & 14 deletions vss-processor-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MavenPublication>("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"))
}
163 changes: 84 additions & 79 deletions vss-processor-plugin/buildSrc/src/main/kotlin/publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

plugins {
`maven-publish`
// id("com.gradle.plugin-publish")
signing
}

Expand All @@ -28,82 +28,87 @@ interface PublishPluginExtension {

val extension = project.extensions.create<PublishPluginExtension>("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<MavenPublication>("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<MavenPublication>("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 = "<substitute your project website>"
// vcsUrl = "<uri to project source repository>"
//}
42 changes: 42 additions & 0 deletions vss-processor-plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = 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<String> = objectFactory.property(String::class.java).convention("")
}

Expand Down

0 comments on commit 3227633

Please sign in to comment.