From 8f052d4585a3c5b35ff9e16ee7245c6fd69031d4 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Mon, 20 Nov 2023 20:04:52 +0100 Subject: [PATCH 1/3] Gradle: set moduleNamePrefix for ModuleDirectivesOrderingCheck (com.swirlds... modules) (#9881) Signed-off-by: Jendrik Johannes --- .../com.hedera.hashgraph.sdk.conventions.gradle.kts | 2 ++ .../swirlds-common/src/main/java/module-info.java | 4 ++-- .../swirlds-logging/src/main/java/module-info.java | 2 +- .../swirlds-platform-core/src/main/java/module-info.java | 8 ++++---- .../swirlds-merkle-test/src/main/java/module-info.java | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts index 17d337c59ea5..1a3341d726d7 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts @@ -22,6 +22,8 @@ plugins { group = "com.swirlds" +tasks.checkModuleInfo { moduleNamePrefix = "com.swirlds" } + javaModuleDependencies { versionsFromConsistentResolution(":swirlds-platform-core") } configurations.getByName("mainRuntimeClasspath") { diff --git a/platform-sdk/swirlds-common/src/main/java/module-info.java b/platform-sdk/swirlds-common/src/main/java/module-info.java index ee92cda0da25..d48934439a4f 100644 --- a/platform-sdk/swirlds-common/src/main/java/module-info.java +++ b/platform-sdk/swirlds-common/src/main/java/module-info.java @@ -166,11 +166,11 @@ exports com.swirlds.common.startup; exports com.swirlds.common.threading.atomic; - requires transitive com.fasterxml.jackson.core; - requires transitive com.fasterxml.jackson.databind; requires transitive com.swirlds.base; requires transitive com.swirlds.config.api; requires transitive com.swirlds.logging; + requires transitive com.fasterxml.jackson.core; + requires transitive com.fasterxml.jackson.databind; requires transitive io.prometheus.simpleclient; requires transitive lazysodium.java; requires transitive org.apache.logging.log4j; diff --git a/platform-sdk/swirlds-logging/src/main/java/module-info.java b/platform-sdk/swirlds-logging/src/main/java/module-info.java index 37c22c805607..fa3062f5a40c 100644 --- a/platform-sdk/swirlds-logging/src/main/java/module-info.java +++ b/platform-sdk/swirlds-logging/src/main/java/module-info.java @@ -6,8 +6,8 @@ requires transitive com.fasterxml.jackson.annotation; requires transitive com.fasterxml.jackson.databind; requires transitive org.apache.logging.log4j; + requires com.swirlds.base; requires com.fasterxml.jackson.core; requires com.fasterxml.jackson.datatype.jsr310; - requires com.swirlds.base; requires static com.github.spotbugs.annotations; } diff --git a/platform-sdk/swirlds-platform-core/src/main/java/module-info.java b/platform-sdk/swirlds-platform-core/src/main/java/module-info.java index 545fd5174f33..e8b99c1ea7fb 100644 --- a/platform-sdk/swirlds-platform-core/src/main/java/module-info.java +++ b/platform-sdk/swirlds-platform-core/src/main/java/module-info.java @@ -129,22 +129,22 @@ com.swirlds.common, com.swirlds.config.impl; - requires transitive com.fasterxml.jackson.annotation; - requires transitive com.fasterxml.jackson.databind; requires transitive com.swirlds.base; requires transitive com.swirlds.cli; requires transitive com.swirlds.common; requires transitive com.swirlds.config.api; requires transitive com.swirlds.platform.gui; + requires transitive com.fasterxml.jackson.annotation; + requires transitive com.fasterxml.jackson.databind; requires transitive info.picocli; requires transitive org.apache.logging.log4j; - requires com.fasterxml.jackson.core; - requires com.fasterxml.jackson.dataformat.yaml; requires com.swirlds.config.extensions; requires com.swirlds.fchashmap; requires com.swirlds.logging; requires com.swirlds.merkledb; requires com.swirlds.virtualmap; + requires com.fasterxml.jackson.core; + requires com.fasterxml.jackson.dataformat.yaml; requires java.management; requires java.scripting; requires jdk.management; diff --git a/platform-sdk/swirlds-unit-tests/structures/swirlds-merkle-test/src/main/java/module-info.java b/platform-sdk/swirlds-unit-tests/structures/swirlds-merkle-test/src/main/java/module-info.java index d1a3a90e5249..24880c64f4af 100644 --- a/platform-sdk/swirlds-unit-tests/structures/swirlds-merkle-test/src/main/java/module-info.java +++ b/platform-sdk/swirlds-unit-tests/structures/swirlds-merkle-test/src/main/java/module-info.java @@ -2,16 +2,16 @@ exports com.swirlds.merkle.map.test.pta; exports com.swirlds.merkle.map.test.lifecycle; - requires transitive com.fasterxml.jackson.annotation; - requires transitive com.fasterxml.jackson.databind; requires transitive com.swirlds.common.testing; requires transitive com.swirlds.common; requires transitive com.swirlds.merkle; - requires com.fasterxml.jackson.core; + requires transitive com.fasterxml.jackson.annotation; + requires transitive com.fasterxml.jackson.databind; requires com.swirlds.base; requires com.swirlds.common.test.fixtures; requires com.swirlds.fchashmap; requires com.swirlds.fcqueue; + requires com.fasterxml.jackson.core; requires org.apache.logging.log4j.core; requires org.apache.logging.log4j; } From 98a088020dfc976a5acf9453fce6331cbebad554 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Mon, 20 Nov 2023 20:42:02 +0100 Subject: [PATCH 2/3] Enable Gradle Configuration Cache (#9651) Signed-off-by: Jendrik Johannes Signed-off-by: Ivan Malygin Co-authored-by: Ivan Malygin --- .../node-zxc-build-release-artifact.yaml | 2 +- build-logic/project-plugins/build.gradle.kts | 6 +- .../project-plugins/src/main/kotlin/Utils.kt | 10 +- ...om.hedera.hashgraph.application.gradle.kts | 7 +- .../com.hedera.hashgraph.hapi.gradle.kts | 9 -- .../com.hedera.hashgraph.java.gradle.kts | 27 ++++++ ...m.hedera.hashgraph.jpms-modules.gradle.kts | 6 -- ....hedera.hashgraph.maven-publish.gradle.kts | 1 - ...ashgraph.platform-maven-publish.gradle.kts | 8 ++ .../com.hedera.hashgraph.root.gradle.kts | 96 ++++++++++++------- ...edera.hashgraph.sdk.conventions.gradle.kts | 3 - ...com.hedera.hashgraph.shadow-jar.gradle.kts | 16 ++-- build-logic/settings-plugins/build.gradle.kts | 5 +- ...era.hashgraph.settings.settings.gradle.kts | 7 +- gradle.properties | 1 + gradlew | 14 +-- hedera-dependency-versions/build.gradle.kts | 2 +- hedera-node/hapi/build.gradle.kts | 50 ++++++---- hedera-node/hedera-app/build.gradle.kts | 36 ++----- .../test/exec/utils/ActionsHelperTest.java | 2 +- platform-sdk/swirlds/build.gradle.kts | 19 ++-- settings.gradle.kts | 24 +---- 22 files changed, 181 insertions(+), 170 deletions(-) diff --git a/.github/workflows/node-zxc-build-release-artifact.yaml b/.github/workflows/node-zxc-build-release-artifact.yaml index ac7fe6739506..bd59d11a024c 100644 --- a/.github/workflows/node-zxc-build-release-artifact.yaml +++ b/.github/workflows/node-zxc-build-release-artifact.yaml @@ -776,7 +776,7 @@ jobs: OSSRH_PASSWORD: ${{ secrets.sdk-ossrh-password }} with: gradle-version: ${{ inputs.gradle-version }} - arguments: "release${{ inputs.sdk-release-profile }} --scan -PpublishSigningEnabled=true" + arguments: "release${{ inputs.sdk-release-profile }} --scan -PpublishSigningEnabled=true --no-configuration-cache" - name: Upload SDK Release Archives if: ${{ inputs.dry-run-enabled != true && inputs.version-policy == 'specified' && !cancelled() && !failure() }} diff --git a/build-logic/project-plugins/build.gradle.kts b/build-logic/project-plugins/build.gradle.kts index 920af813da4e..7731bfeae395 100644 --- a/build-logic/project-plugins/build.gradle.kts +++ b/build-logic/project-plugins/build.gradle.kts @@ -21,17 +21,15 @@ plugins { } dependencies { - implementation("com.adarshr:gradle-test-logger-plugin:3.2.0") + implementation("com.adarshr:gradle-test-logger-plugin:4.0.0") implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.25.0") implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0") implementation("com.github.johnrengelman:shadow:8.1.1") implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4") - implementation("com.gorylenko.gradle-git-properties:gradle-git-properties:2.4.1") implementation( "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1" ) - implementation("gradle.plugin.lazy.zoo.gradle:git-data-plugin:1.2.2") - implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.1") + implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2") implementation("net.swiftzer.semver:semver:1.3.0") implementation("org.gradlex:extra-java-module-info:1.5") implementation("org.gradlex:java-ecosystem-capabilities:1.3.1") diff --git a/build-logic/project-plugins/src/main/kotlin/Utils.kt b/build-logic/project-plugins/src/main/kotlin/Utils.kt index 44bbe798e1cd..094e7c40873d 100644 --- a/build-logic/project-plugins/src/main/kotlin/Utils.kt +++ b/build-logic/project-plugins/src/main/kotlin/Utils.kt @@ -14,8 +14,6 @@ * limitations under the License. */ -import net.swiftzer.semver.SemVer -import org.gradle.api.Project import org.gradle.api.file.Directory import org.gradle.api.file.RegularFile import java.io.OutputStream @@ -32,14 +30,8 @@ class Utils { file("version.txt").let { if (it.asFile.exists()) it else this.dir("..").versionTxt() } @JvmStatic - fun updateVersion(project: Project, newVersion: SemVer) { - project.layout.projectDirectory.versionTxt().asFile.writeText(newVersion.toString()) - } - - @JvmStatic - fun generateProjectVersionReport(rootProject: Project, ostream: OutputStream) { + fun generateProjectVersionReport(version: String, ostream: OutputStream) { val writer = PrintStream(ostream, false, Charsets.UTF_8) - val version = rootProject.layout.projectDirectory.versionTxt().asFile.readText().trim() ostream.use { writer.use { diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.application.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.application.gradle.kts index d4b4cb007b49..4f164a0d88b9 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.application.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.application.gradle.kts @@ -17,13 +17,10 @@ plugins { id("application") id("com.hedera.hashgraph.java") - id("com.gorylenko.gradle-git-properties") } group = "com.swirlds" -gitProperties { keys = listOf("git.build.version", "git.commit.id", "git.commit.id.abbrev") } - // Find the central SDK deployment dir by searching up the folder hierarchy fun sdkDir(dir: Directory): Directory = if (dir.dir("sdk").asFile.exists()) dir.dir("sdk") else sdkDir(dir.dir("..")) @@ -38,9 +35,11 @@ val copyLib = // Copy built jar into `data/apps` and rename val copyApp = tasks.register("copyApp") { + inputs.property("projectName", project.name) + from(tasks.jar) into(sdkDir(layout.projectDirectory).dir("data/apps")) - rename { "${project.name}.jar" } + rename { "${inputs.properties["projectName"]}.jar" } } tasks.assemble { diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.hapi.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.hapi.gradle.kts index e3a6a4c76615..823f771b1439 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.hapi.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.hapi.gradle.kts @@ -49,12 +49,3 @@ sourceSets.all { } } } - -tasks.withType().configureEach { - dependsOn(tasks.named("generatePbjSource")) - dependsOn(tasks.named("generateTestPbjSource")) - dependsOn(tasks.named("generateTestFixturesPbjSource")) - dependsOn(tasks.named("generateItestPbjSource")) - dependsOn(tasks.named("generateEetPbjSource")) - dependsOn(tasks.named("generateXtestPbjSource")) -} diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.java.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.java.gradle.kts index a8f0e3750b9c..9eb5d7b57fd9 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.java.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.java.gradle.kts @@ -70,6 +70,33 @@ sourceSets.all { } } +val writeGitProperties = + tasks.register("writeGitProperties") { + property("git.build.version", project.version) + @Suppress("UnstableApiUsage") + property( + "git.commit.id", + providers + .exec { commandLine("git", "rev-parse", "HEAD") } + .standardOutput + .asText + .map { it.trim() } + ) + @Suppress("UnstableApiUsage") + property( + "git.commit.id.abbrev", + providers + .exec { commandLine("git", "rev-parse", "--short", "HEAD") } + .standardOutput + .asText + .map { it.trim() } + ) + + destinationFile.set(layout.buildDirectory.file("generated/git/git.properties")) + } + +tasks.processResources { from(writeGitProperties) } + tasks.withType().configureEach { isPreserveFileTimestamps = false isReproducibleFileOrder = true diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.jpms-modules.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.jpms-modules.gradle.kts index 8e5ec122bcff..96bfabe0a668 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.jpms-modules.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.jpms-modules.gradle.kts @@ -22,12 +22,6 @@ plugins { } dependencies.components { - // TODO remove, once a new version of 'com.hedera.pbj.runtime' has been - // published with fix from https://github.com/hashgraph/pbj/pull/92 - withModule("com.hedera.pbj:pbj-runtime") { - allVariants { withDependencies { removeAll { it.name != "antlr4-runtime" } } } - } - withModule("io.grpc:grpc-netty") withModule("io.grpc:grpc-protobuf") withModule("io.grpc:grpc-protobuf-lite") diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts index 3dd3bd4718e6..a7cea760f0bd 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.maven-publish.gradle.kts @@ -18,7 +18,6 @@ plugins { id("java") id("maven-publish") id("signing") - id("com.google.cloud.artifactregistry.gradle-plugin") } java { diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.platform-maven-publish.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.platform-maven-publish.gradle.kts index ae5628862ff5..de451c35023b 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.platform-maven-publish.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.platform-maven-publish.gradle.kts @@ -19,6 +19,14 @@ plugins { id("com.hedera.hashgraph.maven-publish") } +@Suppress("UnstableApiUsage") +if (!gradle.startParameter.isConfigurationCacheRequested) { + // plugin to support 'artifactregistry' repositories that currently only works without + // configuration cache + // https://github.com/GoogleCloudPlatform/artifact-registry-maven-tools/issues/85 + apply(plugin = "com.google.cloud.artifactregistry.gradle-plugin") +} + publishing { publications { named("maven") { diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.root.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.root.gradle.kts index 92ac3ae82eb1..3196ca931b2b 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.root.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.root.gradle.kts @@ -23,7 +23,6 @@ plugins { id("com.hedera.hashgraph.spotless-conventions") id("com.hedera.hashgraph.spotless-kotlin-conventions") id("com.hedera.hashgraph.dependency-analysis") - id("lazy.zoo.gradle.git-data-plugin") } spotless { kotlinGradle { target("build-logic/**/*.gradle.kts") } } @@ -32,65 +31,98 @@ val productVersion = layout.projectDirectory.versionTxt().asFile.readText().trim tasks.register("githubVersionSummary") { group = "github" - doLast { - val ghStepSummaryPath: String = - providers.environmentVariable("GITHUB_STEP_SUMMARY").orNull - ?: throw IllegalArgumentException( - "This task may only be run in a Github Actions CI environment!" + - "Unable to locate the GITHUB_STEP_SUMMARY environment variable." - ) + inputs.property("version", productVersion) + outputs.file( + providers + .environmentVariable("GITHUB_STEP_SUMMARY") + .orElse( + provider { + throw IllegalArgumentException( + "This task may only be run in a Github Actions CI environment! " + + "Unable to locate the GITHUB_STEP_SUMMARY environment variable." + ) + } + ) + ) + + doLast { Utils.generateProjectVersionReport( - rootProject, - File(ghStepSummaryPath).outputStream().buffered() + inputs.properties["version"] as String, + outputs.files.singleFile.outputStream().buffered() ) } } tasks.register("showVersion") { group = "versioning" - doLast { println(productVersion) } + + inputs.property("version", productVersion) + + doLast { println(inputs.properties["version"]) } } tasks.register("versionAsPrefixedCommit") { group = "versioning" + + @Suppress("UnstableApiUsage") + inputs.property( + "commit", + providers + .exec { commandLine("git", "rev-parse", "--short", "HEAD") } + .standardOutput + .asText + .map { it.trim() } + ) + inputs.property("commitPrefix", providers.gradleProperty("commitPrefix").orElse("adhoc")) + inputs.property("version", productVersion) + outputs.file(layout.projectDirectory.versionTxt()) + doLast { - gitData.lastCommitHash?.let { - val prefix = providers.gradleProperty("commitPrefix").getOrElse("adhoc") - val newPrerel = prefix + ".x" + it.take(8) - val currVer = SemVer.parse(productVersion) - try { - val newVer = SemVer(currVer.major, currVer.minor, currVer.patch, newPrerel) - Utils.updateVersion(rootProject, newVer) - } catch (e: java.lang.IllegalArgumentException) { - throw IllegalArgumentException(String.format("%s: %s", e.message, newPrerel), e) - } - } + val newPrerel = + inputs.properties["commitPrefix"].toString() + + ".x" + + inputs.properties["commit"].toString().take(8) + val currVer = SemVer.parse(inputs.properties["version"] as String) + val newVer = SemVer(currVer.major, currVer.minor, currVer.patch, newPrerel) + outputs.files.singleFile.writeText(newVer.toString()) } } tasks.register("versionAsSnapshot") { group = "versioning" + + inputs.property("version", productVersion) + outputs.file(layout.projectDirectory.versionTxt()) + doLast { - val currVer = SemVer.parse(productVersion) + val currVer = SemVer.parse(inputs.properties["version"] as String) val newVer = SemVer(currVer.major, currVer.minor, currVer.patch, "SNAPSHOT") - Utils.updateVersion(rootProject, newVer) + outputs.files.singleFile.writeText(newVer.toString()) } } tasks.register("versionAsSpecified") { group = "versioning" - doLast { - val verStr = providers.gradleProperty("newVersion") - if (!verStr.isPresent) { - throw IllegalArgumentException( - "No newVersion property provided! Please add the parameter -PnewVersion= when running this task." + inputs.property( + "newVersion", + providers + .gradleProperty("newVersion") + .orElse( + provider { + throw IllegalArgumentException( + "No newVersion property provided! " + + "Please add the parameter -PnewVersion= when running this task." + ) + } ) - } + ) + outputs.file(layout.projectDirectory.versionTxt()) - val newVer = SemVer.parse(verStr.get()) - Utils.updateVersion(rootProject, newVer) + doLast { + val newVer = SemVer.parse(inputs.properties["newVersion"] as String) + outputs.files.singleFile.writeText(newVer.toString()) } } diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts index 1a3341d726d7..5f65b746dde7 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.sdk.conventions.gradle.kts @@ -17,7 +17,6 @@ plugins { id("java-library") id("com.hedera.hashgraph.java") - id("com.gorylenko.gradle-git-properties") } group = "com.swirlds" @@ -30,8 +29,6 @@ configurations.getByName("mainRuntimeClasspath") { extendsFrom(configurations.getByName("internal")) } -gitProperties { keys = listOf("git.build.version", "git.commit.id", "git.commit.id.abbrev") } - // !!! Remove the following once 'test' tasks are allowed to run in parallel === val allPlatformSdkProjects = rootProject.subprojects diff --git a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.shadow-jar.gradle.kts b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.shadow-jar.gradle.kts index 4e619781e758..32975f5451f0 100644 --- a/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.shadow-jar.gradle.kts +++ b/build-logic/project-plugins/src/main/kotlin/com.hedera.hashgraph.shadow-jar.gradle.kts @@ -14,6 +14,7 @@ * limitations under the License. */ +import com.github.jengelman.gradle.plugins.shadow.internal.DefaultDependencyFilter import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { @@ -26,11 +27,14 @@ tasks.withType().configureEach { from(sourceSets.main.get().output) mergeServiceFiles() - // Defer the resolution of 'runtimeClasspath'. This is an issue in the shadow - // plugin that it automatically accesses the files in 'runtimeClasspath' while - // Gradle is building the task graph. The three lines below work around that. + // There is an issue in the shadow plugin that it automatically accesses the + // files in 'runtimeClasspath' while Gradle is building the task graph. // See: https://github.com/johnrengelman/shadow/issues/882 - inputs.files(project.configurations.runtimeClasspath) - configurations = emptyList() - doFirst { configurations = listOf(project.configurations.runtimeClasspath.get()) } + dependencyFilter = NoResolveDependencyFilter() +} + +class NoResolveDependencyFilter : DefaultDependencyFilter(project) { + override fun resolve(configuration: FileCollection): FileCollection { + return configuration + } } diff --git a/build-logic/settings-plugins/build.gradle.kts b/build-logic/settings-plugins/build.gradle.kts index 4f2b4e9eaf2a..fcdc40f5aea7 100644 --- a/build-logic/settings-plugins/build.gradle.kts +++ b/build-logic/settings-plugins/build.gradle.kts @@ -16,7 +16,4 @@ plugins { `kotlin-dsl` } -dependencies { - implementation("com.gradle:gradle-enterprise-gradle-plugin:3.15.1") - implementation("me.champeau.gradle.includegit:plugin:0.1.6") -} +dependencies { implementation("com.gradle:gradle-enterprise-gradle-plugin:3.15.1") } diff --git a/build-logic/settings-plugins/src/main/kotlin/com.hedera.hashgraph.settings.settings.gradle.kts b/build-logic/settings-plugins/src/main/kotlin/com.hedera.hashgraph.settings.settings.gradle.kts index 12c49e120e3d..a6c46c8efd5c 100644 --- a/build-logic/settings-plugins/src/main/kotlin/com.hedera.hashgraph.settings.settings.gradle.kts +++ b/build-logic/settings-plugins/src/main/kotlin/com.hedera.hashgraph.settings.settings.gradle.kts @@ -22,12 +22,7 @@ pluginManagement { } } -plugins { - id("com.gradle.enterprise") - // Use GIT plugin to clone HAPI protobuf files - // See documentation https://melix.github.io/includegit-gradle-plugin/latest/index.html - id("me.champeau.includegit") -} +plugins { id("com.gradle.enterprise") } // Enable Gradle Build Scan gradleEnterprise { diff --git a/gradle.properties b/gradle.properties index 2e21b561206a..0f66a4dbc061 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,6 +18,7 @@ org.gradle.jvmargs=-Xmx6144m # Enable Gradle caching +org.gradle.configuration-cache=true org.gradle.caching=true # Enable parallel workers diff --git a/gradlew b/gradlew index 0adc8e1a5321..1aa94a426907 100755 --- a/gradlew +++ b/gradlew @@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/hedera-dependency-versions/build.gradle.kts b/hedera-dependency-versions/build.gradle.kts index 2e061f75920e..15738639a18f 100644 --- a/hedera-dependency-versions/build.gradle.kts +++ b/hedera-dependency-versions/build.gradle.kts @@ -53,7 +53,7 @@ moduleInfo { version("com.google.jimfs", "1.2") version("com.google.protobuf", protobufVersion) version("com.google.protobuf.util", protobufVersion) - version("com.hedera.pbj.runtime", "0.7.4") + version("com.hedera.pbj.runtime", "0.7.6") version("com.sun.jna", "5.12.1") version("dagger", daggerVersion) version("dagger.compiler", daggerVersion) diff --git a/hedera-node/hapi/build.gradle.kts b/hedera-node/hapi/build.gradle.kts index 73aae7a8db5c..6bb82463c6e5 100644 --- a/hedera-node/hapi/build.gradle.kts +++ b/hedera-node/hapi/build.gradle.kts @@ -23,6 +23,39 @@ plugins { description = "Hedera API" +val hapiProtoBranchOrTag = "add-pbj-types-for-state" +val hederaProtoDir = layout.projectDirectory.dir("hedera-protobufs") + +if (!gradle.startParameter.isOffline) { + @Suppress("UnstableApiUsage") + providers + .exec { + if (!hederaProtoDir.dir(".git").asFile.exists()) { + workingDir = layout.projectDirectory.asFile + commandLine( + "git", + "clone", + "https://github.com/hashgraph/hedera-protobufs.git", + "-q" + ) + } else { + workingDir = hederaProtoDir.asFile + commandLine("git", "fetch", "-q") + } + } + .result + .get() +} + +@Suppress("UnstableApiUsage") +providers + .exec { + workingDir = hederaProtoDir.asFile + commandLine("git", "checkout", hapiProtoBranchOrTag, "-q") + } + .result + .get() + testModuleInfo { requires("com.hedera.node.hapi") // we depend on the protoc compiled hapi during test as we test our pbj generated code @@ -61,20 +94,3 @@ tasks.test { minHeapSize = "512m" maxHeapSize = "4096m" } - -// ---- -// TODO move the following things to 'hashgraph/pbj' plugin -tasks.withType { - doFirst { - // Clean output directories before generating new code. Belongs into: - // 'pbj-core/pbj-compiler/src/main/java/com/hedera/pbj/compiler/PbjCompilerTask.java' - delete(javaMainOutputDirectory) - delete(javaTestOutputDirectory) - } -} - -tasks.withType().configureEach { - // Wire the source generation so that the source sets know which tasks - // generate code for them. Then this additional 'dependsOn' is not necessary. - dependsOn(tasks.withType()) -} // ---- diff --git a/hedera-node/hedera-app/build.gradle.kts b/hedera-node/hedera-app/build.gradle.kts index 61ff7fadbf03..165a9f50f039 100644 --- a/hedera-node/hedera-app/build.gradle.kts +++ b/hedera-node/hedera-app/build.gradle.kts @@ -127,16 +127,15 @@ tasks.withType { // Add all the libs dependencies into the jar manifest! tasks.jar { inputs.files(configurations.runtimeClasspath) - manifest { - attributes( - "Main-Class" to "com.hedera.node.app.ServicesMain", + manifest { attributes("Main-Class" to "com.hedera.node.app.ServicesMain") } + doFirst { + manifest.attributes( "Class-Path" to - configurations.runtimeClasspath.get().elements.map { entry -> - entry - .map { "../../data/lib/" + it.asFile.name } - .sorted() - .joinToString(separator = " ") - } + inputs.files + .filter { it.extension == "jar" } + .map { "../../data/lib/" + it.name } + .sorted() + .joinToString(separator = " ") ) } } @@ -146,25 +145,6 @@ val copyLib = tasks.register("copyLib") { from(project.configurations.getByName("runtimeClasspath")) into(layout.projectDirectory.dir("../data/lib")) - - doLast { - val nonModulalJars = - destinationDir - .listFiles()!! - .mapNotNull { jar -> - if (zipTree(jar).none { it.name == "module-info.class" }) { - jar.name - } else { - null - } - } - .sorted() - if (nonModulalJars.isNotEmpty()) { - throw RuntimeException( - "Jars without 'module-info.class' in 'data/lib'\n${nonModulalJars.joinToString("\n")}" - ) - } - } } // Copy built jar into `data/apps` and rename HederaNode.jar diff --git a/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/utils/ActionsHelperTest.java b/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/utils/ActionsHelperTest.java index 5062c417cbab..7e98e00d3e0a 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/utils/ActionsHelperTest.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/utils/ActionsHelperTest.java @@ -53,7 +53,7 @@ class ActionsHelperTest { @Test void prettyPrintsAsExpected() { final var expected = - "SolidityAction(callType: CALL, callOperationType: OP_CALL, value: 0, gas: 500000, gasUsed: 0, callDepth: 0, callingAccount: , callingContract: ContractID[shardNum=0, realmNum=0, contract=OneOf[kind=CONTRACT_NUM, value=666]], recipientAccount: , recipientContract: ContractID[shardNum=0, realmNum=0, contract=OneOf[kind=CONTRACT_NUM, value=666]], invalidSolidityAddress (aka targetedAddress): , input: Bytes[1,2,3,4,5,6,7,8,9], output: Bytes[9,8,7,6,5,4,3,2,1], revertReason: , error: )"; + "SolidityAction(callType: CALL, callOperationType: OP_CALL, value: 0, gas: 500000, gasUsed: 0, callDepth: 0, callingAccount: , callingContract: ContractID[shardNum=0, realmNum=0, contract=OneOf[kind=CONTRACT_NUM, value=666]], recipientAccount: , recipientContract: ContractID[shardNum=0, realmNum=0, contract=OneOf[kind=CONTRACT_NUM, value=666]], invalidSolidityAddress (aka targetedAddress): , input: 010203040506070809, output: 090807060504030201, revertReason: , error: )"; final var actual = subject.prettyPrint(CALL_ACTION); assertEquals(expected, actual); } diff --git a/platform-sdk/swirlds/build.gradle.kts b/platform-sdk/swirlds/build.gradle.kts index ee100f479ed9..de9835699c3d 100644 --- a/platform-sdk/swirlds/build.gradle.kts +++ b/platform-sdk/swirlds/build.gradle.kts @@ -32,17 +32,18 @@ tasks.copyApp { tasks.jar { // Gradle fails to track 'configurations.runtimeClasspath' as an input to the task if it is - // only used in the 'mainfest.attributes'. Hence, we explicitly add it as input. + // only used in the 'manifest.attributes'. Hence, we explicitly add it as input. inputs.files(configurations.runtimeClasspath) - manifest { - attributes( - "Class-Path" to - configurations.runtimeClasspath.get().elements.map { entry -> - entry - .map { "data/lib/" + it.asFile.name } + doFirst { + manifest { + attributes( + "Class-Path" to + inputs.files + .filter { it.extension == "jar" } + .map { "data/lib/" + it.name } .sorted() .joinToString(separator = " ") - } - ) + ) + } } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 61a4fbdb5130..8001b3c915c3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,8 +14,6 @@ * limitations under the License. */ -import me.champeau.gradle.igp.gitRepositories - pluginManagement { includeBuild("build-logic") } plugins { id("com.hedera.hashgraph.settings") } @@ -141,26 +139,8 @@ fun includeAllProjects(containingFolder: String) { } } -// The HAPI API version to use for Protobuf sources. This can be a tag or branch -// name from the hedera-protobufs GIT repo. +// The HAPI API version to use for Protobuf sources. val hapiProtoVersion = "0.44.0" -val hapiProtoBranchOrTag = "add-pbj-types-for-state" - -gitRepositories { - checkoutsDirectory.set(File(rootDir, "hedera-node/hapi")) - // check branch in repo for updates every second - refreshIntervalMillis.set(1000) - - if (!gradle.startParameter.isOffline) { - include("hedera-protobufs") { - uri.set("https://github.com/hashgraph/hedera-protobufs.git") - // HAPI repo version - tag.set(hapiProtoBranchOrTag) - // do not load project from repo - autoInclude.set(false) - } - } -} dependencyResolutionManagement { // Protobuf tool versions @@ -169,6 +149,6 @@ dependencyResolutionManagement { version("grpc-proto", "1.45.1") version("hapi-proto", hapiProtoVersion) - plugin("pbj", "com.hedera.pbj.pbj-compiler").version("0.7.4") + plugin("pbj", "com.hedera.pbj.pbj-compiler").version("0.7.6") } } From fe5882f74362f65e6f425debc7542057a55b7443 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Mon, 20 Nov 2023 22:55:53 +0100 Subject: [PATCH 3/3] fix: run 'releaseEvmMavenCentral' with --no-configuration-cache (#10027) Signed-off-by: Jendrik Johannes --- .github/workflows/node-zxc-build-release-artifact.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node-zxc-build-release-artifact.yaml b/.github/workflows/node-zxc-build-release-artifact.yaml index bd59d11a024c..21a3ba8f63f6 100644 --- a/.github/workflows/node-zxc-build-release-artifact.yaml +++ b/.github/workflows/node-zxc-build-release-artifact.yaml @@ -610,7 +610,7 @@ jobs: OSSRH_PASSWORD: ${{ secrets.svcs-ossrh-password }} with: gradle-version: ${{ inputs.gradle-version }} - arguments: "releaseEvmMavenCentral --scan -PpublishSigningEnabled=true" + arguments: "releaseEvmMavenCentral --scan -PpublishSigningEnabled=true --no-configuration-cache" - name: Gradle Maven Central Snapshot uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0 @@ -620,7 +620,7 @@ jobs: OSSRH_PASSWORD: ${{ secrets.svcs-ossrh-password }} with: gradle-version: ${{ inputs.gradle-version }} - arguments: "releaseEvmMavenCentralSnapshot --scan -PpublishSigningEnabled=true" + arguments: "releaseEvmMavenCentralSnapshot --scan -PpublishSigningEnabled=true --no-configuration-cache" sdk-publish: name: Publish Platform to ${{ inputs.version-policy == 'specified' && 'Maven Central' || 'GCP Registry' }}