Skip to content

Commit

Permalink
build: Add Gradle Nexus Publish Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wba2hi committed Jan 31, 2025
1 parent 0192d8f commit b5e5276
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
run: ./gradlew publishAllPublicationsToOSSRHReleaseRepository
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
2 changes: 1 addition & 1 deletion .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
run: ./gradlew publishAllPublicationsToOSSRHSnapshotRepository
run: ./gradlew publishToSonatype
16 changes: 15 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2023 - 2025 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.
Expand All @@ -19,6 +19,7 @@

import com.android.build.api.dsl.LibraryExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import org.eclipse.kuksa.version.SemanticVersion
import org.eclipse.kuksa.version.VERSION_FILE_DEFAULT_NAME
import org.eclipse.kuksa.version.VERSION_FILE_DEFAULT_PATH_KEY
import java.nio.file.FileVisitResult
Expand All @@ -34,13 +35,26 @@ import kotlin.io.path.visitFileTree

val versionDefaultPath = "$rootDir/$VERSION_FILE_DEFAULT_NAME"
rootProject.ext[VERSION_FILE_DEFAULT_PATH_KEY] = versionDefaultPath
val semanticVersion = SemanticVersion(versionDefaultPath)
version = semanticVersion.versionName
group = "org.eclipse.velocitas"

plugins {
base
detekt
version
kotlin("jvm")
jacoco
alias(libs.plugins.gradle.nexus.publish.plugin)
}

nexusPublishing {
repositories {
sonatype {
username = System.getenv("ORG_OSSRH_USERNAME")
password = System.getenv("ORG_OSSRH_PASSWORD")
}
}
}

subprojects {
Expand Down
25 changes: 4 additions & 21 deletions buildSrc/src/main/kotlin/publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2023 - 2025 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.
Expand All @@ -23,6 +23,9 @@ plugins {
}

interface PublishPluginExtension {
val artifactGroup: Property<String>
val artifactName: Property<String>
val artifactVersion: Property<String>
val mavenPublicationName: Property<String>
val componentName: Property<String>
val description: Property<String>
Expand All @@ -32,26 +35,6 @@ val extension = project.extensions.create<PublishPluginExtension>("publish")

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 {
register<MavenPublication>(extension.mavenPublicationName.get()) {
from(components[extension.componentName.get()])
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ detekt-gradlePlugin = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gr
detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" }

[plugins]
gradle-nexus-publish-plugin = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }

0 comments on commit b5e5276

Please sign in to comment.