Skip to content

Commit

Permalink
fix: sign when publishing to central / metadata for all publications (#…
Browse files Browse the repository at this point in the history
…116)

Signed-off-by: Jendrik Johannes <jendrik.johannes@gmail.com>
  • Loading branch information
jjohannes authored Nov 13, 2023
1 parent 1bfd67b commit d2eb8a7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ plugins {
id("com.hedera.pbj.spotless-conventions")
id("com.hedera.pbj.spotless-java-conventions")
id("com.hedera.pbj.spotless-kotlin-conventions")
id("com.hedera.pbj.maven-publish")
}

group = "com.hedera.pbj"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,46 +60,10 @@ publishing {
}
}
}
repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
maven {
name = "sonatypeSnapshot"
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
}

signing { useGpgCmd() }

tasks.withType<Sign> {
onlyIf { providers.gradleProperty("publishSigningEnabled").getOrElse("false").toBoolean() }
}

tasks.register("release-maven-central") {
group = "release"
dependsOn(
tasks.withType<PublishToMavenRepository>().matching {
it.name.endsWith("ToSonatypeRepository")
}
)
}

tasks.register("release-maven-central-snapshot") {
group = "release"
dependsOn(
tasks.withType<PublishToMavenRepository>().matching {
it.name.endsWith("ToSonatypeSnapshotRepository")
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ plugins {
id("java-library")
id("com.hedera.pbj.conventions")
id("com.google.protobuf") // protobuf plugin is only used for tests
id("com.hedera.pbj.maven-publish")
}

tasks.generateGrammarSource {
Expand All @@ -33,4 +32,45 @@ protobuf {
}
}

publishing { publications.create<MavenPublication>("maven") { from(components["java"]) } }
val maven = publishing.publications.create<MavenPublication>("maven") { from(components["java"]) }

signing.sign(maven)

publishing {
repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
maven {
name = "sonatypeSnapshot"
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
}

tasks.register("release-maven-central") {
group = "release"
dependsOn(
tasks.withType<PublishToMavenRepository>().matching {
it.name.endsWith("ToSonatypeRepository")
}
)
}

tasks.register("release-maven-central-snapshot") {
group = "release"
dependsOn(
tasks.withType<PublishToMavenRepository>().matching {
it.name.endsWith("ToSonatypeSnapshotRepository")
}
)
}

0 comments on commit d2eb8a7

Please sign in to comment.