diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 571b250e9..5f897e740 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,8 +88,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 @@ -199,7 +199,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 7f6078a32..938c04553 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -125,4 +125,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..0811074b0 --- /dev/null +++ b/developers.properties @@ -0,0 +1 @@ +nikita.lebedev@limechain.tech=Nikita Lebedev diff --git a/example-android/app/build.gradle.kts b/example-android/app/build.gradle.kts index a5bc706ff..c9c61b2d9 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:hedera-dependency-versions")) // --------------------------------------------- implementation("com.hedera.hashgraph:sdk:2.41.0") diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index dec474986..fe48de5a0 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -1,7 +1,4 @@ -/*- - * - * Hedera Java SDK - * +/* * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,11 +12,11 @@ * 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.examples.java") + id("com.hedera.gradle.module.application") + id("org.gradlex.java-module-dependencies") } mainModuleInfo { @@ -27,7 +24,81 @@ mainModuleInfo { runtimeOnly("org.slf4j.simple") } +// '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.41.0") implementation("com.hedera.hashgraph:sdk-full:2.41.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 + .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/jdk-version.txt b/examples/gradle/jdk-version.txt new file mode 100644 index 000000000..8808b7e39 --- /dev/null +++ b/examples/gradle/jdk-version.txt @@ -0,0 +1 @@ +17.0.12 diff --git a/examples/settings.gradle.kts b/examples/settings.gradle.kts index 2a19d1397..85f5a4260 100644 --- a/examples/settings.gradle.kts +++ b/examples/settings.gradle.kts @@ -1,7 +1,4 @@ -/*- - * - * Hedera Java SDK - * +/* * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,16 +12,16 @@ * 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 { - includeBuild("../gradle/plugins") - repositories { - gradlePluginPortal() - } + repositories.gradlePluginPortal() + repositories.maven("https://repo.onepiece.software/snapshots") } +plugins { id("com.hedera.gradle.build") version "0.0.2" } + +@Suppress("UnstableApiUsage") dependencyResolutionManagement { repositories.mavenCentral() } + // --- Remove to use a published SDK version --- -includeBuild("..") -// --------------------------------------------- +includeBuild("..") // --------------------------------------------- diff --git a/examples/src/main/java/module-info.java b/examples/src/main/java/module-info.java index dba574aac..ed2b93d1d 100644 --- a/examples/src/main/java/module-info.java +++ b/examples/src/main/java/module-info.java @@ -19,12 +19,9 @@ */ module com.hedera.hashgraph.examples { - requires com.hedera.hashgraph.sdk; - // requires com.hedera.hashgraph.sdk.full; - requires com.google.gson; - requires java.dotenv; + requires com.hedera.hashgraph.sdk; // .full; + requires io.github.cdimascio.dotenv.java; requires static java.annotation; - requires com.google.protobuf; } 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..3f5ed6927 --- /dev/null +++ b/gradle/aggregation/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + id("com.hedera.gradle.base.lifecycle") + id("java") +} + +dependencies { + implementation(project(":sdk")) + implementation("io.grpc:grpc-protobuf") +} diff --git a/gradle/jdk-version.txt b/gradle/jdk-version.txt new file mode 100644 index 000000000..8808b7e39 --- /dev/null +++ b/gradle/jdk-version.txt @@ -0,0 +1 @@ +17.0.12 diff --git a/gradle/plugins/build.gradle.kts b/gradle/plugins/build.gradle.kts deleted file mode 100644 index 87a34b00b..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.1.4") - 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 220ceb189..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts +++ /dev/null @@ -1,92 +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 - .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 037c2d2b0..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts +++ /dev/null @@ -1,132 +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 { - 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.jacocoTestReport { - // 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 6282658cb..000000000 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts +++ /dev/null @@ -1,130 +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", "headlong") - module("com.github.spotbugs:spotbugs-annotations", "com.github.spotbugs.annotations") - module("com.google.errorprone:error_prone_annotations", "com.google.errorprone.annotations") - 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/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..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 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/sdk-dependency-versions/build.gradle.kts b/hedera-dependency-versions/build.gradle.kts similarity index 76% rename from sdk-dependency-versions/build.gradle.kts rename to hedera-dependency-versions/build.gradle.kts index 261937872..3ffa8c9d6 100644 --- a/sdk-dependency-versions/build.gradle.kts +++ b/hedera-dependency-versions/build.gradle.kts @@ -19,9 +19,12 @@ */ plugins { - id("com.hedera.gradle.versions") + id("com.hedera.gradle.base.lifecycle") + id("com.hedera.gradle.base.jpms-modules") } +group = "com.hedera.hashgraph" + dependencies.constraints { api("com.esaulpaugh:headlong:12.1.0") { because("headlong") @@ -41,13 +44,13 @@ dependencies.constraints { because("io.grpc") } api("io.grpc:grpc-inprocess:1.64.0") { - because("io.grpc.protobuf") + because("io.grpc.inprocess") } api("io.grpc:grpc-protobuf:1.64.0") { because("io.grpc.protobuf") } api("io.grpc:grpc-protobuf-lite:1.64.0") { - because("io.grpc.protobuf") + because("io.grpc.protobuf.lite") } api("io.grpc:grpc-stub:1.64.0") { because("io.grpc.stub") @@ -67,6 +70,9 @@ dependencies.constraints { 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.0") { @@ -84,6 +90,21 @@ dependencies.constraints { 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.0.21") { diff --git a/sdk-full/build.gradle.kts b/sdk-full/build.gradle.kts index a148b6fe5..3ae361b7d 100644 --- a/sdk-full/build.gradle.kts +++ b/sdk-full/build.gradle.kts @@ -1,7 +1,4 @@ -/*- - * - * Hedera Java SDK - * +/* * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,16 +12,58 @@ * 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.sdk-full") + id("com.hedera.gradle.module.library") + id("com.hedera.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 515c7989e..574625e87 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.google.common; requires com.google.gson; requires headlong; @@ -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..bd68f22f0 100644 --- a/sdk/build.gradle.kts +++ b/sdk/build.gradle.kts @@ -1,7 +1,4 @@ -/*- - * - * Hedera Java SDK - * +/* * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,14 +12,23 @@ * 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.sdk") + id("com.hedera.gradle.module.library") + id("com.hedera.gradle.feature.protobuf") + id("com.hedera.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 +36,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 +55,36 @@ 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.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..b1448899f 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/FileAppendTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/FileAppendTransaction.java @@ -1,8 +1,5 @@ -/*- - * - * Hedera Java SDK - * - * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC +/* + * 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. @@ -15,8 +12,8 @@ * 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.hashgraph.sdk; import com.google.protobuf.ByteString; @@ -28,10 +25,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 +58,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 +114,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 +125,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 +171,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 +203,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 d9f19f2fe..c9aca4777 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.google.common; requires com.google.gson; requires headlong; @@ -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 90228b96c..9773a6ba3 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..fa7cafa2b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,4 @@ -/*- - * - * Hedera Java SDK - * +/* * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,20 +12,23 @@ * 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 { - includeBuild("gradle/plugins") + repositories.gradlePluginPortal() + repositories.maven("https://repo.onepiece.software/snapshots") } -plugins { - id("com.hedera.gradle.settings") + +plugins { id("com.hedera.gradle.build") version "0.0.2" } + +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..2cf7a05fe 100644 --- a/tck/build.gradle.kts +++ b/tck/build.gradle.kts @@ -1,7 +1,4 @@ -/*- - * - * Hedera Java SDK - * +/* * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,56 +12,72 @@ * 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 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("com.hedera.gradle.base.lifecycle") + id("com.hedera.gradle.check.javac-lint") + id("com.hedera.gradle.check.spotless") + id("com.hedera.gradle.check.spotless-java") + id("com.hedera.gradle.check.spotless-kotlin") + id("com.hedera.gradle.feature.git-properties-file") + id("com.hedera.gradle.feature.java-compile") + id("com.hedera.gradle.feature.java-doc") + id("com.hedera.gradle.feature.java-execute") + id("com.hedera.gradle.feature.test") + id("com.hedera.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(":hedera-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) } + +// Configure dependency analysis without using Java Modules +tasks.qualityGate { dependsOn(tasks.named("projectHealth")) } -tasks.test { - // discover and execute JUnit5-based tests - useJUnitPlatform() +tasks.qualityCheck { dependsOn(tasks.named("projectHealth")) } + +dependencyAnalysis { + issues { + onAny { + severity("fail") + exclude("com.google.protobuf:protobuf-javalite") + } + } }