Skip to content

Commit

Permalink
build: deactivate signing by default for everything that is published (
Browse files Browse the repository at this point in the history
…#82)

Signed-off-by: Jendrik Johannes <jendrik.johannes@gmail.com>
  • Loading branch information
jjohannes authored Jan 16, 2025
1 parent 870bbc3 commit b6e7a5d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ java {
val publishSigningEnabled =
providers.gradleProperty("publishSigningEnabled").getOrElse("false").toBoolean()

if (publishSigningEnabled) {
signing {
sign(publishing.publications)
useGpgCmd()
}
tasks.withType<Sign>().configureEach { enabled = publishSigningEnabled }

signing {
sign(publishing.publications)
useGpgCmd()
}

publishing.publications.withType<MavenPublication>().configureEach {
Expand Down
34 changes: 34 additions & 0 deletions src/test/kotlin/org/hiero/gradle/test/LocalPublishTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
package org.hiero.gradle.test

import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.TaskOutcome
import org.hiero.gradle.test.fixtures.GradleProject
import org.junit.jupiter.api.Test

class LocalPublishTest {

@Test
fun `can perform a local publish of library without signing keys`() {
val p = GradleProject().withMinimalStructure()
p.moduleBuildFile("""plugins { id("org.hiero.gradle.module.library") }""")

val result = p.run("publishToMavenLocal -Dmaven.repo.local=${p.file(".m2").absolutePath}")

assertThat(result.task(":module-a:publishMavenPublicationToMavenLocal")?.outcome)
.isEqualTo(TaskOutcome.SUCCESS)
assertThat(p.file(".m2/org/example/module-a/1.0/module-a-1.0.jar")).exists()
}

@Test
fun `can perform a local publish of gradle plugin without signing keys`() {
val p = GradleProject().withMinimalStructure()
p.moduleBuildFile("""plugins { id("org.hiero.gradle.module.gradle-plugin") }""")

val result = p.run("publishToMavenLocal -Dmaven.repo.local=${p.file(".m2").absolutePath}")

assertThat(result.task(":module-a:publishPluginMavenPublicationToMavenLocal")?.outcome)
.isEqualTo(TaskOutcome.SUCCESS)
assertThat(p.file(".m2/org/example/module-a/1.0/module-a-1.0.jar")).exists()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MavenCentralPublishTest {
id("org.hiero.gradle.feature.publish-artifactregistry")
}
"""
.trimMargin()
.trimIndent()
)

// We should not get: 'No staging repository with name sonatype created'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PublishDependencyConstraintsTest {
publishDependencyConstraint("io.grpc:grpc-netty")
}
"""
.trimMargin()
.trimIndent()
)

p.run("generateMetadataFileForMavenPublication")
Expand Down

0 comments on commit b6e7a5d

Please sign in to comment.