diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b6fadf82d..3eeecf5cc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,7 @@ version: 2 updates: - package-ecosystem: gradle - directory: "/sdk-dependency-versions" + directory: "/hiero-dependency-versions" schedule: interval: weekly open-pull-requests-limit: 10 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cfd79c6f1..d5a809d12 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 name: PR Checks on: @@ -88,8 +89,8 @@ jobs: - name: Build SDK run: ./gradlew assemble --scan - - name: Gradle Dependency Scopes Check - run: ./gradlew checkAllModuleInfo --continue --scan + - name: Code Quality Checks + run: ./gradlew qualityCheck :examples:qualityCheck --continue --scan - name: Start Local Node run: npx @hashgraph/hedera-local start -d --network local --network-tag=0.57.0 @@ -204,7 +205,7 @@ jobs: run: npx @hashgraph/hedera-local start -d --network local - name: Run TCK Unit Tests - run: ./gradlew :tck:test + run: ./gradlew :tck:test --scan - name: Stop the local node run: npx @hashgraph/hedera-local stop diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index a04f48204..fb5d8aa71 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 name: Release Artifacts on: @@ -125,4 +126,7 @@ jobs: - name: Nexus Release if: ${{ github.event_name == 'push' }} - run: ./gradlew closeAndReleaseSonatypeStagingRepository --no-configuration-cache --scan -PsonatypeUsername=${{ secrets.SONATYPE_USERNAME }} -PsonatypePassword=${{ secrets.SONATYPE_PASSWORD }} + env: + NEXUS_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + NEXUS_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: ./gradlew releaseMavenCentral -PpublishingPackageGroup=com.hedera.hashgraph -PpublishSigningEnabled=true --scan --no-configuration-cache diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 7f58403aa..000000000 --- a/build.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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.gradle.root") -} - -dependencyAnalysis.abi { - exclusions { - // Exposes: org.slf4j.Logger - excludeClasses("logger") - // Exposes: com.google.common.base.MoreObjects.ToStringHelper - excludeClasses(".*\\.CustomFee") - // Exposes: com.esaulpaugh.headlong.abi.Tuple - excludeClasses(".*\\.ContractFunctionResult") - // Exposes: org.bouncycastle.crypto.params.KeyParameter - excludeClasses(".*\\.PrivateKey.*") - // Exposes: io.grpc.stub.AbstractFutureStub (and others) - excludeClasses(".*Grpc") - } -} diff --git a/developers.properties b/developers.properties new file mode 100644 index 000000000..faf098b15 --- /dev/null +++ b/developers.properties @@ -0,0 +1 @@ +info@lfdecentralizedtrust.org=The Hiero Team diff --git a/example-android/app/build.gradle.kts b/example-android/app/build.gradle.kts index 9eef3fc9b..afca29380 100644 --- a/example-android/app/build.gradle.kts +++ b/example-android/app/build.gradle.kts @@ -65,7 +65,7 @@ android { dependencies { // --- Remove to use a published SDK version --- - implementation(platform("com.hedera.hashgraph:sdk-dependency-versions")) + implementation(platform("com.hedera.hashgraph:hiero-dependency-versions")) // --------------------------------------------- implementation("com.hedera.hashgraph:sdk:2.46.0") diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index e846f501c..9194b9604 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -1,25 +1,7 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ - +// SPDX-License-Identifier: Apache-2.0 plugins { - id("com.hedera.gradle.examples.java") + id("org.hiero.gradle.module.application") + id("org.gradlex.java-module-dependencies") } mainModuleInfo { @@ -27,12 +9,84 @@ mainModuleInfo { runtimeOnly("org.slf4j.simple") } -dependencies { - implementation("org.bouncycastle:bcpkix-jdk18on:1.78.1") - implementation("org.bouncycastle:bcprov-jdk18on:1.78.1") +// 'com.google.protobuf' implementation is provided through 'sdk' as it differs between 'sdk' and +// 'sdk-full' +dependencyAnalysis { + issues { + all { onUsedTransitiveDependencies { exclude("com.google.protobuf:protobuf-javalite") } } + } } dependencies.constraints { + implementation("io.github.cdimascio:dotenv-java:3.0.2") implementation("com.hedera.hashgraph:sdk:2.46.0") implementation("com.hedera.hashgraph:sdk-full:2.46.0") } + +tasks.register("runAllExamples") { + workingDirectory = rootDir + sources.from(sourceSets.main.get().java.asFileTree) + rtClasspath.from(configurations.runtimeClasspath.get() + files(tasks.jar)) +} + +tasks.addRule("Pattern: run: Runs an example.") { + if (startsWith("run")) { + tasks.register(this) { + workingDir = rootDir + classpath = configurations.runtimeClasspath.get() + files(tasks.jar) + mainModule = "com.hedera.hashgraph.examples" + mainClass = + "com.hedera.hashgraph.sdk.examples.${this@addRule.substring("run".length)}Example" + } + } +} + +abstract class RunAllExample : DefaultTask() { + @get:InputFiles abstract val sources: ConfigurableFileCollection + + @get:InputFiles abstract val rtClasspath: ConfigurableFileCollection + + @get:Internal abstract val workingDirectory: RegularFileProperty + + @get:Inject abstract val exec: ExecOperations + + @TaskAction + fun runAll() { + val exampleClasses = + sources + .filter { it.name.endsWith("Example.java") } + .asSequence() + .map { it.name.replace(".java", "") } + .filter { + it != "ValidateChecksumExample" + } // disabled this example, because it needs user input (but it WORKS) + .filter { + it != "ConsensusPubSubChunkedExample" + } // is flaky on local-node env, will be investigated + .filter { + it != "InitializeClientWithMirrorNetworkExample" + } // disabled - cannot run on localnode + .toList() + + exampleClasses.forEach { className -> + println( + """ + + ---EXECUTING $className: + + """ + .trimIndent() + ) + + exec.javaexec { + workingDir = workingDirectory.get().asFile + classpath = rtClasspath + mainModule = "com.hedera.hashgraph.examples" + mainClass = "com.hedera.hashgraph.sdk.examples.$className" + + // NOTE: Uncomment to enable trace logs in the SDK during the examples + // jvmArgs "-Dorg.slf4j.simpleLogger.log.com.hedera.hashgraph=trace" + } + } + } +} diff --git a/examples/gradle/toolchain-versions.properties b/examples/gradle/toolchain-versions.properties new file mode 100644 index 000000000..f6397fb7d --- /dev/null +++ b/examples/gradle/toolchain-versions.properties @@ -0,0 +1 @@ +jdk=17.0.12 diff --git a/examples/settings.gradle.kts b/examples/settings.gradle.kts index 2a19d1397..709694144 100644 --- a/examples/settings.gradle.kts +++ b/examples/settings.gradle.kts @@ -1,30 +1,7 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ +// SPDX-License-Identifier: Apache-2.0 +plugins { id("org.hiero.gradle.build") version "0.1.0" } -pluginManagement { - includeBuild("../gradle/plugins") - repositories { - gradlePluginPortal() - } -} +@Suppress("UnstableApiUsage") dependencyResolutionManagement { repositories.mavenCentral() } // --- Remove to use a published SDK version --- includeBuild("..") -// --------------------------------------------- diff --git a/examples/src/main/java/module-info.java b/examples/src/main/java/module-info.java index b94bba8ae..7242d5b8c 100644 --- a/examples/src/main/java/module-info.java +++ b/examples/src/main/java/module-info.java @@ -19,13 +19,9 @@ */ module com.hedera.hashgraph.examples { - requires com.hedera.hashgraph.sdk; - // requires com.hedera.hashgraph.sdk.full; - + requires com.hedera.hashgraph.sdk; // .full; requires com.google.gson; - requires java.dotenv; - - requires static java.annotation; - requires com.google.protobuf; + requires io.github.cdimascio.dotenv.java; requires org.bouncycastle.provider; + requires static java.annotation; } diff --git a/examples/version.txt b/examples/version.txt new file mode 100644 index 000000000..b694fe3f6 --- /dev/null +++ b/examples/version.txt @@ -0,0 +1 @@ +0.1.0-SNAPSHOT diff --git a/gradle/aggregation/build.gradle.kts b/gradle/aggregation/build.gradle.kts new file mode 100644 index 000000000..aa94166ca --- /dev/null +++ b/gradle/aggregation/build.gradle.kts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 +plugins { + id("org.hiero.gradle.base.lifecycle") + id("org.hiero.gradle.report.code-coverage") + id("org.hiero.gradle.check.spotless") + id("org.hiero.gradle.check.spotless-kotlin") +} + +dependencies { + implementation(project(":sdk")) + implementation("io.grpc:grpc-protobuf") +} diff --git a/gradle/plugins/build.gradle.kts b/gradle/plugins/build.gradle.kts deleted file mode 100644 index 5ba022d2c..000000000 --- a/gradle/plugins/build.gradle.kts +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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.autonomousapps:dependency-analysis-gradle-plugin:2.6.0") - implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4") - implementation("io.github.gradle-nexus:publish-plugin:1.3.0") - implementation("org.gradlex:extra-java-module-info:1.9") - implementation("org.gradlex:java-module-dependencies:1.6.5") - implementation("org.gradlex:jvm-dependency-conflict-resolution:2.1") - - implementation("org.gradle.toolchains:foojay-resolver:0.8.0") - implementation("com.gradle:develocity-gradle-plugin:3.17.2") -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.base.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.base.gradle.kts deleted file mode 100644 index f048c89cf..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.base.gradle.kts +++ /dev/null @@ -1,22 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ - -group = "com.hedera.hashgraph" -version = providers.fileContents(rootProject.layout.projectDirectory.file("version.txt")).asText.getOrElse("").trim() diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts deleted file mode 100644 index e90786ea4..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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.gradle.java-base") -} - -javaModuleDependencies { - moduleNameToGA.put("com.hedera.hashgraph.sdk", "com.hedera.hashgraph:sdk") - moduleNameToGA.put("com.hedera.hashgraph.sdk.full", "com.hedera.hashgraph:sdk-full") -} - -tasks.register("runAllExamples") { - workingDirectory = rootDir - sources.from(sourceSets.main.get().java.asFileTree) - rtClasspath.from(configurations.runtimeClasspath.get() + files(tasks.jar)) -} - -tasks.addRule("Pattern: run: Runs an example.") { - if (startsWith("run")) { - tasks.register(this) { - workingDir = rootDir - classpath = configurations.runtimeClasspath.get() + files(tasks.jar) - mainModule = "com.hedera.hashgraph.examples" - mainClass = "com.hedera.hashgraph.sdk.examples.${this@addRule.substring("run".length)}Example" - - // NOTE: Uncomment to enable trace logs in the SDK during the examples - // jvmArgs("-Dorg.slf4j.simpleLogger.log.com.hedera.hashgraph=trace") - } - } -} - -abstract class RunAllExample : DefaultTask() { - @get:InputFiles - abstract val sources: ConfigurableFileCollection - - @get:InputFiles - abstract val rtClasspath: ConfigurableFileCollection - - @get:Internal - abstract val workingDirectory: RegularFileProperty - - @get:Inject - abstract val exec: ExecOperations - - @TaskAction - fun runAll() { - val exampleClasses = sources - .filter { it.name.endsWith("Example.java") } - .asSequence() - .map { it.name.replace(".java", "") } - .filter { it != "ValidateChecksumExample" } // disabled this example, because it needs user input (but it WORKS) - .filter { it != "ConsensusPubSubChunkedExample" } // is flaky on local-node env, will be investigated - .filter { it != "InitializeClientWithMirrorNetworkExample" } // disabled - cannot run on localnode - .toList() - - exampleClasses.forEach { className -> - println(""" - - ---EXECUTING $className: - - """.trimIndent()); - - exec.javaexec { - workingDir = workingDirectory.get().asFile - classpath = rtClasspath - mainModule = "com.hedera.hashgraph.examples" - mainClass = "com.hedera.hashgraph.sdk.examples.$className" - - // NOTE: Uncomment to enable trace logs in the SDK during the examples - // jvmArgs "-Dorg.slf4j.simpleLogger.log.com.hedera.hashgraph=trace" - } - } - } -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.java-base.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.java-base.gradle.kts deleted file mode 100644 index ed8b4b2c6..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.java-base.gradle.kts +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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("jacoco") - id("org.gradlex.java-module-dependencies") - id("com.hedera.gradle.base") - id("com.hedera.gradle.repositories") - id("com.hedera.gradle.patch-modules") -} - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) - vendor = JvmVendorSpec.ADOPTIUM - } -} - -jacoco { - toolVersion = "0.8.8" -} - -jvmDependencyConflicts { - consistentResolution.platform("com.hedera.hashgraph:sdk-dependency-versions") -} - -val deactivatedCompileLintOptions = - listOf( - "module", // module not found when doing 'exports to ...' - "serial", // serializable class ... has no definition of serialVersionUID - "processing", // No processor claimed any of these annotations: ... - "try", // auto-closeable resource ignore is never referenced... (AutoClosableLock) - "missing-explicit-ctor", // class ... declares no explicit constructors - "removal", - "deprecation", - "overrides", // overrides equals, but neither it ... overrides hashCode method - "unchecked", - "rawtypes", - "exports", - "dep-ann" - ) - -tasks.withType().configureEach { - options.encoding = "UTF-8" - options.compilerArgs.add("-Werror") - options.compilerArgs.add("-Xlint:all,-" + deactivatedCompileLintOptions.joinToString(",-")) -} - -tasks.withType().configureEach { - isPreserveFileTimestamps = false - isReproducibleFileOrder = true - filePermissions { unix("0664") } - dirPermissions { unix("0775") } -} - -tasks.buildDependents { setGroup(null) } - -tasks.buildNeeded { setGroup(null) } - -tasks.jar { setGroup(null) } - -tasks.test { group = "build" } - -tasks.checkAllModuleInfo { group = "build" } - -sourceSets.all { - // Remove 'classes' tasks from 'build' group to keep it cleaned up - tasks.named(classesTaskName) { group = null } -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts deleted file mode 100644 index 2106a4a82..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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 org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL - -plugins { - id("java-library") - id("com.google.protobuf") - id("com.hedera.gradle.java-base") - id("com.hedera.gradle.publish") -} - -@Suppress("UnstableApiUsage") -testing.suites { - named("test") { - useJUnitJupiter() - } - register("testIntegration") { - testType = TestSuiteType.INTEGRATION_TEST - targets.all { - testTask { - failFast = true - group = "build" - systemProperty("CONFIG_FILE", providers.gradleProperty("CONFIG_FILE").getOrElse("")) - systemProperty("HEDERA_NETWORK", providers.gradleProperty("HEDERA_NETWORK").getOrElse("")) - systemProperty("OPERATOR_ID", providers.gradleProperty("OPERATOR_ID").getOrElse("")) - systemProperty("OPERATOR_KEY", providers.gradleProperty("OPERATOR_KEY").getOrElse("")) - } - } - } -} - -tasks.withType().configureEach { - // NOTE: Uncomment to enable trace logs in the SDK during tests - // jvmArgs("-Dorg.slf4j.simpleLogger.log.com.hedera.hashgraph=trace") - - // emit logs per passed or failed test - testLogging { - exceptionFormat = FULL - events("passed", "skipped", "failed", "standardOut", "standardError") - } - - // propagate system environment to test runner - systemProperty("OPERATOR_ID", providers.gradleProperty("OPERATOR_ID").getOrElse("")) - systemProperty("OPERATOR_KEY", providers.gradleProperty("OPERATOR_KEY").getOrElse("")) - systemProperty("CONFIG_FILE", providers.gradleProperty("CONFIG_FILE").getOrElse("")) - systemProperty("HEDERA_NETWORK", providers.gradleProperty("HEDERA_NETWORK").getOrElse("")) -} - -tasks.withType().configureEach { - options { - this as StandardJavadocDocletOptions - encoding = "UTF-8" - addStringOption("Xdoclint:all,-missing", "-quiet") - addStringOption("Xwerror", "-quiet") - } -} - -tasks.withType().configureEach { - failFast = true - maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) -} - -tasks.jacocoTestReport { - dependsOn(tasks.withType()) - // make sure to use any/all test coverage data for the report and run all tests before this report is made - executionData.from( - tasks.test.map { it.extensions.getByType().destinationFile!! }, - tasks.named("testIntegration").map { it.extensions.getByType().destinationFile!! } - ) - - // remove generated proto files from report - classDirectories.setFrom(sourceSets.main.get().output.asFileTree.matching { - exclude( - "**/proto/**", - "**/AccountAllowanceAdjustTransaction.*", - "**/HederaPreCheckStatusException.*", - "**/HederaReceiptStatusException.*" - ) - }) - - // configure it so only xml is generated for the report - reports { - xml.required = true - html.required = true - csv.required = false - } -} - - -// https://github.com/google/protobuf-gradle-plugin -protobuf { - protoc { - // shouldn't be updated for now (breaking changes after 4.x.x) - artifact = "com.google.protobuf:protoc:3.25.4" - } - plugins { - id("grpc") { - artifact = "io.grpc:protoc-gen-grpc-java:1.66.0" - } - } -} -tasks.generateProto { - plugins { plugins.register("grpc") { option("@generated=omit") } } -} - -tasks.compileJava { - options.javaModuleVersion = project.version.toString() -} - -tasks.jar { - exclude("**/*.proto") - includeEmptyDirs = false - manifest { - attributes["Implementation-Version"] = project.version - } -} - -sourceSets.all { - configurations[getTaskName("", "compileProtoPath")].extendsFrom(configurations["internal"]) -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts deleted file mode 100644 index 913408e8b..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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("org.gradlex.extra-java-module-info") - id("org.gradlex.jvm-dependency-conflict-resolution") -} - -// 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.guava:listenablefuture", - "com.google.j2objc:j2objc-annotations", - "org.checkerframework:checker-compat-qual", - "org.checkerframework:checker-qual", - "org.codehaus.mojo:animal-sniffer-annotations" - ) - - module("com.github.spotbugs:spotbugs-annotations") { annotationLibraries.forEach { removeDependency(it) } } - module("com.google.guava:guava") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-api") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-context") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-core") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-netty-shaded") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-protobuf") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-protobuf-lite") { annotationLibraries.forEach { removeDependency(it) } } - module("io.grpc:grpc-util") { annotationLibraries.forEach { removeDependency(it) } } - - // Testing only - module("org.jetbrains.kotlin:kotlin-stdlib") { removeDependency("org.jetbrains.kotlin:kotlin-stdlib-common") } - module("junit:junit") { removeDependency("org.hamcrest:hamcrest-core") } -} - -// 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("com.esaulpaugh:headlong", "com.esaulpaugh.headlong") - module("com.github.spotbugs:spotbugs-annotations", "com.github.spotbugs.annotations") - module("com.google.errorprone:error_prone_annotations", "com.google.errorprone.annotations") { - patchRealModule() - exportAllPackages() - requireAllDefinedDependencies() - } - module("com.google.guava:failureaccess", "com.google.common.util.concurrent.internal") - module("com.google.guava:guava", "com.google.common") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - } - module("com.google.protobuf:protobuf-java", "com.google.protobuf") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - requires("jdk.unsupported") - } - module("com.google.protobuf:protobuf-javalite", "com.google.protobuf") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - requires("jdk.unsupported") - } - module("io.grpc:grpc-api", "io.grpc") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - uses("io.grpc.LoadBalancerProvider") - uses("io.grpc.ManagedChannelProvider") - uses("io.grpc.NameResolverProvider") - } - module("io.grpc:grpc-context", "io.grpc.context") - module("io.grpc:grpc-core", "io.grpc.internal") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - } - module("io.grpc:grpc-inprocess", "io.grpc.inprocess") - module("io.grpc:grpc-protobuf-lite", "io.grpc.protobuf.lite") - module("io.grpc:grpc-protobuf", "io.grpc.protobuf") - module("io.grpc:grpc-stub", "io.grpc.stub") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - } - module("io.perfmark:perfmark-api", "io.perfmark") - module("com.google.code.findbugs:jsr305", "java.annotation") - module("org.jetbrains:annotations", "org.jetbrains.annotations") - - // Full protobuf only - module("com.google.api.grpc:proto-google-common-protos", "com.google.api.grpc.common") - - // Testing only - module("io.grpc:grpc-netty-shaded", "io.grpc.netty.shaded") { - exportAllPackages() - requireAllDefinedDependencies() - requires("java.logging") - requires("jdk.unsupported") - ignoreServiceProvider("reactor.blockhound.integration.BlockHoundIntegration") - } - module("io.grpc:grpc-util", "io.grpc.util") - module("io.github.cdimascio:java-dotenv", "java.dotenv") - module("io.github.json-snapshot:json-snapshot", "json.snapshot") - module("junit:junit", "junit") - module("org.mockito:mockito-core", "org.mockito") - module("org.mockito:mockito-junit-jupiter", "org.mockito.junit.jupiter") - module("org.objenesis:objenesis", "org.objenesis") -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.publish.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.publish.gradle.kts deleted file mode 100644 index bc1aa5f76..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.publish.gradle.kts +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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") -} - -java { - withJavadocJar() - withSourcesJar() -} - -tasks.withType().configureEach { setGroup(null) } - -val mavenJava = publishing.publications.create("mavenJava") { - from(components["java"]) - - versionMapping { - allVariants { fromResolutionResult() } - } - - suppressAllPomMetadataWarnings() - - pom { - name = "Hedera SDK" - description = "Hedera™ Hashgraph SDK for Java" - url = "https://github.com/hashgraph/hedera-sdk-java" - - organization { - name = "Hedera Hashgraph" - url = "https://www.hedera.com" - } - - issueManagement { - system = "GitHub" - url = "https://github.com/hashgraph/hedera-sdk-java/issues" - } - - licenses { - license { - name = "Apache License, Version 2.0" - url = "https://github.com/hashgraph/hedera-sdk-java/blob/main/LICENSE" - distribution = "repo" - } - } - - scm { - url = "https://github.com/hashgraph/hedera-sdk-java" - connection = "scm:git:https://github.com/hashgraph/hedera-sdk-java.git" - developerConnection = "scm:git:ssh://github.com:hashgraph/hedera-sdk-java.git" - } - - developers { - developer { - name = "Nikita Lebedev" - } - - developer { - name = "Ivan Asenov" - } - } - } -} - -signing { - sign(mavenJava) - useGpgCmd() -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.repositories.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.repositories.gradle.kts deleted file mode 100644 index b6bfe054c..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.repositories.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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 { - maven("https://jitpack.io") { - content { includeModule("io.github.cdimascio", "java-dotenv") } - } - mavenCentral() -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.root.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.root.gradle.kts deleted file mode 100644 index 72f33aa2a..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.root.gradle.kts +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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.gradle.base") - id("com.hedera.gradle.repositories") - id("com.autonomousapps.dependency-analysis") - id("io.github.gradle-nexus.publish-plugin") -} - -val productVersion = layout.projectDirectory.file("version.txt").asFile.readText().trim() - -tasks.register("showVersion") { - group = "versioning" - - inputs.property("version", productVersion) - - doLast { println(inputs.properties["version"]) } -} - -nexusPublishing { - repositories { - sonatype { } - } -} - -tasks.named("closeSonatypeStagingRepository") { - // The publishing of all components to Maven Central is automatically done before close - // (which is done before release). - dependsOn(":sdk:publishToSonatype") - dependsOn(":sdk-full:publishToSonatype") -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.sdk-full.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.sdk-full.gradle.kts deleted file mode 100644 index dd9fefbdb..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.sdk-full.gradle.kts +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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.gradle.java") -} - -javaModuleDependencies.moduleNameToGA.put("com.google.protobuf", "com.google.protobuf:protobuf-java") - -val sdkSrcMainProto = layout.projectDirectory.dir("../sdk/src/main/proto") -val sdkSrcMainJava = layout.projectDirectory.dir("../sdk/src/main/java").asFileTree.matching { - exclude("module-info.java") -} -val sdkSrcMainResources = layout.projectDirectory.dir("../sdk/src/main/resources") - -tasks.generateProto { - addIncludeDir(files(sdkSrcMainProto)) - addSourceDirs(files(sdkSrcMainProto)) -} - -tasks.compileJava { - source(sdkSrcMainJava) -} - -tasks.processResources { - from(sdkSrcMainResources) -} - -tasks.javadoc { - source(sdkSrcMainJava) -} - -tasks.named("sourcesJar") { - from(sdkSrcMainJava) - from(sdkSrcMainResources) -} - -// 'sdk-full' is an alternative to 'sdk'. They cannot be used together. -// We express this via capability. -val sdkCapability = "${project.group}:sdk:${project.version}" -val sdkFullCapability = "${project.group}:${project.name}:${project.version}" -configurations.apiElements { - outgoing.capability(sdkFullCapability) // The default capability - outgoing.capability(sdkCapability) // The 'sdk' capability -} -configurations.runtimeElements { - outgoing.capability(sdkFullCapability) // The default capability - outgoing.capability(sdkCapability) // The 'sdk' capability -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.sdk.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.sdk.gradle.kts deleted file mode 100644 index ded6e2482..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.sdk.gradle.kts +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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.gradle.java") -} - -javaModuleDependencies.moduleNameToGA.put("com.google.protobuf", "com.google.protobuf:protobuf-javalite") - -tasks.generateProto { - builtins.named("java") { option("lite") } - plugins.named("grpc") { option("lite") } -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.settings.settings.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.settings.settings.gradle.kts deleted file mode 100644 index 69eda3654..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.settings.settings.gradle.kts +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ - -pluginManagement { - repositories { - gradlePluginPortal() - mavenCentral() - } -} - -plugins { - id("com.gradle.develocity") - id("org.gradle.toolchains.foojay-resolver-convention") -} - -includeBuild(".") - -// Enable Gradle Build Scan -develocity { - buildScan { - termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use" - termsOfUseAgree = "yes" - publishing.onlyIf { false } // only publish with explicit '--scan' - } -} - -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 - } - } - } -} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.versions.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.versions.gradle.kts deleted file mode 100644 index 1c32fe4b2..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.versions.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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-platform") - id("org.gradlex.java-module-versions") -} - -group = "com.hedera.hashgraph" diff --git a/gradle/toolchain-versions.properties b/gradle/toolchain-versions.properties new file mode 100644 index 000000000..f6397fb7d --- /dev/null +++ b/gradle/toolchain-versions.properties @@ -0,0 +1 @@ +jdk=17.0.12 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f..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..e2847c820 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.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf133..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 +# ############################################################################## # @@ -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 7101f8e46..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 ########################################################################## diff --git a/hiero-dependency-versions/build.gradle.kts b/hiero-dependency-versions/build.gradle.kts new file mode 100644 index 000000000..3f855b7f8 --- /dev/null +++ b/hiero-dependency-versions/build.gradle.kts @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: Apache-2.0 +plugins { + id("org.hiero.gradle.base.lifecycle") + id("org.hiero.gradle.base.jpms-modules") + id("org.hiero.gradle.check.spotless") + id("org.hiero.gradle.check.spotless-kotlin") +} + +group = "com.hedera.hashgraph" + +dependencies.constraints { + api("com.esaulpaugh:headlong:12.3.3") { because("com.esaulpaugh.headlong") } + api("com.google.code.gson:gson:2.10.1") { because("com.google.gson") } + api("com.google.protobuf:protobuf-java:4.29.1") { because("com.google.protobuf") } + api("com.google.protobuf:protobuf-javalite:4.29.1") { because("com.google.protobuf") } + api("io.grpc:grpc-api:1.68.2") { because("io.grpc") } + api("io.grpc:grpc-inprocess:1.67.1") { because("io.grpc.inprocess") } + api("io.grpc:grpc-protobuf:1.68.2") { because("io.grpc.protobuf") } + api("io.grpc:grpc-protobuf-lite:1.68.2") { because("io.grpc.protobuf.lite") } + api("io.grpc:grpc-stub:1.68.2") { because("io.grpc.stub") } + api("com.google.code.findbugs:jsr305:3.0.2") { because("java.annotation") } + api("org.bouncycastle:bcpkix-jdk18on:1.79") { because("org.bouncycastle.pkix") } + api("org.bouncycastle:bcprov-jdk18on:1.79") { because("org.bouncycastle.provider") } + api("org.slf4j:slf4j-api:2.0.9") { because("org.slf4j") } + api("org.slf4j:slf4j-simple:2.0.16") { because("org.slf4j.simple") } + api("com.google.code.findbugs:jsr305:3.0.2") { because("javax.annotation") } + + // Testing + api("com.fasterxml.jackson.core:jackson-core:2.18.2") { because("com.fasterxml.jackson.core") } + api("io.github.cdimascio:java-dotenv:5.3.1") { because("java.dotenv") } + api("io.github.json-snapshot:json-snapshot:1.0.17") { because("json.snapshot") } + api("org.apache.commons:commons-lang3:3.17.0") { because("org.apache.commons.lang3") } + api("org.assertj:assertj-core:3.26.3") { because("org.assertj.core") } + 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("com.google.guava:guava:33.3.1-android") { because("com.google.common") } + api("com.fasterxml.jackson.core:jackson-core:2.18.0") { because("com.fasterxml.jackson.core") } + + api("com.google.protobuf:protoc:3.25.4") + api("io.grpc:protoc-gen-grpc-java:1.66.0") + + // Examples + api("org.jetbrains.kotlin:kotlin-stdlib:2.1.0") { because("kotlin.stdlib") } +} diff --git a/sdk-dependency-versions/build.gradle.kts b/sdk-dependency-versions/build.gradle.kts deleted file mode 100644 index 87053d915..000000000 --- a/sdk-dependency-versions/build.gradle.kts +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * - * Hedera Java SDK - * - * 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.gradle.versions") -} - -dependencies.constraints { - api("com.esaulpaugh:headlong:12.3.3") { - because("headlong") - } - api("com.google.code.gson:gson:2.10.1") { - because("com.google.gson") - } - api("com.google.protobuf:protobuf-java:4.29.1") { - because("com.google.protobuf") - } - api("com.google.protobuf:protobuf-javalite:4.29.1") { - because("com.google.protobuf") - } - api("io.grpc:grpc-api:1.68.2") { - because("io.grpc") - } - api("io.grpc:grpc-inprocess:1.67.1") { - because("io.grpc.protobuf") - } - api("io.grpc:grpc-protobuf:1.68.2") { - because("io.grpc.protobuf") - } - api("io.grpc:grpc-protobuf-lite:1.68.2") { - because("io.grpc.protobuf") - } - api("io.grpc:grpc-stub:1.68.2") { - because("io.grpc.stub") - } - api("com.google.code.findbugs:jsr305:3.0.2") { - because("java.annotation") - } - api("org.bouncycastle:bcpkix-jdk18on:1.79") { - because("org.bouncycastle.pkix") - } - api("org.bouncycastle:bcprov-jdk18on:1.79") { - because("org.bouncycastle.provider") - } - api("org.slf4j:slf4j-api:2.0.9") { - because("org.slf4j") - } - api("org.slf4j:slf4j-simple:2.0.16") { - because("org.slf4j.simple") - } - - // Testing - api("com.fasterxml.jackson.core:jackson-core:2.18.2") { - because("com.fasterxml.jackson.core") - } - api("io.github.cdimascio:java-dotenv:5.3.1") { - because("java.dotenv") - } - api("io.github.json-snapshot:json-snapshot:1.0.17") { - because("json.snapshot") - } - api("org.apache.commons:commons-lang3:3.17.0") { - because("org.apache.commons.lang3") - } - api("org.assertj:assertj-core:3.26.3") { - because("org.assertj.core") - } - - // Examples - api("org.jetbrains.kotlin:kotlin-stdlib:2.1.0") { - because("kotlin.stdlib") - } -} diff --git a/sdk-full/build.gradle.kts b/sdk-full/build.gradle.kts index a148b6fe5..1bf745112 100644 --- a/sdk-full/build.gradle.kts +++ b/sdk-full/build.gradle.kts @@ -1,30 +1,54 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ - +// SPDX-License-Identifier: Apache-2.0 plugins { - id("com.hedera.gradle.sdk-full") + id("org.hiero.gradle.module.library") + id("org.hiero.gradle.feature.protobuf") } -// Define dependency constraints for gRPC implementations so that clients automatically get the correct version +description = "Hedera™ Hashgraph SDK for Java" + +// Define dependency constraints for gRPC implementations so that clients automatically get the +// correct version dependencies.constraints { api("io.grpc:grpc-netty:1.64.0") api("io.grpc:grpc-netty-shaded:1.64.0") api("io.grpc:grpc-okhttp:1.64.0") } + +javaModuleDependencies.moduleNameToGA.put( + "com.google.protobuf", + "com.google.protobuf:protobuf-java" +) + +tasks.withType().configureEach { options.compilerArgs.add("-Xlint:-exports,-dep-ann") } + +val sdkSrcMainProto = layout.projectDirectory.dir("../sdk/src/main/proto") +val sdkSrcMainJava = + layout.projectDirectory.dir("../sdk/src/main/java").asFileTree.matching { + exclude("module-info.java") + } +val sdkSrcMainResources = layout.projectDirectory.dir("../sdk/src/main/resources") + +tasks.generateProto { + addIncludeDir(files(sdkSrcMainProto)) + addSourceDirs(files(sdkSrcMainProto)) +} + +tasks.compileJava { source(sdkSrcMainJava) } + +tasks.processResources { from(sdkSrcMainResources) } + +tasks.javadoc { source(sdkSrcMainJava) } + +tasks.named("sourcesJar") { + from(sdkSrcMainJava) + from(sdkSrcMainResources) +} + +// 'sdk-full' is an alternative to 'sdk'. They cannot be used together. +// We express this via capability. +listOf(configurations.apiElements.get(), configurations.runtimeElements.get()).forEach { + it.outgoing.capability( + "${project.group}:${project.name}:${project.version}" + ) // The default capability + it.outgoing.capability("${project.group}:sdk:${project.version}") // The 'sdk' capability +} diff --git a/sdk-full/src/main/java/module-info.java b/sdk-full/src/main/java/module-info.java index b82a169e1..19a4674b6 100644 --- a/sdk-full/src/main/java/module-info.java +++ b/sdk-full/src/main/java/module-info.java @@ -20,7 +20,6 @@ module com.hedera.hashgraph.sdk.full { requires transitive com.google.protobuf; - requires com.esaulpaugh.headlong; requires com.google.common; requires com.google.gson; @@ -32,7 +31,6 @@ requires org.bouncycastle.pkix; requires org.bouncycastle.provider; requires org.slf4j; - requires static transitive java.annotation; exports com.hedera.hashgraph.sdk; diff --git a/sdk/build.gradle.kts b/sdk/build.gradle.kts index 1c6229fcc..288097962 100644 --- a/sdk/build.gradle.kts +++ b/sdk/build.gradle.kts @@ -1,28 +1,19 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ - +// SPDX-License-Identifier: Apache-2.0 plugins { - id("com.hedera.gradle.sdk") + id("org.hiero.gradle.module.library") + id("org.hiero.gradle.feature.protobuf") + id("org.hiero.gradle.feature.test-integration") } -// Define dependency constraints for gRPC implementations so that clients automatically get the correct version +description = "Hedera™ Hashgraph SDK for Java" + +javaModuleDependencies.moduleNameToGA.put( + "com.google.protobuf", + "com.google.protobuf:protobuf-javalite" +) + +// Define dependency constraints for gRPC implementations so that clients automatically get the +// correct version dependencies.constraints { api("io.grpc:grpc-netty:1.64.0") api("io.grpc:grpc-netty-shaded:1.64.0") @@ -30,6 +21,9 @@ dependencies.constraints { } testModuleInfo { + requires("com.fasterxml.jackson.annotation") + requires("com.fasterxml.jackson.core") + requires("com.fasterxml.jackson.databind") requires("json.snapshot") requires("org.assertj.core") requires("org.junit.jupiter.api") @@ -46,3 +40,38 @@ testIntegrationModuleInfo { runtimeOnly("io.grpc.netty.shaded") runtimeOnly("org.slf4j.simple") } + +protobuf { + generateProtoTasks { + all().configureEach { + builtins.named("java") { option("lite") } + plugins.named("grpc") { option("lite") } + } + } +} + +tasks.withType().configureEach { + systemProperty("CONFIG_FILE", providers.gradleProperty("CONFIG_FILE").getOrElse("")) + systemProperty("HEDERA_NETWORK", providers.gradleProperty("HEDERA_NETWORK").getOrElse("")) + systemProperty("OPERATOR_ID", providers.gradleProperty("OPERATOR_ID").getOrElse("")) + systemProperty("OPERATOR_KEY", providers.gradleProperty("OPERATOR_KEY").getOrElse("")) +} + +tasks.testIntegration { failFast = true } + +tasks.withType().configureEach { options.compilerArgs.add("-Xlint:-exports,-dep-ann") } + +dependencyAnalysis.abi { + exclusions { + // Exposes: org.slf4j.Logger + excludeClasses("logger") + // Exposes: com.google.common.base.MoreObjects.ToStringHelper + excludeClasses(".*\\.CustomFee") + // Exposes: com.esaulpaugh.headlong.abi.Tuple + excludeClasses(".*\\.ContractFunctionResult") + // Exposes: org.bouncycastle.crypto.params.KeyParameter + excludeClasses(".*\\.PrivateKey.*") + // Exposes: io.grpc.stub.AbstractFutureStub (and others) + excludeClasses(".*Grpc") + } +} diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/FileAppendTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/FileAppendTransaction.java index eaa87ba8d..d33a1a66c 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/FileAppendTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/FileAppendTransaction.java @@ -1,22 +1,4 @@ -/*- - * - * Hedera Java SDK - * - * Copyright (C) 2020 - 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. - * - */ +// SPDX-License-Identifier: Apache-2.0 package com.hedera.hashgraph.sdk; import com.google.protobuf.ByteString; @@ -28,10 +10,9 @@ import com.hedera.hashgraph.sdk.proto.TransactionID; import com.hedera.hashgraph.sdk.proto.TransactionResponse; import io.grpc.MethodDescriptor; - -import javax.annotation.Nullable; import java.util.LinkedHashMap; import java.util.Objects; +import javax.annotation.Nullable; /** *

A transaction specifically to append data to a file on the network. @@ -62,7 +43,9 @@ public FileAppendTransaction() { * records * @throws InvalidProtocolBufferException when there is an issue with the protobuf */ - FileAppendTransaction(LinkedHashMap> txs) throws InvalidProtocolBufferException { + FileAppendTransaction( + LinkedHashMap> txs) + throws InvalidProtocolBufferException { super(txs); initFromTransactionBody(); @@ -116,7 +99,7 @@ public ByteString getContents() { * * @param contents the contents to append to the file. * @return {@code this} - * @see #setContents(String) for an overload which takes {@link String}. + * @see #setContents(String) for an overload which takes String. */ public FileAppendTransaction setContents(byte[] contents) { return setData(contents); @@ -127,13 +110,12 @@ public FileAppendTransaction setContents(byte[] contents) { * * @param contents the contents to append to the file. * @return {@code this} - * @see #setContents(String) for an overload which takes {@link String}. + * @see #setContents(String) for an overload which takes String. */ public FileAppendTransaction setContents(ByteString contents) { return setData(contents); } - /** *

Encode the given {@link String} as UTF-8 and append it to file as identified by * {@link #setFileId(FileId)}. @@ -174,12 +156,13 @@ void initFromTransactionBody() { if (!innerSignedTransactions.isEmpty()) { try { - for (var i = 0; i < innerSignedTransactions.size(); - i += nodeAccountIds.isEmpty() ? 1 : nodeAccountIds.size()) { - data = data.concat( - TransactionBody.parseFrom(innerSignedTransactions.get(i).getBodyBytes()) - .getFileAppend().getContents() - ); + for (var i = 0; + i < innerSignedTransactions.size(); + i += nodeAccountIds.isEmpty() ? 1 : nodeAccountIds.size()) { + data = data.concat(TransactionBody.parseFrom( + innerSignedTransactions.get(i).getBodyBytes()) + .getFileAppend() + .getContents()); } } catch (InvalidProtocolBufferException exc) { throw new IllegalArgumentException(exc.getMessage()); @@ -205,7 +188,13 @@ FileAppendTransactionBody.Builder build() { } @Override - void onFreezeChunk(TransactionBody.Builder body, @Nullable TransactionID initialTransactionId, int startIndex, int endIndex, int chunk, int total) { + void onFreezeChunk( + TransactionBody.Builder body, + @Nullable TransactionID initialTransactionId, + int startIndex, + int endIndex, + int chunk, + int total) { body.setFileAppend(build().setContents(data.substring(startIndex, endIndex))); } diff --git a/sdk/src/main/java/module-info.java b/sdk/src/main/java/module-info.java index 7dfbc187f..36ca7aaf7 100644 --- a/sdk/src/main/java/module-info.java +++ b/sdk/src/main/java/module-info.java @@ -20,7 +20,6 @@ module com.hedera.hashgraph.sdk { requires transitive com.google.protobuf; - requires com.esaulpaugh.headlong; requires com.google.common; requires com.google.gson; @@ -32,7 +31,6 @@ requires org.bouncycastle.pkix; requires org.bouncycastle.provider; requires org.slf4j; - requires static transitive java.annotation; exports com.hedera.hashgraph.sdk; diff --git a/sdk/src/testIntegration/java/module-info.java b/sdk/src/testIntegration/java/module-info.java index 8fbf5e58a..358c841ee 100644 --- a/sdk/src/testIntegration/java/module-info.java +++ b/sdk/src/testIntegration/java/module-info.java @@ -24,6 +24,5 @@ requires org.assertj.core; requires org.bouncycastle.provider; requires org.junit.jupiter.api; - requires static java.annotation; } diff --git a/settings.gradle.kts b/settings.gradle.kts index ecb9abf83..5cf6caf79 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,34 +1,14 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ +// SPDX-License-Identifier: Apache-2.0 +plugins { id("org.hiero.gradle.build") version "0.1.1" } -pluginManagement { - includeBuild("gradle/plugins") -} -plugins { - id("com.hedera.gradle.settings") +rootProject.name = "hedera-sdk-java" + +javaModules { + module("sdk") { group = "com.hedera.hashgraph" } + module("sdk-full") { group = "com.hedera.hashgraph" } + module("tck") { group = "com.hedera.hashgraph.sdk.tck" } } includeBuild("examples") -includeBuild("example-android") -include("sdk") -include("sdk-full") -include("sdk-dependency-versions") -include("tck") +includeBuild("example-android") diff --git a/tck/build.gradle.kts b/tck/build.gradle.kts index 93068a4cf..551b22d89 100644 --- a/tck/build.gradle.kts +++ b/tck/build.gradle.kts @@ -1,70 +1,68 @@ -/*- - * - * Hedera Java SDK - * - * 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. - * - */ +// SPDX-License-Identifier: Apache-2.0 +import org.springframework.boot.gradle.plugin.ResolveMainClassName +import org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES plugins { - id("java") - id("com.diffplug.spotless") version "6.25.0" id("org.springframework.boot") version "3.2.3" + id("java") + id("com.autonomousapps.dependency-analysis") + id("org.hiero.gradle.base.lifecycle") + id("org.hiero.gradle.check.javac-lint") + id("org.hiero.gradle.check.spotless") + id("org.hiero.gradle.check.spotless-java") + id("org.hiero.gradle.check.spotless-kotlin") + id("org.hiero.gradle.feature.git-properties-file") + id("org.hiero.gradle.feature.java-compile") + id("org.hiero.gradle.feature.java-doc") + id("org.hiero.gradle.feature.java-execute") + id("org.hiero.gradle.feature.test") + id("org.hiero.gradle.report.test-logger") } description = "Hedera SDK TCK Server" -group = "com.hedera.hashgraph.sdk.tck" -version = "0.0.1" - -java { - sourceCompatibility = JavaVersion.VERSION_17 -} -repositories { - mavenCentral() -} +version = "0.0.1" dependencies { - implementation(platform("org.springframework.boot:spring-boot-dependencies:3.2.3")) - implementation(platform(project(":sdk-dependency-versions"))) + annotationProcessor(platform(BOM_COORDINATES)) + annotationProcessor("org.projectlombok:lombok") - implementation("org.springframework.boot:spring-boot-starter") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("com.thetransactioncompany:jsonrpc2-server:2.0") - implementation("io.grpc:grpc-netty-shaded:1.57.2") - implementation("org.bouncycastle:bcpkix-jdk18on:1.78.1") - implementation("org.bouncycastle:bcprov-jdk18on:1.78.1") + implementation(platform(BOM_COORDINATES)) + implementation(platform(project(":hiero-dependency-versions"))) implementation(project(":sdk")) - compileOnly("org.projectlombok:lombok:1.18.30") - annotationProcessor("org.projectlombok:lombok:1.18.30") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") - testImplementation("org.mockito:mockito-core:3.11.2") - testImplementation("org.mockito:mockito-junit-jupiter:5.11.0") + implementation("com.thetransactioncompany:jsonrpc2-base") + implementation("com.thetransactioncompany:jsonrpc2-server:2.0") + implementation("net.minidev:json-smart") + implementation("org.apache.tomcat.embed:tomcat-embed-core") + implementation("org.bouncycastle:bcprov-jdk18on") + implementation("org.slf4j:slf4j-api") + implementation("org.springframework.boot:spring-boot") + implementation("org.springframework.boot:spring-boot-autoconfigure") + implementation("org.springframework:spring-context") + implementation("org.springframework:spring-web") + implementation("org.springframework:spring-webmvc") + runtimeOnly("io.grpc:grpc-netty-shaded") + runtimeOnly("org.springframework.boot:spring-boot-starter-web") + compileOnly("org.projectlombok:lombok") + + testImplementation("org.junit.jupiter:junit-jupiter-api") + testImplementation("org.mockito:mockito-core") + testImplementation("org.mockito:mockito-junit-jupiter") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") } -spotless { - java { - endWithNewline() - palantirJavaFormat() - target("**/*.java") - toggleOffOn() - } -} +tasks.withType { setGroup(null) } -tasks.test { - // discover and execute JUnit5-based tests - useJUnitPlatform() +// Configure dependency analysis without using Java Modules +tasks.qualityGate { dependsOn(tasks.named("projectHealth")) } + +tasks.qualityCheck { dependsOn(tasks.named("projectHealth")) } + +dependencyAnalysis { + issues { + onAny { + severity("fail") + exclude("com.google.protobuf:protobuf-javalite") + } + } }