Skip to content

Commit

Permalink
build: stopped using third party maven publish plugin and switched to…
Browse files Browse the repository at this point in the history
… official plugin instead
  • Loading branch information
janniclas committed Oct 22, 2024
1 parent fbe829b commit 062a47b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 95 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,14 @@ jobs:
ref: ${{ env.SPHA_VERSION }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
with:
dependency-graph: generate-and-submit

- name: Publish to OSSRH
env:
GITHUB_DEPENDENCY_GRAPH_REF: refs/heads/main
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PW }}
ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: true
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
SONATYPE_CONNECT_TIMEOUT_SECONDS: 300
run: ./gradlew publishAllPublicationsToMavenCentralRepository
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
run: ./gradlew publish

- name: Generate Release Notes
run: ./gradlew -q printChangeLog > RELEASE_NOTES.md
Expand Down
1 change: 0 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ repositories {

dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.plugin.mavenPublish)
implementation(libs.plugin.dokkatoo)
implementation(libs.plugin.kotlin)
implementation(libs.plugin.ktfmt)
Expand Down
87 changes: 55 additions & 32 deletions buildSrc/src/main/kotlin/spha-kotlin-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,76 @@
* License-Filename: LICENSE
*/

import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import org.gradle.accessors.dm.LibrariesForLibs

private val Project.libs: LibrariesForLibs
get() = extensions.getByType()

plugins {
// Apply core plugins.
jacoco
`java-library`
`maven-publish`
signing
jacoco
id("dev.adamko.dokkatoo")
kotlin("jvm")
id("com.ncorti.ktfmt.gradle")
id("spha-release-conventions")
kotlin("jvm")
}

repositories { mavenCentral() }

mavenPublishing {
configure(
KotlinJvm(
// configures the -javadoc artifact, possible values:
// - `JavadocJar.None()` don't publish this artifact
// - `JavadocJar.Empty()` publish an empty jar
// - `JavadocJar.Dokka("dokkaHtml")` when using Kotlin with Dokka, where `dokkaHtml` is
// the name of the Dokka task that should be used as input
javadocJar = JavadocJar.Dokka("dokkatooGeneratePublicationJavadoc"),
// whether to publish a sources jar
sourcesJar = true,
)
)
// mavenPublishing {
// configure(
// KotlinJvm(
// // configures the -javadoc artifact, possible values:
// // - `JavadocJar.None()` don't publish this artifact
// // - `JavadocJar.Empty()` publish an empty jar
// // - `JavadocJar.Dokka("dokkaHtml")` when using Kotlin with Dokka, where `dokkaHtml`
// is
// // the name of the Dokka task that should be used as input
// javadocJar = JavadocJar.Dokka("dokkatooGeneratePublicationJavadoc"),
// // whether to publish a sources jar
// sourcesJar = true,
// )
// )
// }

java {
withJavadocJar()
withSourcesJar()
toolchain { languageVersion = JavaLanguageVersion.of(21) }
}

java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "de.fraunhofer.iem"
artifactId = "spha-${project.name}"
from(components["java"])
}
}
repositories {
maven {
name = "mavenCentral"
val releasesRepoUrl =
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url =
uri(
if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl
else releasesRepoUrl
)
credentials(PasswordCredentials::class)
}
}
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["maven"])
}

kotlin {
compilerOptions { apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0) }
Expand Down Expand Up @@ -81,16 +116,4 @@ tasks.register("jacocoReport") {
dependsOn(tasks.withType<JacocoReport>())
}

tasks.register<Jar>("javadocJar") {
description = "Assembles a JAR containing the Javadoc documentation."
group = "Documentation"

dependsOn(tasks.dokkatooGeneratePublicationJavadoc)
from(tasks.dokkatooGeneratePublicationJavadoc.flatMap { it.outputDirectory })
archiveClassifier = "javadoc"
}

if (project != rootProject)
version =
rootProject
.version
if (project != rootProject) version = rootProject.version
54 changes: 0 additions & 54 deletions buildSrc/src/main/kotlin/spha-release-conventions.gradle.kts

This file was deleted.

0 comments on commit 062a47b

Please sign in to comment.