diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c08fc5876..4bf8dd2a5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,7 +11,12 @@ updates: schedule: interval: daily - - package-ecosystem: "gradle" - directory: "/" + - package-ecosystem: gradle + directory: /hedera-dependency-versions schedule: - interval: "weekly" \ No newline at end of file + interval: weekly + + - package-ecosystem: gradle + directory: / + schedule: + interval: weekly \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 3bd71c4cd..000000000 --- a/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id("com.hedera.block.root") -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index d9fff832f..000000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { `kotlin-dsl` } - -repositories { gradlePluginPortal() } - -dependencies { - implementation("com.adarshr:gradle-test-logger-plugin:4.0.0") - implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.32.0") - implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") - implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4") - implementation("com.gradle.publish:plugin-publish-plugin:1.2.1") - implementation("gradle.plugin.lazy.zoo.gradle:git-data-plugin:1.2.2") - implementation("io.github.gradle-nexus:publish-plugin:1.3.0") - 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.8") - implementation("org.gradlex:jvm-dependency-conflict-resolution:2.0") - implementation("org.gradlex:java-module-dependencies:1.6.5") -} diff --git a/buildSrc/src/main/kotlin/Utils.kt b/buildSrc/src/main/kotlin/Utils.kt deleted file mode 100644 index f6ce8f4bf..000000000 --- a/buildSrc/src/main/kotlin/Utils.kt +++ /dev/null @@ -1,83 +0,0 @@ -import net.swiftzer.semver.SemVer -import org.gradle.api.Project -import java.io.File -import java.io.OutputStream -import java.io.PrintStream - -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -class Utils { - companion object { - @JvmStatic - fun updateVersion(project: Project, newVersion: SemVer) { - val gradlePropFile = File(project.projectDir, "gradle.properties") - var lines: List = mutableListOf() - - if (gradlePropFile.exists()) { - lines = gradlePropFile.readLines(Charsets.UTF_8) - } - - var versionStr = "version=$newVersion" - val finalLines: List - - - if (lines.isNotEmpty()) { - finalLines = lines.map { - if (it.trimStart().startsWith("version=")) { - versionStr - } else { - it - } - } - } else { - finalLines = listOf(versionStr) - } - - - gradlePropFile.bufferedWriter(Charsets.UTF_8).use { - val writer = it - finalLines.forEach { - writer.write(it) - writer.newLine() - } - writer.flush() - } - } - - @JvmStatic - fun generateProjectVersionReport(rootProject: Project, ostream: OutputStream) { - val writer = PrintStream(ostream, false, Charsets.UTF_8) - - ostream.use { - writer.use { - // Writer headers - writer.println("### Deployed Version Information") - writer.println() - writer.println("| Artifact Name | Version Number |") - writer.println("| --- | --- |") - - // Write table rows - rootProject.childProjects.values.onEach { - writer.printf("| %s | %s |\n", it.name, it.version.toString()) - } - writer.flush() - ostream.flush() - } - } - } - } -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.aggregate-reports.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.aggregate-reports.gradle.kts deleted file mode 100644 index 0a3a6a386..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.aggregate-reports.gradle.kts +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.BufferedOutputStream -import net.swiftzer.semver.SemVer - -plugins { id("lazy.zoo.gradle.git-data-plugin") } - -tasks.register("githubVersionSummary") { - group = "github" - doLast { - val ghStepSummaryPath: String = - System.getenv("GITHUB_STEP_SUMMARY") - ?: throw IllegalArgumentException( - "This task may only be run in a Github Actions CI environment! Unable to locate the GITHUB_STEP_SUMMARY environment variable." - ) - - val ghStepSummaryFile = File(ghStepSummaryPath) - Utils.generateProjectVersionReport( - rootProject, - BufferedOutputStream(ghStepSummaryFile.outputStream()) - ) - } -} - -tasks.register("showVersion") { - group = "versioning" - doLast { println(project.version) } -} - -tasks.register("versionAsPrefixedCommit") { - group = "versioning" - doLast { - gitData.lastCommitHash?.let { - val prefix = findProperty("commitPrefix")?.toString() ?: "adhoc" - val newPrerel = prefix + ".x" + it.take(8) - val currVer = SemVer.parse(project.version.toString()) - try { - val newVer = SemVer(currVer.major, currVer.minor, currVer.patch, newPrerel) - Utils.updateVersion(project, newVer) - } catch (e: java.lang.IllegalArgumentException) { - throw IllegalArgumentException(String.format("%s: %s", e.message, newPrerel), e) - } - } - } -} - -tasks.register("versionAsSnapshot") { - group = "versioning" - doLast { - val currVer = SemVer.parse(project.version.toString()) - val newVer = SemVer(currVer.major, currVer.minor, currVer.patch, "SNAPSHOT") - - Utils.updateVersion(project, newVer) - } -} - -tasks.register("versionAsSpecified") { - group = "versioning" - doLast { - val verStr = - providers.gradleProperty("newVersion").orNull - ?: throw IllegalArgumentException( - "No newVersion property provided! Please add the parameter -PnewVersion= when running this task." - ) - - val newVer = SemVer.parse(verStr) - Utils.updateVersion(project, newVer) - } -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.conventions.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.conventions.gradle.kts deleted file mode 100644 index 7dad4eb8c..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.conventions.gradle.kts +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.adarshr.gradle.testlogger.theme.ThemeType - -plugins { - id("java") - id("jacoco") - id("org.gradlex.java-module-dependencies") - id("com.adarshr.test-logger") - id("com.hedera.block.repositories") - id("com.hedera.block.jpms-modules") - id("com.hedera.block.spotless-conventions") - id("com.hedera.block.spotless-java-conventions") - id("com.hedera.block.spotless-kotlin-conventions") - id("com.hedera.block.maven-publish") -} - -group = "com.hedera.block" - -java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 - toolchain { - languageVersion.set(JavaLanguageVersion.of(21)) - vendor.set(JvmVendorSpec.ADOPTIUM) - } - - // Enable JAR file generation required for publishing - withJavadocJar() - withSourcesJar() -} - -testing { - @Suppress("UnstableApiUsage") suites.getByName("test") { useJUnitJupiter() } -} - -tasks.withType { - isPreserveFileTimestamps = false - isReproducibleFileOrder = true - fileMode = 436 // octal: 0664 - dirMode = 509 // octal: 0775 -} - -tasks.withType { options.encoding = "UTF-8" } - -tasks.withType { - options.encoding = "UTF-8" - (options as StandardJavadocDocletOptions).tags( - "apiNote:a:API Note:", - "implSpec:a:Implementation Requirements:", - "implNote:a:Implementation Note:" - ) -} - -testlogger { - theme = ThemeType.MOCHA - slowThreshold = 10000 - showStandardStreams = true - showPassedStandardStreams = false - showSkippedStandardStreams = false - showFailedStandardStreams = true -} - -// Ensure JaCoCo coverage is generated and aggregated -tasks.jacocoTestReport.configure { - reports { - xml.required.set(true) - html.required.set(true) - } - - val testExtension = tasks.test.get().extensions.getByType() - executionData.setFrom(testExtension.destinationFile) - - shouldRunAfter(tasks.named("check")) -} - -tasks.check { - // Ensure the check task also runs the JaCoCo coverage report - dependsOn(tasks.jacocoTestReport) - // Check dependency scopes in module-info.java - dependsOn(tasks.checkAllModuleInfo) -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts deleted file mode 100644 index 14ae2e6c5..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (C) 2016-2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id("org.gradlex.jvm-dependency-conflict-resolution") - id("org.gradlex.extra-java-module-info") -} - -// Fix or enhance the metadata of third-party Modules. This is about the metadata in the -// repositories: '*.pom' and '*.module' files. -jvmDependencyConflicts.patch { - // These compile time annotation libraries are not of interest in our setup and are thus removed - // from the dependencies of all components that bring them in. - val annotationLibraries = - listOf( - "com.google.android:annotations", - "com.google.code.findbugs:annotations", - "com.google.code.findbugs:jsr305", - "com.google.errorprone:error_prone_annotations", - "com.google.guava:listenablefuture", - "org.checkerframework:checker-compat-qual", - "org.checkerframework:checker-qual", - "org.codehaus.mojo:animal-sniffer-annotations" - ) - - module("io.grpc:grpc-netty-shaded") { annotationLibraries.forEach { removeDependency(it) } } - - module("io.grpc:grpc-api") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-core") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-context") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-protobuf") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-protobuf-lite") { - annotationLibraries.forEach { removeDependency(it) } - removeDependency(/* dependency = */ "com.google.protobuf:protobuf-javalite") - addApiDependency("com.google.protobuf:protobuf-java") - } - module("io.grpc:grpc-services") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-stub") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-testing") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-util") { annotationLibraries.forEach { removeDependency(it) } } - module("com.google.dagger:dagger-compiler") { - annotationLibraries.forEach { removeDependency(it) } - } - module("com.google.dagger:dagger-producers") { - annotationLibraries.forEach { removeDependency(it) } - } - module("com.google.dagger:dagger-spi") { annotationLibraries.forEach { removeDependency(it) } } - module("com.google.guava:guava") { - (annotationLibraries - - "com.google.code.findbugs:jsr305" - - "com.google.errorprone:error_prone_annotations" - - "org.checkerframework:checker-qual") - .forEach { removeDependency(it) } - } - module("com.google.protobuf:protobuf-java-util") { - annotationLibraries.forEach { removeDependency(it) } - } - module("io.prometheus:simpleclient") { - removeDependency("io.prometheus:simpleclient_tracer_otel") - removeDependency("io.prometheus:simpleclient_tracer_otel_agent") - } - module("org.jetbrains.kotlin:kotlin-stdlib") { - removeDependency("org.jetbrains.kotlin:kotlin-stdlib-common") - } - module("junit:junit") { removeDependency("org.hamcrest:hamcrest-core") } - module("org.hyperledger.besu:secp256k1") { addApiDependency("net.java.dev.jna:jna") } -} - -// Fix or enhance the 'module-info.class' of third-party Modules. This is about the -// 'module-info.class' inside the Jar files. In our full Java Modules setup every -// Jar needs to have this file. If it is missing, it is added by what is configured here. -extraJavaModuleInfo { - failOnAutomaticModules = true // Only allow Jars with 'module-info' on all module paths - - module("io.grpc:grpc-api", "io.grpc") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - uses("io.grpc.ManagedChannelProvider") - uses("io.grpc.NameResolverProvider") - uses("io.grpc.LoadBalancerProvider") - } - - module("io.grpc:grpc-core", "io.grpc.internal") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - } - module("io.grpc:grpc-context", "io.grpc.context") - module("io.grpc:grpc-stub", "io.grpc.stub") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - } - module("io.grpc:grpc-testing", "io.grpc.testing") - module("io.grpc:grpc-services", "io.grpc.services") - module("io.grpc:grpc-util", "io.grpc.util") - module("io.grpc:grpc-protobuf", "io.grpc.protobuf") - module("io.grpc:grpc-protobuf-lite", "io.grpc.protobuf.lite") - - module("io.grpc:grpc-netty-shaded", "io.grpc.netty.shaded") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - requires("jdk.unsupported") - ignoreServiceProvider("reactor.blockhound.integration.BlockHoundIntegration") - } - - module("com.github.spotbugs:spotbugs-annotations", "com.github.spotbugs.annotations") - module("com.google.code.findbugs:jsr305", "java.annotation") { - exportAllPackages() - mergeJar("javax.annotation:javax.annotation-api") - } - module("com.google.errorprone:error_prone_annotations", "com.google.errorprone.annotations") - module("com.google.j2objc:j2objc-annotations", "com.google.j2objc.annotations") - module("com.google.protobuf:protobuf-java", "com.google.protobuf") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - } - module("com.google.guava:guava", "com.google.common") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - } - module("com.google.guava:failureaccess", "com.google.common.util.concurrent.internal") - module("com.google.api.grpc:proto-google-common-protos", "com.google.api.grpc.common") - module("com.google.dagger:dagger", "dagger") - module("io.perfmark:perfmark-api", "io.perfmark") - module("javax.inject:javax.inject", "javax.inject") - - module("commons-codec:commons-codec", "org.apache.commons.codec") - module("org.apache.commons:commons-math3", "org.apache.commons.math3") - module("org.apache.commons:commons-collections4", "org.apache.commons.collections4") - module("com.esaulpaugh:headlong", "headlong") - - module("org.checkerframework:checker-qual", "org.checkerframework.checker.qual") - module("net.i2p.crypto:eddsa", "net.i2p.crypto.eddsa") - module("org.jetbrains:annotations", "org.jetbrains.annotations") - module("org.antlr:antlr4-runtime", "org.antlr.antlr4.runtime") - - // needed for metrics and logging, but also several platform classes - module("com.goterl:resource-loader", "resource.loader") - module("com.goterl:lazysodium-java", "lazysodium.java") - module("org.hyperledger.besu:secp256k1", "org.hyperledger.besu.nativelib.secp256k1") - module("net.java.dev.jna:jna", "com.sun.jna") { - exportAllPackages() - requires("java.logging") - } - module("io.prometheus:simpleclient", "io.prometheus.simpleclient") - module("io.prometheus:simpleclient_common", "io.prometheus.simpleclient_common") - module("io.prometheus:simpleclient_httpserver", "io.prometheus.simpleclient.httpserver") { - exportAllPackages() - requireAllDefinedDependencies() - requires("jdk.httpserver") - } - - // Annotation processing only - module("com.google.auto.service:auto-service-annotations", "com.google.auto.service") - module("com.google.auto.service:auto-service", "com.google.auto.service.processor") - module("com.google.auto:auto-common", "com.google.auto.common") - module("com.google.dagger:dagger-compiler", "dagger.compiler") - module("com.google.dagger:dagger-producers", "dagger.producers") - module("com.google.dagger:dagger-spi", "dagger.spi") - module( - "com.google.devtools.ksp:symbol-processing-api", - "com.google.devtools.ksp.symbolprocessingapi" - ) - module("com.google.errorprone:javac-shaded", "com.google.errorprone.javac.shaded") - module("com.google.googlejavaformat:google-java-format", "com.google.googlejavaformat") - module("net.ltgt.gradle.incap:incap", "net.ltgt.gradle.incap") - module("org.jetbrains.kotlinx:kotlinx-metadata-jvm", "kotlinx.metadata.jvm") - - // Test clients only - module("com.github.docker-java:docker-java-api", "com.github.dockerjava.api") - module("com.github.docker-java:docker-java-transport", "com.github.dockerjava.transport") - module( - "com.github.docker-java:docker-java-transport-zerodep", - "com.github.dockerjava.transport.zerodep" - ) - module("io.github.cdimascio:java-dotenv", "io.github.cdimascio") - module("com.google.protobuf:protobuf-java-util", "com.google.protobuf.util") - module("com.squareup:javapoet", "com.squareup.javapoet") { - exportAllPackages() - requires("java.compiler") - } - module("junit:junit", "junit") - module("org.hamcrest:hamcrest", "org.hamcrest") - module("org.json:json", "org.json") - module("org.mockito:mockito-core", "org.mockito") - module("org.objenesis:objenesis", "org.objenesis") - module("org.rnorth.duct-tape:duct-tape", "org.rnorth.ducttape") - module("org.testcontainers:junit-jupiter", "org.testcontainers.junit.jupiter") - module("org.testcontainers:testcontainers", "org.testcontainers") - module("org.mockito:mockito-junit-jupiter", "org.mockito.junit.jupiter") -} - -// Make 'javax.annotation:javax.annotation-api' discoverable for merging it into -// 'com.google.code.findbugs:jsr305' -dependencies { "javaModulesMergeJars"("javax.annotation:javax.annotation-api:1.3.2") } diff --git a/buildSrc/src/main/kotlin/com.hedera.block.maven-publish.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.maven-publish.gradle.kts deleted file mode 100644 index 4e6aaabfd..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.maven-publish.gradle.kts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id("java") - id("maven-publish") - id("signing") -} - -publishing { - publications.withType().configureEach { - pom { - packaging = findProperty("maven.project.packaging")?.toString() ?: "jar" - name.set(project.name) - url.set("https://www.hedera.com/") - inceptionYear.set("2024") - - description.set( - "An implementation of a Block Node for the Hedera public distributed ledger." - ) - - organization { - name.set("Hedera Hashgraph, LLC") - url.set("https://www.hedera.com") - } - - licenses { - license { - name.set("Apache 2.0 License") - url.set("https://raw.githubusercontent.com/hashgraph/pbj/main/LICENSE") - } - } - - developers { - developer { - name.set("Jasper Potts") - email.set("jasper.potts@swirldslabs.com") - organization.set("Swirlds Labs, Inc.") - organizationUrl.set("https://www.swirldslabs.com") - } - } - - scm { - connection.set("scm:git:git://github.com/hashgraph/hedera-block-node.git") - developerConnection.set("scm:git:ssh://github.com:hashgraph/hedera-block-node.git") - url.set("https://github.com/hashgraph/hedera-block-node") - } - } - } -} - -signing { useGpgCmd() } - -tasks.withType { - onlyIf { providers.gradleProperty("publishSigningEnabled").getOrElse("false").toBoolean() } -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.protobuf.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.protobuf.gradle.kts deleted file mode 100644 index 359e50c5c..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.protobuf.gradle.kts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.google.protobuf.gradle.id -import com.hedera.block.tasks.GitClone - -plugins { - id("java-library") - id("com.hedera.block.conventions") - id("com.google.protobuf") -} - -tasks.register("cloneHederaProtobufs") { - url = "https://github.com/hashgraph/hedera-protobufs.git" - offline = gradle.startParameter.isOffline - localCloneDirectory = layout.buildDirectory.dir("hedera-protobufs") -} - -// Configure Protobuf Plugin to download protoc executable rather than using local installed version -protobuf { - val libs = the().named("libs") - protoc { artifact = "com.google.protobuf:protoc:" + libs.findVersion("google.proto").get() } - plugins { - // Add GRPC plugin as we need to generate GRPC services - id("grpc") { - artifact = - "io.grpc:protoc-gen-grpc-java:" + libs.findVersion("grpc.protobuf.grpc").get() - } - } - generateProtoTasks { all().forEach { it.plugins { id("grpc") } } } -} - -tasks.javadoc { - options { - this as StandardJavadocDocletOptions - // There are violations in the generated protobuf code - addStringOption("Xdoclint:-reference,-html", "-quiet") - } -} - -// Give JUnit more ram and make it execute tests in parallel -tasks.test { - // We are running a lot of tests 10s of thousands, so they need to run in parallel. Make each - // class run in parallel. - systemProperties["junit.jupiter.execution.parallel.enabled"] = true - systemProperties["junit.jupiter.execution.parallel.mode.default"] = "concurrent" - // limit amount of threads, so we do not use all CPU - systemProperties["junit.jupiter.execution.parallel.config.dynamic.factor"] = "0.9" -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.protos.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.protos.gradle.kts deleted file mode 100644 index 291f89918..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.protos.gradle.kts +++ /dev/null @@ -1,22 +0,0 @@ -plugins { - id("java") - id("com.google.protobuf") - id("com.hedera.block.conventions") -} - -sourceSets { - main { - proto { - srcDir("src/main/protobuf") - } - } -} - -protobuf { - // Configure the protoc executable - protoc { - // Download from repositories - artifact = "com.google.protobuf:protoc:3.21.10" - } -} - diff --git a/buildSrc/src/main/kotlin/com.hedera.block.repositories.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.repositories.gradle.kts deleted file mode 100644 index 6db244ccd..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.repositories.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -repositories { - mavenCentral() - maven { - url = uri("https://hyperledger.jfrog.io/artifactory/besu-maven") - content { includeGroupByRegex("org\\.hyperledger\\..*") } - } -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.root.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.root.gradle.kts deleted file mode 100644 index fbfa2c467..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.root.gradle.kts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import io.github.gradlenexus.publishplugin.CloseNexusStagingRepository - -plugins { - id("com.hedera.block.repositories") - id("com.hedera.block.aggregate-reports") - id("com.hedera.block.spotless-conventions") - id("com.hedera.block.spotless-kotlin-conventions") - id("com.autonomousapps.dependency-analysis") - id("io.github.gradle-nexus.publish-plugin") -} - -group = "com.hedera.block" - -spotless { kotlinGradle { target("buildSrc/**/*.gradle.kts") } } - -nexusPublishing { - repositories { - sonatype { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") - } - } -} - -tasks.withType { - // The publishing of all components to Maven Central (in this case only 'pbj-runtime') is - // automatically done before close (which is done before release). - dependsOn(":server:publishToSonatype") -} - -tasks.register("release") { - group = "release" - dependsOn(tasks.closeAndReleaseStagingRepository) -} - -tasks.register("releaseSnapshot") { - group = "release" - dependsOn(":server:publishToSonatype") -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.server.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.server.gradle.kts deleted file mode 100644 index 5bb202c3b..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.server.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id("application") - id("com.hedera.block.conventions") - id("me.champeau.jmh") -} - -val maven = publishing.publications.create("maven") { from(components["java"]) } - -signing.sign(maven) - diff --git a/buildSrc/src/main/kotlin/com.hedera.block.simulator.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.simulator.gradle.kts deleted file mode 100644 index f5361b330..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.simulator.gradle.kts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id("application") - id("com.hedera.block.conventions") - id("me.champeau.jmh") -} - -val maven = publishing.publications.create("maven") { from(components["java"]) } - -signing.sign(maven) diff --git a/buildSrc/src/main/kotlin/com.hedera.block.spotless-conventions.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.spotless-conventions.gradle.kts deleted file mode 100644 index f83772726..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.spotless-conventions.gradle.kts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { id("com.diffplug.spotless") } - -spotless { - // Disable strong enforcement during gradle check tasks - isEnforceCheck = false - - // optional: limit format enforcement to just the files changed by this feature branch - ratchetFrom("origin/main") - - format("misc") { - // define the files to apply `misc` to - target("*.gradle", "*.md", ".gitignore") - - // define the steps to apply to those files - trimTrailingWhitespace() - indentWithSpaces() - endWithNewline() - } - - format("actionYaml") { - target(".github/workflows/*.yaml") - - trimTrailingWhitespace() - indentWithSpaces() - endWithNewline() - - licenseHeader( - """ - ## - # Copyright (C) ${'$'}YEAR Hedera Hashgraph, LLC - # - # Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - ## - """ - .trimIndent(), - "(name|on)" - ) - } -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.spotless-java-conventions.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.spotless-java-conventions.gradle.kts deleted file mode 100644 index 54f051165..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.spotless-java-conventions.gradle.kts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { id("com.diffplug.spotless") } - -spotless { - java { - targetExclude("build/generated/**/*.java", "build/generated/**/*.proto") - // enable toggle comment support - toggleOffOn() - // don't need to set target, it is inferred from java - // apply a specific flavor of google-java-format - googleJavaFormat("1.17.0").aosp().reflowLongStrings() - // make sure every file has the following copyright header. - // optionally, Spotless can set copyright years by digging - // through git history (see "license" section below). - // The delimiter override below is required to support some - // of our test classes which are in the default package. - licenseHeader( - """ - /* - * Copyright (C) ${'$'}YEAR Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */${"\n\n"} - """ - .trimIndent(), - "(package|import)" - ) - } -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.spotless-kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.spotless-kotlin-conventions.gradle.kts deleted file mode 100644 index 430a8944f..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.spotless-kotlin-conventions.gradle.kts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { id("com.diffplug.spotless") } - -spotless { - kotlinGradle { - ktfmt().kotlinlangStyle() - - licenseHeader( - """ - /* - * Copyright (C) ${'$'}YEAR Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */${"\n\n"} - """ - .trimIndent(), - "(import|plugins|repositories)", - ) - } -} diff --git a/buildSrc/src/main/kotlin/com.hedera.block.suites.gradle.kts b/buildSrc/src/main/kotlin/com.hedera.block.suites.gradle.kts deleted file mode 100644 index f5361b330..000000000 --- a/buildSrc/src/main/kotlin/com.hedera.block.suites.gradle.kts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id("application") - id("com.hedera.block.conventions") - id("me.champeau.jmh") -} - -val maven = publishing.publications.create("maven") { from(components["java"]) } - -signing.sign(maven) diff --git a/buildSrc/src/main/kotlin/com/hedera/block/tasks/GitClone.kt b/buildSrc/src/main/kotlin/com/hedera/block/tasks/GitClone.kt deleted file mode 100644 index d47c11dc6..000000000 --- a/buildSrc/src/main/kotlin/com/hedera/block/tasks/GitClone.kt +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hedera.block.tasks - -import javax.inject.Inject -import org.gradle.api.DefaultTask -import org.gradle.api.file.DirectoryProperty -import org.gradle.api.provider.Property -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.TaskAction -import org.gradle.process.ExecOperations - -abstract class GitClone : DefaultTask() { - - @get:Input abstract val url: Property - - @get:Input @get:Optional abstract val tag: Property - - @get:Input @get:Optional abstract val branch: Property - - @get:Input abstract val offline: Property - - @get:OutputDirectory abstract val localCloneDirectory: DirectoryProperty - - @get:Inject protected abstract val exec: ExecOperations - - init { - // If a 'branch' is configured, the task is never up-to-date as it may change - outputs.upToDateWhen { !branch.isPresent } - } - - @TaskAction - fun cloneOrUpdate() { - if (!tag.isPresent && !branch.isPresent || tag.isPresent && branch.isPresent) { - throw RuntimeException("Define either 'tag' or 'branch'") - } - - val localClone = localCloneDirectory.get() - if (!offline.get()) { - exec.exec { - if (!localClone.dir(".git").asFile.exists()) { - workingDir = localClone.asFile.parentFile - commandLine( - "git", - "clone", - url.get(), - "-q" - ) - } else { - workingDir = localClone.asFile - commandLine("git", "fetch", "-q") - } - } - } - if (tag.isPresent) { - exec.exec { - workingDir = localClone.asFile - commandLine("git", "checkout", tag.get(), "-q") - } - exec.exec { - workingDir = localClone.asFile - commandLine("git", "reset", "--hard", tag.get(), "-q") - } - } else { - exec.exec { - workingDir = localClone.asFile - commandLine("git", "checkout", branch.get(), "-q") - } - exec.exec { - workingDir = localClone.asFile - commandLine("git", "reset", "--hard", "origin/${branch.get()}", "-q") - } - } - } -} diff --git a/developers.properties b/developers.properties new file mode 100644 index 000000000..21765ad53 --- /dev/null +++ b/developers.properties @@ -0,0 +1 @@ +hedera-base@hashgraph.com=Hedera Base Team diff --git a/gradle.properties b/gradle.properties index 7157575a1..4fac13161 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,11 @@ -# Version number -version=0.2.0-SNAPSHOT - # Need increased heap for running Gradle itself, or SonarQube will run the JVM out of metaspace -org.gradle.jvmargs=-Xmx2048m +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# Enable Gradle Caching +# Enable Gradle caching +org.gradle.configuration-cache=true org.gradle.caching=true + +# Enable parallel workers org.gradle.parallel=true # Disable publish signing by default diff --git a/gradle/aggregation/build.gradle.kts b/gradle/aggregation/build.gradle.kts new file mode 100644 index 000000000..86f0c3687 --- /dev/null +++ b/gradle/aggregation/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + id("com.hedera.gradle.report.code-coverage") +} + +dependencies { + implementation(project(":server")) + implementation(project(":simulator")) + implementation(project(":suites")) +} diff --git a/gradle/jdk-version.txt b/gradle/jdk-version.txt new file mode 100644 index 000000000..f222bf6f4 --- /dev/null +++ b/gradle/jdk-version.txt @@ -0,0 +1 @@ +21.0.4 diff --git a/gradle/modules.properties b/gradle/modules.properties deleted file mode 100644 index b63ad263a..000000000 --- a/gradle/modules.properties +++ /dev/null @@ -1,50 +0,0 @@ -com.swirlds.metrics.api=com.swirlds:swirlds-metrics-api -com.swirlds.metrics.impl=com.swirlds:swirlds-metrics-impl -com.swirlds.common=com.swirlds:swirlds-common -com.swirlds.config.impl=com.swirlds:swirlds-config-impl -com.swirlds.config.extensions=com.swirlds:swirlds-config-extensions -com.swirlds.config.processor=com.swirlds:swirlds-config-processor -com.google.auto.service=com.google.auto.service:auto-service-annotations -com.google.auto.service.processor=com.google.auto.service:auto-service -com.google.auto.common=com.google.auto:auto-common -com.github.spotbugs.annotations=com.github.spotbugs:spotbugs-annotations -com.lmax.disruptor=com.lmax:disruptor -io.helidon.webserver=io.helidon.webserver:helidon-webserver -io.helidon.webserver.grpc=io.helidon.webserver:helidon-webserver-grpc - -io.helidon.webserver.testing.junit5=io.helidon.webserver.testing.junit5:helidon-webserver-testing-junit5 - -io.helidon.logging=io.helidon.logging:helidon-logging-jul -org.antlr.antlr4.runtime=org.antlr:antlr4-runtime -com.google.common=com.google.guava:guava - -google.proto=com.google.protobuf:protoc -io.grpc=io.grpc:grpc-api -io.grpc.protobuf=io.grpc:grpc-protobuf -io.grpc.stub=io.grpc:grpc-stub -io.grpc.netty.shaded=io.grpc:grpc-netty-shaded - -com.hedera.pbj.runtime=com.hedera.pbj:pbj-runtime -com.google.protobuf=com.google.protobuf:protobuf-java -com.google.protobuf.util=com.google.protobuf:protobuf-java-util -com.apache.commons.codec=commons-codec:commons-codec -org.apache.commons.collections4=org.apache.commons:commons-collections4 -org.apache.commons.io=commons-io:commons-io -org.apache.commons.lang3=org.apache.commons:commons-lang3 -org.apache.commons.compress=org.apache.commons:commons-compress - -org.testcontainers=org.testcontainers:testcontainers -org.testcontainers.junit-jupiter=org.testcontainers:junit-jupiter -com.github.dockerjava.api=com.github.docker-java:docker-java-api -com.github.docker-java.transport.zerodep=com.github.docker-java:docker-java-transport-zerodep -com.github.docker-java.transport.httpclient5=com.github.docker-java:docker-java-transport-httpclient5 -io.github.cdimascio=io.github.cdimascio:java-dotenv - -java.annotation=javax.annotation:javax.annotation-api -org.apache.logging.log4j.slf4j2.impl=org.apache.logging.log4j:log4j-slf4j2-impl - -dagger=com.google.dagger:dagger -dagger.compiler=com.google.dagger:dagger-compiler -com.squareup.javapoet=com.squareup:javapoet -javax.inject=javax.inject:javax.inject -org.checkerframework.checker.qual=org.checkerframework:checker-qual diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd4917..a4b76b953 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138c..df97d72b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a426..f5feea6d6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 6689b85be..9b42019c7 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/hedera-dependency-versions/build.gradle.kts b/hedera-dependency-versions/build.gradle.kts new file mode 100644 index 000000000..157f3e544 --- /dev/null +++ b/hedera-dependency-versions/build.gradle.kts @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2023 Hedera Hashgraph, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("com.hedera.gradle.base.lifecycle") + id("com.hedera.gradle.base.jpms-modules") +} + +dependencies.constraints { + // Define a constant for the platform SDK version. + // Platform SDK modules are all released together with matching versions. + val swirldsVersion = "0.51.5" + val daggerVersion = "2.42" + val grpcVersion = "1.65.1" + + api("com.github.spotbugs:spotbugs-annotations:4.7.3") { because("com.github.spotbugs.annotations") } + api("com.google.auto.service:auto-service-annotations:1.1.1") { because("com.google.auto.service") } + api("com.google.guava:guava:33.3.1-jre") { because("com.google.common") } + api("com.google.j2objc:j2objc-annotations:3.0.0") { because("com.google.j2objc.annotations") } + api("com.google.protobuf:protobuf-java-util:4.28.2") { because("com.google.protobuf.util") } + api("com.google.protobuf:protoc:4.28.2") { because("google.proto") } + api("com.hedera.pbj:pbj-runtime:0.9.2") { because("com.hedera.pbj.runtime") } + api("com.lmax:disruptor:4.0.0") { because("com.lmax.disruptor") } + api("com.swirlds:swirlds-common:$swirldsVersion") { because("com.swirlds.common") } + api("com.swirlds:swirlds-config-impl:$swirldsVersion") { because("com.swirlds.config.impl") } + api("io.helidon.logging:helidon-logging-jul:4.1.0") { because("io.helidon.logging.jul") } + api("io.helidon.webserver:helidon-webserver-grpc:4.1.0") { because("io.helidon.webserver.grpc") } + api("io.helidon.webserver:helidon-webserver:4.1.0") { because("io.helidon.webserver") } + + // gRPC dependencies + api("io.grpc:grpc-api:$grpcVersion") { because("io.grpc") } + api("io.grpc:grpc-stub:$grpcVersion") { because("io.grpc.stub") } + api("io.grpc:grpc-protobuf:$grpcVersion") { because("io.grpc.protobuf") } + api("io.grpc:grpc-netty:$grpcVersion") { because("io.grpc.netty") } + api("io.grpc:protoc-gen-grpc-java:1.66.0") { because("XXXXX") } + + // needed for dagger + api("com.google.dagger:dagger:$daggerVersion") { because("dagger") } + api("com.google.dagger:dagger-compiler:$daggerVersion") { because("dagger.compiler") } + api("com.squareup:javapoet:1.13.0") { because("com.squareup.javapoet") } + + // Testing only versions + api("org.junit.jupiter:junit-jupiter-api:5.10.2") { because("org.junit.jupiter.api") } + api("org.mockito:mockito-core:5.8.0") { because("org.mockito") } + api("org.mockito:mockito-junit-jupiter:5.8.0") { because("org.mockito.junit.jupiter") } + api("org.testcontainers:testcontainers:1.20.1") { because("org.testcontainers") } + api("org.testcontainers:junit-jupiter:1.20.1") { because("org.testcontainers.junit.jupiter") } + api("com.github.docker-java:docker-java-api:3.4.0") { because("com.github.dockerjava.api") } + api("io.github.cdimascio:dotenv-java:3.0.2") { because("io.github.cdimascio.dotenv.java") } + + api("com.google.auto.service:auto-service:1.1.1") { because("com.google.auto.service.processor") } + api("com.google.dagger:dagger-compiler:$daggerVersion") { because("dagger.compiler") } +} + + diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 828a0e5f7..98f913572 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -15,10 +15,14 @@ */ plugins { + id("com.hedera.gradle.module.library") id("application") - id("com.hedera.block.server") } +// Remove the following line to enable all 'javac' lint checks that we have turned on by default +// and then fix the reported issues. +tasks.withType().configureEach { options.compilerArgs.add("-Xlint:-exports") } + application { mainModule = "com.hedera.block.server" mainClass = "com.hedera.block.server.Server" @@ -29,7 +33,7 @@ mainModuleInfo { annotationProcessor("com.google.auto.service.processor") runtimeOnly("com.swirlds.config.impl") runtimeOnly("org.apache.logging.log4j.slf4j2.impl") - runtimeOnly("io.helidon.logging") + runtimeOnly("io.helidon.logging.jul") } testModuleInfo { diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index ccd73557f..cfefafbf8 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -18,14 +18,14 @@ exports com.hedera.block.server.notifier; exports com.hedera.block.server.service; - requires com.hedera.block.stream; - requires com.google.protobuf; - requires com.hedera.pbj.runtime; - requires com.lmax.disruptor; requires com.swirlds.common; requires com.swirlds.config.api; requires com.swirlds.config.extensions; requires com.swirlds.metrics.api; + requires com.google.protobuf; + requires com.hedera.block.stream; + requires com.hedera.pbj.runtime; + requires com.lmax.disruptor; requires dagger; requires io.grpc.stub; requires io.helidon.common; @@ -35,6 +35,7 @@ requires javax.inject; requires static com.github.spotbugs.annotations; requires static com.google.auto.service; + requires static java.compiler; // javax.annotation.processing.Generated provides com.swirlds.config.api.ConfigurationExtension with BlockNodeConfigExtension; diff --git a/settings.gradle.kts b/settings.gradle.kts index 9dd268f44..2104e797d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -14,124 +14,18 @@ * limitations under the License. */ -plugins { - id("com.gradle.enterprise").version("3.15.1") +pluginManagement { + repositories.gradlePluginPortal() + repositories.maven("https://repo.onepiece.software/snapshots") } -// Include the subprojects -include(":suites") -include(":stream") -include(":server") -include(":simulator") +plugins { id("com.hedera.gradle.build") version "0.0.2" } -includeBuild(".") // https://github.com/gradle/gradle/issues/21490#issuecomment-1458887481 +rootProject.name = "hedera-block-node" -gradleEnterprise { - buildScan { - termsOfServiceUrl = "https://gradle.com/terms-of-service" - termsOfServiceAgree = "yes" - } -} - -dependencyResolutionManagement { - versionCatalogs { - create("libs") { - // Define a constant for the platform SDK version. - // Platform SDK modules are all released together with matching versions. - val swirldsVersion = "0.51.5" - - // Define a constant for the Dagger version. - val daggerVersion = "2.42" - - // Define a constant for protobuf version. - val protobufVersion = "4.28.2" - - // Compile time dependencies - version("io.helidon.webserver.http2", "4.1.0") - version("io.helidon.webserver.grpc", "4.1.0") - version("io.helidon.logging", "4.1.0") - version("com.lmax.disruptor", "4.0.0") - version("com.github.spotbugs.annotations", "4.7.3") - version("com.swirlds.metrics.api", swirldsVersion) - version("com.swirlds.metrics.impl", swirldsVersion) - version("com.swirlds.common", swirldsVersion) - version("com.swirlds.config.impl", swirldsVersion) - version("com.swirlds.config.processor", swirldsVersion) - version("com.swirlds.config.extensions", swirldsVersion) - version("com.google.auto.service.processor", "1.1.1") - version("com.google.auto.service", "1.1.1") - version("org.hyperledger.besu.nativelib.secp256k1", "0.8.2") - - // gRPC dependencies - version("io.grpc", "1.65.1") - version("io.grpc.protobuf", "1.65.1") - version("io.grpc.stub", "1.65.1") - version("io.grpc.netty.shaded", "1.65.1") - - // Reference from the protobuf plugin - version("google.proto", protobufVersion) - version("grpc.protobuf.grpc", "1.65.1") - - // Google protobuf dependencies - version("com.google.protobuf", protobufVersion) - version("com.google.protobuf.util", protobufVersion) - - // PBJ dependencies - plugin("pbj", "com.hedera.pbj.pbj-compiler").version("0.9.2") - version("com.hedera.pbj.runtime", "0.9.2") - version("org.antlr.antlr4.runtime", "4.13.1") - - version("java.annotation", "1.3.2") - version("javax.inject", "1") - version("com.google.common", "33.0.0-jre") - - version("org.apache.commons.codec", "1.15") - version("org.apache.commons.collections4", "4.4") - version("org.apache.commons.io", "2.15.1") - version("org.apache.commons.lang3", "3.14.0") - version("org.apache.commons.compress", "1.26.0") - version("org.apache.logging.log4j.slf4j2.impl", "2.21.1") - - // needed for dagger - version("dagger", daggerVersion) - version("dagger.compiler", daggerVersion) - version("com.squareup.javapoet", "1.13.0") - - // Testing only versions - version("org.assertj.core", "3.23.1") - version("org.junit.jupiter.api", "5.10.2") - version("org.junit.platform", "1.11.0") - version("org.mockito", "5.8.0") - version("org.mockito.junit.jupiter", "5.8.0") - version("org.testcontainers", "1.20.1") - version("org.testcontainers.junit-jupiter", "1.20.1") - version("com.github.docker-java", "3.4.0") - version("io.github.cdimascio", "5.2.2") - } - } -} - - -// Build cache configuration -val isCiServer = System.getenv().containsKey("CI") -val gradleCacheUsername: String? = System.getenv("GRADLE_CACHE_USERNAME") -val gradleCachePassword: String? = System.getenv("GRADLE_CACHE_PASSWORD") -val gradleCacheAuthorized = - (gradleCacheUsername?.isNotEmpty() ?: false) && (gradleCachePassword?.isNotEmpty() ?: false) - -buildCache { - remote { - url = uri("https://cache.gradle.hedera.svcs.eng.swirldslabs.io/cache/") - isPush = isCiServer && gradleCacheAuthorized - - isUseExpectContinue = true - isEnabled = !gradle.startParameter.isOffline - - if (isCiServer && gradleCacheAuthorized) { - credentials { - username = gradleCacheUsername - password = gradleCachePassword - } - } +javaModules { + directory(".") { + group = "com.hedera.block" + module("suites") // no 'module-info' yet } } diff --git a/simulator/build.gradle.kts b/simulator/build.gradle.kts index ea112413a..30471e37e 100644 --- a/simulator/build.gradle.kts +++ b/simulator/build.gradle.kts @@ -16,11 +16,15 @@ plugins { id("application") - id("com.hedera.block.simulator") + id("com.hedera.gradle.module.library") } description = "Hedera Block Stream Simulator" +// Remove the following line to enable all 'javac' lint checks that we have turned on by default +// and then fix the reported issues. +tasks.withType().configureEach { options.compilerArgs.add("-Xlint:-exports") } + application { mainModule = "com.hedera.block.simulator" mainClass = "com.hedera.block.simulator.BlockStreamSimulator" @@ -31,15 +35,15 @@ mainModuleInfo { annotationProcessor("com.google.auto.service.processor") runtimeOnly("com.swirlds.config.impl") runtimeOnly("org.apache.logging.log4j.slf4j2.impl") - runtimeOnly("io.grpc.netty.shaded") + runtimeOnly("io.grpc.netty") } testModuleInfo { requires("org.junit.jupiter.api") requires("org.mockito") requires("org.mockito.junit.jupiter") - requiresStatic("com.github.spotbugs.annotations") requires("com.swirlds.common") + requiresStatic("com.github.spotbugs.annotations") } tasks.register("untarTestBlockStream") { diff --git a/simulator/src/main/java/module-info.java b/simulator/src/main/java/module-info.java index ddca45813..e1bc9e909 100644 --- a/simulator/src/main/java/module-info.java +++ b/simulator/src/main/java/module-info.java @@ -6,17 +6,18 @@ exports com.hedera.block.simulator.exception; exports com.hedera.block.simulator; - requires static com.github.spotbugs.annotations; - requires static com.google.auto.service; - requires com.hedera.block.stream; - requires com.google.protobuf; - requires com.hedera.pbj.runtime; requires com.swirlds.config.api; requires com.swirlds.config.extensions; + requires com.google.protobuf; + requires com.hedera.block.stream; + requires com.hedera.pbj.runtime; requires dagger; requires io.grpc.stub; requires io.grpc; requires javax.inject; + requires static com.github.spotbugs.annotations; + requires static com.google.auto.service; + requires static java.compiler; // javax.annotation.processing.Generated provides com.swirlds.config.api.ConfigurationExtension with SimulatorConfigExtension; diff --git a/stream/build.gradle.kts b/stream/build.gradle.kts index d2d8d391a..84c9323d6 100644 --- a/stream/build.gradle.kts +++ b/stream/build.gradle.kts @@ -14,13 +14,14 @@ * limitations under the License. */ +import com.hedera.gradle.tasks.GitClone + plugins { - id("com.hedera.block.protobuf") - alias(libs.plugins.pbj) + id("com.hedera.gradle.module.library") + id("com.hedera.gradle.feature.protobuf") + id("com.hedera.pbj.pbj-compiler") version "0.9.2" } -group = "com.hedera.block" - description = "Hedera API" // Remove the following line to enable all 'javac' lint checks that we have turned on by default @@ -30,28 +31,31 @@ tasks.withType().configureEach { } // Add downloaded HAPI repo protobuf files into build directory and add to sources to build them -tasks.cloneHederaProtobufs { - // uncomment below to use a specific tag - // tag = "v0.53.0" or a specific commit like "0047255" - tag = "d5e6988" +val cloneHederaProtobufs = + tasks.register("cloneHederaProtobufs") { + url = "https://github.com/hashgraph/hedera-protobufs.git" - // uncomment below to use a specific branch - // branch = "main" -} + // uncomment below to use a specific tag + // tag = "v0.53.0" or a specific commit like "0047255" + tag = "d5e6988" + + // uncomment below to use a specific branch + // branch = "main" + } sourceSets { main { pbj { - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("services") }) - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("block") }) - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("platform") }) - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("streams") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("services") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("block") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("platform") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("streams") }) } proto { - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("services") }) - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("block") }) - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("platform") }) - srcDir(tasks.cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("streams") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("services") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("block") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("platform") }) + srcDir(cloneHederaProtobufs.flatMap { it.localCloneDirectory.dir("streams") }) } } } diff --git a/stream/src/main/java/module-info.java b/stream/src/main/java/module-info.java index f557cc459..0cde0ce26 100644 --- a/stream/src/main/java/module-info.java +++ b/stream/src/main/java/module-info.java @@ -1,6 +1,6 @@ module com.hedera.block.stream { exports com.hedera.hapi.block; - exports com.hedera.hapi.block.protoc; + exports com.hedera.hapi.block.protoc; // TODO move to test fixtures exports com.hedera.hapi.block.stream.protoc; exports com.hedera.hapi.block.stream; exports com.hedera.hapi.block.stream.input; diff --git a/suites/build.gradle.kts b/suites/build.gradle.kts index d5d5534ee..6114aff66 100644 --- a/suites/build.gradle.kts +++ b/suites/build.gradle.kts @@ -16,28 +16,23 @@ plugins { id("application") - id("com.hedera.block.suites") + id("com.hedera.gradle.module.library") } description = "Hedera Block Node E2E Suites" -dependencies { implementation(project(":simulator")) } - application { mainModule = "com.hedera.block.suites" mainClass = "com.hedera.block.suites.BaseSuite" } mainModuleInfo { - runtimeOnly("org.testcontainers.junit-jupiter") + runtimeOnly("org.testcontainers.junit.jupiter") runtimeOnly("org.junit.jupiter.engine") runtimeOnly("org.testcontainers") runtimeOnly("com.swirlds.config.impl") } -// workaround until https://github.com/hashgraph/hedera-block-node/pull/216 is integrated -dependencies.constraints { implementation("org.slf4j:slf4j-api:2.0.6") } - val updateDockerEnv = tasks.register("updateDockerEnv") { description = diff --git a/suites/src/main/java/module-info.java b/suites/src/main/java/module-info.java index 513183446..e6ba022de 100644 --- a/suites/src/main/java/module-info.java +++ b/suites/src/main/java/module-info.java @@ -1,14 +1,14 @@ /** Runtime module of the suites. */ module com.hedera.block.node.suites { - requires com.hedera.block.simulator; + // Require testing libraries requires com.swirlds.config.api; requires com.swirlds.config.extensions; - - // Require testing libraries - requires io.github.cdimascio; + requires com.hedera.block.simulator; + requires io.github.cdimascio.dotenv.java; requires org.junit.jupiter.api; requires org.junit.platform.suite.api; requires org.testcontainers; + requires static dagger; exports com.hedera.block.suites to org.junit.platform.commons; diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..d144648c3 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.2.0-SNAPSHOT