From 022f3fc907fe9ada48ac486bc8683f1340e54a35 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Mon, 16 Sep 2024 09:51:27 +0200 Subject: [PATCH] build: generalize publishing setup Do not have 'hedera-services' specifics in plugins so that they may be reused without modification in other repositories. For this, we introduce two files in the folder for each "product" - developers.properties - description.txt (optional) See changes in the PR for what these files contain. Signed-off-by: Jendrik Johannes --- .../node-zxc-build-release-artifact.yaml | 4 +- developers.properties | 6 ++ ...com.hedera.gradle.maven-publish.gradle.kts | 74 +++++++++++++++---- ...com.hedera.gradle.nexus-publish.gradle.kts | 9 +-- ....hedera.gradle.platform-publish.gradle.kts | 44 ----------- ....hedera.gradle.services-publish.gradle.kts | 41 ---------- hedera-node/developers.properties | 4 + platform-sdk/description.txt | 3 + platform-sdk/developers.properties | 4 + 9 files changed, 83 insertions(+), 106 deletions(-) create mode 100644 developers.properties create mode 100644 hedera-node/developers.properties create mode 100644 platform-sdk/description.txt create mode 100644 platform-sdk/developers.properties diff --git a/.github/workflows/node-zxc-build-release-artifact.yaml b/.github/workflows/node-zxc-build-release-artifact.yaml index d131535c5171..84bd5c653710 100644 --- a/.github/workflows/node-zxc-build-release-artifact.yaml +++ b/.github/workflows/node-zxc-build-release-artifact.yaml @@ -871,7 +871,7 @@ jobs: NEXUS_PASSWORD: ${{ secrets.sdk-ossrh-password }} with: gradle-version: ${{ inputs.gradle-version }} - arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.swirlds --scan -PpublishSigningEnabled=true --no-configuration-cache" + arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.swirlds -Ps01SonatypeHost=true -PpublishSigningEnabled=true --scan --no-configuration-cache" - name: Gradle Publish Services to ${{ inputs.version-policy == 'specified' && 'Maven Central' || 'Google Artifact Registry' }} (${{ inputs.release-profile }}) uses: gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3.1.0 @@ -881,7 +881,7 @@ jobs: NEXUS_PASSWORD: ${{ secrets.svcs-ossrh-password }} with: gradle-version: ${{ inputs.gradle-version }} - arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.hedera --scan -PpublishSigningEnabled=true --no-configuration-cache" + arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.hedera.hashgraph -PpublishSigningEnabled=true --scan --no-configuration-cache" - name: Upload SDK Release Archives if: ${{ inputs.dry-run-enabled != true && inputs.version-policy == 'specified' && !cancelled() && !failure() }} diff --git a/developers.properties b/developers.properties new file mode 100644 index 000000000000..d029ffc679cd --- /dev/null +++ b/developers.properties @@ -0,0 +1,6 @@ +# This file is here for 'hapi', because that "product" is missing the toplevel folder +# (it contains the 'hapi' module directly) +hedera-base@hashgraph.com=Hedera Base Team +hedera-services@hashgraph.com=Hedera Services Team +hedera-smart-contracts@hashgraph.com=Hedera Smart Contracts Team +release-engineering@hashgraph.com=Release Engineering Team diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.maven-publish.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.maven-publish.gradle.kts index fbc9dd85100f..293350cfc431 100644 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.maven-publish.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com.hedera.gradle.maven-publish.gradle.kts @@ -14,12 +14,21 @@ * limitations under the License. */ +import java.util.Properties + plugins { id("java") id("maven-publish") id("signing") } +tasks.withType().configureEach { + // Publishing tasks are only enabled if we publish to the matching group. + // Otherwise, Nexus configuration and credentials do not fit. + val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").orNull + enabled = publishingPackageGroup == project.group +} + java { withJavadocJar() withSourcesJar() @@ -42,32 +51,69 @@ val maven = allVariants { fromResolutionResult() } } + suppressAllPomMetadataWarnings() + pom { - packaging = findProperty("maven.project.packaging")?.toString() ?: "jar" - name.set(project.name) - url.set("https://www.swirlds.com/") - inceptionYear.set("2016") + val devGroups = Properties() + val developerProperties = layout.projectDirectory.file("../developers.properties") + devGroups.load( + providers + .fileContents(developerProperties) + .asText + .orElse( + provider { + throw RuntimeException("${developerProperties.asFile} does not exist") + } + ) + .get() + .reader() + ) + + url = "https://www.hashgraph.com/" + inceptionYear = "2016" - description.set(provider(project::getDescription)) + description = + providers + .fileContents(layout.projectDirectory.file("../description.txt")) + .asText + .orElse(provider { project.description }) + .map { it.replace("\n", " ").trim() } + .orNull organization { - name.set("Hedera Hashgraph, LLC") - url.set("https://www.hedera.com") + name = "Hedera Hashgraph, LLC" + url = "https://www.hedera.com" + } + + val repoName = isolated.rootProject.name + + issueManagement { + system = "GitHub" + url = "https://github.com/hashgraph/$repoName/issues" } licenses { license { - name.set("Apache License, Version 2.0") - url.set( - "https://raw.githubusercontent.com/hashgraph/hedera-services/main/LICENSE" - ) + name = "Apache License, Version 2.0" + url = "https://raw.githubusercontent.com/hashgraph/$repoName/main/LICENSE" } } scm { - connection.set("scm:git:git://github.com/hashgraph/hedera-services.git") - developerConnection.set("scm:git:ssh://github.com:hashgraph/hedera-services.git") - url.set("https://github.com/hashgraph/hedera-services") + connection = "scm:git:git://github.com/hashgraph/$repoName.git" + developerConnection = "scm:git:ssh://github.com:hashgraph/$repoName.git" + url = "https://github.com/hashgraph/$repoName" + } + + developers { + devGroups.forEach { mail, team -> + developer { + name = team as String + email = mail as String + organization = "Hedera Hashgraph" + organizationUrl = "https://www.hedera.com" + } + } } } } diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.nexus-publish.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.nexus-publish.gradle.kts index 182be0a43f10..429566cb793a 100644 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.nexus-publish.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com.hedera.gradle.nexus-publish.gradle.kts @@ -19,16 +19,15 @@ plugins { id("io.github.gradle-nexus.publish-plugin") } -val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("") -val isPlatformPublish = publishingPackageGroup == "com.swirlds" - nexusPublishing { - packageGroup = publishingPackageGroup + val s01SonatypeHost = providers.gradleProperty("s01SonatypeHost").getOrElse("false").toBoolean() + packageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("") + repositories { sonatype { username = System.getenv("NEXUS_USERNAME") password = System.getenv("NEXUS_PASSWORD") - if (isPlatformPublish) { + if (s01SonatypeHost) { nexusUrl = uri("https://s01.oss.sonatype.org/service/local/") snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.platform-publish.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.platform-publish.gradle.kts index 79fd23a0ad23..e2983169da5f 100644 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.platform-publish.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com.hedera.gradle.platform-publish.gradle.kts @@ -31,50 +31,6 @@ if ( apply(plugin = "com.google.cloud.artifactregistry.gradle-plugin") } -// Publishing tasks are only enabled if we publish to the matching group. -// Otherwise, Nexus configuration and credentials do not fit. -val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("") - -tasks.withType().configureEach { - enabled = publishingPackageGroup == "com.swirlds" -} - -publishing.publications.named("maven") { - pom.description = - "Swirlds is a software platform designed to build fully-distributed " + - "applications that harness the power of the cloud without servers. " + - "Now you can develop applications with fairness in decision making, " + - "speed, trust and reliability, at a fraction of the cost of " + - "traditional server-based platforms." - - pom.developers { - developer { - name = "Platform Base Team" - email = "platform-base@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - developer { - name = "Platform Hashgraph Team" - email = "platform-hashgraph@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - developer { - name = "Platform Data Team" - email = "platform-data@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - developer { - name = "Release Engineering Team" - email = "release-engineering@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - } -} - publishing.repositories { maven("artifactregistry://us-maven.pkg.dev/swirlds-registry/maven-prerelease-channel") { name = "prereleaseChannel" diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.services-publish.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.services-publish.gradle.kts index 4bae581a0fd3..57ed149ed3de 100644 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.services-publish.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com.hedera.gradle.services-publish.gradle.kts @@ -18,44 +18,3 @@ plugins { id("java") id("com.hedera.gradle.maven-publish") } - -// Publishing tasks are only enabled if we publish to the matching group. -// Otherwise, Nexus configuration and credentials do not fit. -val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("") - -tasks.withType().configureEach { - enabled = publishingPackageGroup == "com.hedera" -} - -publishing { - publications { - named("maven") { - pom.developers { - developer { - name = "Hedera Base Team" - email = "hedera-base@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - developer { - name = "Hedera Services Team" - email = "hedera-services@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - developer { - name = "Hedera Smart Contracts Team" - email = "hedera-smart-contracts@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - developer { - name = "Release Engineering Team" - email = "release-engineering@swirldslabs.com" - organization = "Hedera Hashgraph" - organizationUrl = "https://www.hedera.com" - } - } - } - } -} diff --git a/hedera-node/developers.properties b/hedera-node/developers.properties new file mode 100644 index 000000000000..078a762f8735 --- /dev/null +++ b/hedera-node/developers.properties @@ -0,0 +1,4 @@ +hedera-base@hashgraph.com=Hedera Base Team +hedera-services@hashgraph.com=Hedera Services Team +hedera-smart-contracts@hashgraph.com=Hedera Smart Contracts Team +release-engineering@hashgraph.com=Release Engineering Team diff --git a/platform-sdk/description.txt b/platform-sdk/description.txt new file mode 100644 index 000000000000..90ec8bd24256 --- /dev/null +++ b/platform-sdk/description.txt @@ -0,0 +1,3 @@ +Swirlds is a software platform designed to build fully-distributed applications that harness the power of the cloud +without servers. Now you can develop applications with fairness in decision making, speed, trust and reliability, at +a fraction of the cost of traditional server-based platforms. diff --git a/platform-sdk/developers.properties b/platform-sdk/developers.properties new file mode 100644 index 000000000000..6e8ae7c80af6 --- /dev/null +++ b/platform-sdk/developers.properties @@ -0,0 +1,4 @@ +platform-base@hashgraph.com=Platform Base Team +platform-hashgraph@hashgraph.com=Platform Hashgraph Team +platform-data@hashgraph.com=Platform Data Team +release-engineering@hashgraph.com=Release Engineering Team