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 11, 2024
1 parent 56067ca commit b65ebce
Show file tree
Hide file tree
Showing 38 changed files with 321 additions and 1,006 deletions.
4 changes: 2 additions & 2 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
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("..") // ---------------------------------------------
3 changes: 1 addition & 2 deletions examples/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
// 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
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.

This file was deleted.

Loading

0 comments on commit b65ebce

Please sign in to comment.