Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use common Hiero Gradle config #2033

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
name: PR Checks

on:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 5 additions & 1 deletion .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
name: Release Artifacts

on:
Expand Down Expand Up @@ -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
38 changes: 0 additions & 38 deletions build.gradle.kts

This file was deleted.

1 change: 1 addition & 0 deletions developers.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]=The Hiero Team
2 changes: 1 addition & 1 deletion example-android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
102 changes: 78 additions & 24 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,38 +1,92 @@
/*-
*
* 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 {
runtimeOnly("io.grpc.netty.shaded")
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<RunAllExample>("runAllExamples") {
workingDirectory = rootDir
sources.from(sourceSets.main.get().java.asFileTree)
rtClasspath.from(configurations.runtimeClasspath.get() + files(tasks.jar))
}

tasks.addRule("Pattern: run<Example>: Runs an example.") {
if (startsWith("run")) {
tasks.register<JavaExec>(this) {
workingDir = rootDir
classpath = configurations.runtimeClasspath.get() + files(tasks.jar)
mainModule = "com.hedera.hashgraph.examples"
mainClass =
"com.hedera.hashgraph.sdk.examples.${[email protected]("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"
}
}
}
}
1 change: 1 addition & 0 deletions examples/gradle/toolchain-versions.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jdk=17.0.12
29 changes: 3 additions & 26 deletions examples/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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("..")
// ---------------------------------------------
10 changes: 3 additions & 7 deletions examples/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions examples/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0-SNAPSHOT
12 changes: 12 additions & 0 deletions gradle/aggregation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
}
37 changes: 0 additions & 37 deletions gradle/plugins/build.gradle.kts

This file was deleted.

This file was deleted.

Loading