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 Oct 16, 2024
1 parent a47c7ba commit 3590ef4
Show file tree
Hide file tree
Showing 38 changed files with 323 additions and 1,010 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 @@ -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
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:hedera-dependency-versions"))
// ---------------------------------------------

implementation("com.hedera.hashgraph:sdk:2.41.0")
Expand Down
83 changes: 77 additions & 6 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/*-
*
* Hedera Java SDK
*
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,19 +12,93 @@
* 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 {
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.41.0")
implementation("com.hedera.hashgraph:sdk-full:2.41.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/jdk-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17.0.12
19 changes: 8 additions & 11 deletions examples/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/*-
*
* Hedera Java SDK
*
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -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("..") // ---------------------------------------------
7 changes: 2 additions & 5 deletions examples/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
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
9 changes: 9 additions & 0 deletions gradle/aggregation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("com.hedera.gradle.base.lifecycle")
id("java")
}

dependencies {
implementation(project(":sdk"))
implementation("io.grpc:grpc-protobuf")
}
1 change: 1 addition & 0 deletions gradle/jdk-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17.0.12
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 3590ef4

Please sign in to comment.