Skip to content

Commit

Permalink
build: use plugins from 'hedera-gradle-conventions'
Browse files Browse the repository at this point in the history
Signed-off-by: Jendrik Johannes <[email protected]>
  • Loading branch information
jjohannes committed Dec 9, 2024
1 parent 002f6b9 commit b638150
Show file tree
Hide file tree
Showing 39 changed files with 334 additions and 1,212 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -204,7 +204,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
5 changes: 4 additions & 1 deletion .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@
nikita.lebedev@limechain.tech=Nikita Lebedev
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.45.0")
Expand Down
98 changes: 77 additions & 21 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,89 @@
/*-
*
* 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")
}

// '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.45.0")
implementation("com.hedera.hashgraph:sdk-full:2.45.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.${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"
}
}
}
}
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("..")
// ---------------------------------------------
8 changes: 2 additions & 6 deletions examples/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
*/

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 io.github.cdimascio.dotenv.java;
requires static java.annotation;
requires com.google.protobuf;
}
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.

22 changes: 0 additions & 22 deletions gradle/plugins/src/main/kotlin/com.hedera.gradle.base.gradle.kts

This file was deleted.

Loading

0 comments on commit b638150

Please sign in to comment.