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

feat: 00071 hedera protobufs #117

Merged
merged 90 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
d6c287f
wip: fixed some protobuf compilation errors
mattp-swirldslabs Aug 6, 2024
5db0ee2
wip: moved packages
mattp-swirldslabs Aug 6, 2024
6134410
wip: fixed protobuf obj errors
mattp-swirldslabs Aug 6, 2024
3a251b2
wip: close to working?
mattp-swirldslabs Aug 6, 2024
8da2727
wip: pointed to the correct branch of hedera-protobufs
mattp-swirldslabs Aug 6, 2024
3cb912f
wip: getting further
mattp-swirldslabs Aug 6, 2024
e2e9b82
fix: does this help or hurt?
mattp-swirldslabs Aug 7, 2024
aff8af9
fix: use main rather than continue-block-node branch
mattp-swirldslabs Aug 12, 2024
042d14f
wip: flailing around added deps
mattp-swirldslabs Aug 12, 2024
aa95f90
wip: stopping point with Joseph
mattp-swirldslabs Aug 13, 2024
bda2731
wip: troubleshooting
mattp-swirldslabs Aug 13, 2024
9ac80c3
wip: different approach with Fredy
mattp-swirldslabs Aug 13, 2024
e81781e
wip: I got passed the compiler errors
mattp-swirldslabs Aug 13, 2024
df03f70
wip: getting to checkModuleDirectivesScope
mattp-swirldslabs Aug 13, 2024
9182846
wip: modules still broken
mattp-swirldslabs Aug 13, 2024
0514f83
wip: fixing app compilation errors
mattp-swirldslabs Aug 13, 2024
02ec129
fix: aligned server classes to new types
mattp-swirldslabs Aug 14, 2024
509c53f
fix: fixed the application compile issues
mattp-swirldslabs Aug 14, 2024
f8ab319
wip: not working
mattp-swirldslabs Aug 14, 2024
5b41913
fix: fixed the slf4j runtimeClasspath issue
mattp-swirldslabs Aug 14, 2024
51c74a0
fix: fixed test compilation issues
mattp-swirldslabs Aug 14, 2024
25c7c8e
fix: fixed testRuntimeClasspath issue
mattp-swirldslabs Aug 14, 2024
06d63ee
reverse me
mattp-swirldslabs Aug 14, 2024
4d6d276
fix: fixed read Block and write BlockItems and fixed 1 test
mattp-swirldslabs Aug 14, 2024
33bf7c4
fix: fixing the fake hash alg
mattp-swirldslabs Aug 15, 2024
8ba27d5
fix: fixing tests and spotless
mattp-swirldslabs Aug 15, 2024
59a0579
fix: fixed a test
mattp-swirldslabs Aug 15, 2024
7685fb1
fix: fixed BlockStreamService test
mattp-swirldslabs Aug 15, 2024
b754d13
fix: fixed remaining broken tests
mattp-swirldslabs Aug 15, 2024
474308e
fix: spotless
mattp-swirldslabs Aug 15, 2024
f327a1e
wip: completely broken again
mattp-swirldslabs Aug 15, 2024
bfe319e
wip: stuck
mattp-swirldslabs Aug 16, 2024
7769f09
fix: compile working across stream and server
mattp-swirldslabs Aug 16, 2024
676bcad
fix: fixed a couple of runtime dependency issues
mattp-swirldslabs Aug 16, 2024
521ebf8
fix: fixed the service name. Now the server starts
mattp-swirldslabs Aug 16, 2024
63b2b3f
wip: broken producer.sh
mattp-swirldslabs Aug 16, 2024
716cbcc
wip: adjusting producer.sh
mattp-swirldslabs Aug 16, 2024
8e6c7fe
wip: trying to figure out helidon logging issue
mattp-swirldslabs Aug 16, 2024
04fb6e1
wip: still not working
mattp-swirldslabs Aug 16, 2024
9ecb672
fix: spotless
mattp-swirldslabs Aug 16, 2024
08eccca
fix: added requires to jpms to fix logging requirement
mattp-swirldslabs Aug 16, 2024
6e0addf
fix: fixup
mattp-swirldslabs Aug 19, 2024
f14e2c1
fix: added translator to convert between protoc and pbj for singleBlock
mattp-swirldslabs Aug 19, 2024
aa1146e
fix: translated the inbound protoc from helidon to pbj
mattp-swirldslabs Aug 19, 2024
cda4a5c
fix: adjusted the subscribeBlockStream rpc to use protoc and pbj
mattp-swirldslabs Aug 19, 2024
2790ac5
wip: able to send blockitem with producer.sh
mattp-swirldslabs Aug 19, 2024
a255990
fix: able to subscribe to the stream
mattp-swirldslabs Aug 19, 2024
65ed893
fix: fixed producer loop counter. singleBlock now returns success cod…
mattp-swirldslabs Aug 20, 2024
3c17d83
fix: added event and block_proof blockitems
mattp-swirldslabs Aug 20, 2024
c3c32d1
fix: able to remove Copy duplicates strategy and clean up
mattp-swirldslabs Aug 20, 2024
5f6006f
fix: adjusted producer/consumer scripts. added batch_consumer to crea…
mattp-swirldslabs Aug 21, 2024
43b93d9
fix: adjusted the workflow gradle commands to exclude tests while the…
mattp-swirldslabs Aug 21, 2024
52f59f6
fix: adjusted how the mediator increments metrics
mattp-swirldslabs Aug 21, 2024
7fe6836
fix: boosted test coverage back to 100%
mattp-swirldslabs Aug 21, 2024
908f5a5
fix: spotless
mattp-swirldslabs Aug 21, 2024
8cdd877
fix: adjust pr-checks to skip spotless on PBJ
mattp-swirldslabs Aug 21, 2024
0fd400c
fix: spotless on gradle files
mattp-swirldslabs Aug 21, 2024
f9588d7
fix: removed ackbuilder and adjusted tests
mattp-swirldslabs Aug 21, 2024
75fc2b4
fix: added tests for coverage
mattp-swirldslabs Aug 21, 2024
de54734
fix: spotless
mattp-swirldslabs Aug 21, 2024
729220a
fix: removed netty jpms references
mattp-swirldslabs Aug 21, 2024
fa709fb
fix: exempting Translator from codecov
mattp-swirldslabs Aug 21, 2024
a93f80e
fix: removed unnecessary tunweni jpms operations
mattp-swirldslabs Aug 21, 2024
f2dc9c9
fix: removed commented line
mattp-swirldslabs Aug 21, 2024
f4dc234
fix: removed commented out lines
mattp-swirldslabs Aug 21, 2024
7eb7a90
fix: adjusted the spotless config so it skips proto files
mattp-swirldslabs Aug 21, 2024
cd5568f
fix: bumped PBJ to 0.9.2 to fix the test issue
mattp-swirldslabs Aug 21, 2024
7577bde
fix: code review changes
mattp-swirldslabs Aug 21, 2024
f3e1899
fix: refactor common logic
mattp-swirldslabs Aug 21, 2024
6fd7a80
fix: removed wildcard imports
mattp-swirldslabs Aug 22, 2024
09d4ba0
fix: removed 2023 from headers
mattp-swirldslabs Aug 22, 2024
8c12682
fix: remove jetbrains module from jpms
mattp-swirldslabs Aug 22, 2024
daee5bf
fix: remove dependencies from gradle files
mattp-swirldslabs Aug 22, 2024
5d366db
fix: code review feedback
mattp-swirldslabs Aug 22, 2024
121f52c
fix: removed annotations for local variable assignment
mattp-swirldslabs Aug 22, 2024
8d24a57
fix: Renamed a test and removed JMH modules
mattp-swirldslabs Aug 22, 2024
dc759d3
fix: moved runtimeOnly dep to mainModuleInfo
mattp-swirldslabs Aug 22, 2024
99ad840
fix: removed old jvm GC directive for protobuf tests
mattp-swirldslabs Aug 22, 2024
ebf333a
fix: added static imports for Logger.Level
mattp-swirldslabs Aug 22, 2024
5add1a0
fix: importing System.Logger
mattp-swirldslabs Aug 22, 2024
9d64c30
fix: Changed message interpolation to reuse string. Removed TODOs per…
mattp-swirldslabs Aug 22, 2024
05475fc
fix: fixed error and debug messages
mattp-swirldslabs Aug 22, 2024
74b4f64
fix: exclude test files generated from manual end to end runs
mattp-swirldslabs Aug 23, 2024
e2f3605
fix: pin hedera-services to the latest commit on main
mattp-swirldslabs Aug 23, 2024
262347b
fix: adjusted exception handling to throw ParseException
mattp-swirldslabs Aug 23, 2024
ba5be60
fix: refactored static method to a more general toPbj()
mattp-swirldslabs Aug 23, 2024
eea8b2d
fix: refactored to fromPbj method
mattp-swirldslabs Aug 23, 2024
f27dd39
fix: refactored to fromPbj method
mattp-swirldslabs Aug 23, 2024
d18dfb9
fix: refactored to fromPbj method
mattp-swirldslabs Aug 23, 2024
3827a83
fix: refactored to fromPbj
mattp-swirldslabs Aug 23, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ jobs:

- name: Build
id: gradle-build
run: ${GRADLE_EXEC} build
run: ${GRADLE_EXEC} build -x :stream:test # TODO: Remove -x :stream:test when PBJ bug is fixed

- name: Style Check
id: spotless-check
run: ${GRADLE_EXEC} spotlessCheck
run: ${GRADLE_EXEC} spotlessCheck -x :stream:spotlessCheck # Do not run spotless on the generated PBJ files

- name: Unit Tests
id: unit-tests
run: ${GRADLE_EXEC} check
run: ${GRADLE_EXEC} check -x :stream:test # TODO: Remove -x :stream:test when PBJ bug is fixed

- name: Upload coverage report
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release-push-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ jobs:
java-version: 21

- name: Build
run: ./gradlew clean build

run: ./gradlew clean build -x :stream:test # TODO: Remove -x :stream:test when PBJ bug is fixed
- name: Login to GitHub Container Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ repositories { gradlePluginPortal() }

dependencies {
implementation("com.adarshr:gradle-test-logger-plugin:4.0.0")
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.31.0")
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.32.0")
mattp-swirldslabs marked this conversation as resolved.
Show resolved Hide resolved
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
implementation("com.gradle.publish:plugin-publish-plugin:1.2.1")
implementation("gradle.plugin.lazy.zoo.gradle:git-data-plugin:1.2.2")
implementation("io.github.gradle-nexus:publish-plugin:1.3.0")
implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2")
implementation("net.swiftzer.semver:semver:1.3.0")
implementation("org.gradlex:java-module-dependencies:1.6.5")
implementation("org.gradlex:extra-java-module-info:1.8")
implementation("org.gradlex:jvm-dependency-conflict-resolution:2.0")
implementation("org.gradlex:java-module-dependencies:1.6.5")
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Utils {
lines = gradlePropFile.readLines(Charsets.UTF_8)
}

var versionStr = "version=${newVersion.toString()}"
var versionStr = "version=$newVersion"
val finalLines: List<String>


Expand Down
93 changes: 70 additions & 23 deletions buildSrc/src/main/kotlin/com.hedera.block.jpms-modules.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,11 @@ jvmDependencyConflicts.patch {
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"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.google.guava:guava") {
annotationLibraries.forEach { removeDependency(it) }
removeDependency("com.google.guava:failureaccess")
}
module("io.grpc:grpc-api") { annotationLibraries.forEach { removeDependency(it) } }
module("io.grpc:grpc-core") { annotationLibraries.forEach { removeDependency(it) } }
module("io.grpc:grpc-context") { annotationLibraries.forEach { removeDependency(it) } }
Expand All @@ -50,61 +45,95 @@ jvmDependencyConflicts.patch {
removeDependency(/* dependency = */ "com.google.protobuf:protobuf-javalite")
addApiDependency("com.google.protobuf:protobuf-java")
}
module("io.grpc:grpc-services") { annotationLibraries.forEach { removeDependency(it) } }
module("io.grpc:grpc-stub") { annotationLibraries.forEach { removeDependency(it) } }
module("io.grpc:grpc-testing") { annotationLibraries.forEach { removeDependency(it) } }
module("io.grpc:grpc-util") { annotationLibraries.forEach { removeDependency(it) } }
// Added for metrics and logging, but also several platform classes
module("com.google.guava:guava") {
(annotationLibraries -
"com.google.code.findbugs:jsr305" -
"com.google.errorprone:error_prone_annotations" -
"org.checkerframework:checker-qual")
.forEach { removeDependency(it) }
}
module("com.google.protobuf:protobuf-java-util") {
annotationLibraries.forEach { removeDependency(it) }
}
module("io.prometheus:simpleclient") {
removeDependency("io.prometheus:simpleclient_tracer_otel")
removeDependency("io.prometheus:simpleclient_tracer_otel_agent")
}
module("org.jetbrains.kotlin:kotlin-stdlib") {
removeDependency("org.jetbrains.kotlin:kotlin-stdlib-common")
}
module("junit:junit") { removeDependency("org.hamcrest:hamcrest-core") }
module("org.hyperledger.besu:secp256k1") { addApiDependency("net.java.dev.jna:jna") }
}

// 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 = false // Only allow Jars with 'module-info' on all module paths
failOnAutomaticModules = true // Only allow Jars with 'module-info' on all module paths

module("com.google.api.grpc:proto-google-common-protos", "com.google.api.grpc.common")
module("com.google.guava:guava", "com.google.common") {
module("io.grpc:grpc-api", "io.grpc") {
exportAllPackages()
requireAllDefinedDependencies()
requires("java.logging")
}
module("com.google.protobuf:protobuf-java", "com.google.protobuf") {

module("io.grpc:grpc-core", "io.grpc.internal")
module("io.grpc:grpc-context", "io.grpc.context")
module("io.grpc:grpc-stub", "io.grpc.stub") {
exportAllPackages()
requireAllDefinedDependencies()
requires("java.logging")
}
module("io.grpc:grpc-api", "io.grpc") {
module("io.grpc:grpc-testing", "io.grpc.testing")
module("io.grpc:grpc-services", "io.grpc.services")
module("io.grpc:grpc-util", "io.grpc.util")
module("io.grpc:grpc-protobuf", "io.grpc.protobuf")
module("io.grpc:grpc-protobuf-lite", "io.grpc.protobuf.lite")
module("com.github.spotbugs:spotbugs-annotations", "com.github.spotbugs.annotations")
module("com.google.code.findbugs:jsr305", "java.annotation") {
exportAllPackages()
mergeJar("javax.annotation:javax.annotation-api")
}
module("com.google.errorprone:error_prone_annotations", "com.google.errorprone.annotations")
module("com.google.j2objc:j2objc-annotations", "com.google.j2objc.annotations")
module("com.google.protobuf:protobuf-java", "com.google.protobuf") {
exportAllPackages()
requireAllDefinedDependencies()
requires("java.logging")
}
module("io.grpc:grpc-core", "io.grpc.internal")
module("io.grpc:grpc-context", "io.grpc.context")
module("io.grpc:grpc-protobuf", "io.grpc.protobuf")
module("io.grpc:grpc-protobuf-lite", "io.grpc.protobuf.lite")
module("io.grpc:grpc-stub", "io.grpc.stub") {
module("com.google.guava:guava", "com.google.common") {
exportAllPackages()
requireAllDefinedDependencies()
requires("java.logging")
}
module("io.grpc:grpc-util", "io.grpc.util")
module("com.google.guava:failureaccess", "com.google.common.util.concurrent.internal")
module("com.google.api.grpc:proto-google-common-protos", "com.google.api.grpc.common")

module("io.perfmark:perfmark-api", "io.perfmark")
module("javax.inject:javax.inject", "javax.inject")

module("junit:junit", "junit")
module("org.mockito:mockito-core", "org.mockito")
module("org.mockito:mockito-junit-jupiter", "org.mockito.junit.jupiter")
module("commons-codec:commons-codec", "org.apache.commons.codec")
module("org.apache.commons:commons-math3", "org.apache.commons.math3")
module("org.apache.commons:commons-collections4", "org.apache.commons.collections4")
module("com.esaulpaugh:headlong", "headlong")

// spotbugs
module("com.github.spotbugs:spotbugs-annotations", "com.github.spotbugs.annotations")
module("com.google.code.findbugs:jsr305", "java.annotation") { exportAllPackages() }
module("org.checkerframework:checker-qual", "org.checkerframework.checker.qual")
module("net.i2p.crypto:eddsa", "net.i2p.crypto.eddsa")
module("org.antlr:antlr4-runtime", "org.antlr.antlr4.runtime")

// needed for metrics and logging, but also several platform classes
module("com.goterl:resource-loader", "resource.loader")
module("com.goterl:lazysodium-java", "lazysodium.java")
module("org.hyperledger.besu:secp256k1", "org.hyperledger.besu.nativelib.secp256k1")
module("net.java.dev.jna:jna", "com.sun.jna") {
exportAllPackages()
requires("java.logging")
}
module("io.prometheus:simpleclient", "io.prometheus.simpleclient")
module("io.prometheus:simpleclient_common", "io.prometheus.simpleclient_common")
module("io.prometheus:simpleclient_httpserver", "io.prometheus.simpleclient.httpserver") {
Expand All @@ -117,4 +146,22 @@ extraJavaModuleInfo {
module("com.google.auto.service:auto-service-annotations", "com.google.auto.service")
module("com.google.auto.service:auto-service", "com.google.auto.service.processor")
module("com.google.auto:auto-common", "com.google.auto.common")

// JMH only
jsync-swirlds marked this conversation as resolved.
Show resolved Hide resolved
module("net.sf.jopt-simple:jopt-simple", "jopt.simple")
module("org.openjdk.jmh:jmh-core", "jmh.core")
module("org.openjdk.jmh:jmh-generator-asm", "jmh.generator.asm")
module("org.openjdk.jmh:jmh-generator-bytecode", "jmh.generator.bytecode")
module("org.openjdk.jmh:jmh-generator-reflection", "jmh.generator.reflection")

module("com.google.protobuf:protobuf-java-util", "com.google.protobuf.util")
module("junit:junit", "junit")
module("org.hamcrest:hamcrest", "org.hamcrest")
module("org.json:json", "org.json")
module("org.mockito:mockito-core", "org.mockito")
module("org.objenesis:objenesis", "org.objenesis")
module("org.rnorth.duct-tape:duct-tape", "org.rnorth.ducttape")
module("org.testcontainers:junit-jupiter", "org.testcontainers.junit.jupiter")
module("org.testcontainers:testcontainers", "org.testcontainers")
module("org.mockito:mockito-junit-jupiter", "org.mockito.junit.jupiter")
}
mattp-swirldslabs marked this conversation as resolved.
Show resolved Hide resolved
65 changes: 65 additions & 0 deletions buildSrc/src/main/kotlin/com.hedera.block.protobuf.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
mattp-swirldslabs marked this conversation as resolved.
Show resolved Hide resolved
*
* 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 com.hedera.block.tasks.GitClone

plugins {
id("java-library")
id("com.hedera.block.conventions")
id("com.google.protobuf")
}

tasks.register<GitClone>("cloneHederaProtobufs") {
url = "https://github.com/hashgraph/hedera-protobufs.git"
offline = gradle.startParameter.isOffline
localCloneDirectory = layout.buildDirectory.dir("hedera-protobufs")
}

// Configure Protobuf Plugin to download protoc executable rather than using local installed version
protobuf {
val libs = the<VersionCatalogsExtension>().named("libs")
protoc { artifact = "com.google.protobuf:protoc:" + libs.findVersion("google.proto").get() }
plugins {
// Add GRPC plugin as we need to generate GRPC services
id("grpc") {
artifact =
"io.grpc:protoc-gen-grpc-java:" + libs.findVersion("grpc.protobuf.grpc").get()
}
}
generateProtoTasks { ofSourceSet("main").forEach { it.plugins { id("grpc") } } }
mattp-swirldslabs marked this conversation as resolved.
Show resolved Hide resolved
}

tasks.javadoc {
options {
this as StandardJavadocDocletOptions
// There are violations in the generated protobuf code
addStringOption("Xdoclint:-reference,-html", "-quiet")
}
}

// Give JUnit more ram and make it execute tests in parallel
tasks.test {
// We are running a lot of tests 10s of thousands, so they need to run in parallel. Make each
// class run in parallel.
systemProperties["junit.jupiter.execution.parallel.enabled"] = true
systemProperties["junit.jupiter.execution.parallel.mode.default"] = "concurrent"
// limit amount of threads, so we do not use all CPU
systemProperties["junit.jupiter.execution.parallel.config.dynamic.factor"] = "0.9"
// us parallel GC to keep up with high temporary garbage creation,
// and allow GC to use 40% of CPU if needed
jvmArgs("-XX:+UseParallelGC", "-XX:GCTimeRatio=90")
mattp-swirldslabs marked this conversation as resolved.
Show resolved Hide resolved
}
91 changes: 91 additions & 0 deletions buildSrc/src/main/kotlin/com/hedera/block/tasks/GitClone.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2022-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.
*/

package com.hedera.block.tasks

import javax.inject.Inject
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.process.ExecOperations

abstract class GitClone : DefaultTask() {

@get:Input abstract val url: Property<String>

@get:Input @get:Optional abstract val tag: Property<String>

@get:Input @get:Optional abstract val branch: Property<String>

@get:Input abstract val offline: Property<Boolean>

@get:OutputDirectory abstract val localCloneDirectory: DirectoryProperty

@get:Inject protected abstract val exec: ExecOperations

init {
// If a 'branch' is configured, the task is never up-to-date as it may change
outputs.upToDateWhen { !branch.isPresent }
}

@TaskAction
fun cloneOrUpdate() {
if (!tag.isPresent && !branch.isPresent || tag.isPresent && branch.isPresent) {
throw RuntimeException("Define either 'tag' or 'branch'")
}

val localClone = localCloneDirectory.get()
if (!offline.get()) {
exec.exec {
if (!localClone.dir(".git").asFile.exists()) {
workingDir = localClone.asFile.parentFile
commandLine(
"git",
"clone",
"https://github.com/hashgraph/hedera-protobufs.git",
mattp-swirldslabs marked this conversation as resolved.
Show resolved Hide resolved
"-q"
)
} else {
workingDir = localClone.asFile
commandLine("git", "fetch", "-q")
}
}
}
if (tag.isPresent) {
exec.exec {
workingDir = localClone.asFile
commandLine("git", "checkout", tag.get(), "-q")
}
exec.exec {
workingDir = localClone.asFile
commandLine("git", "reset", "--hard", tag.get(), "-q")
}
} else {
exec.exec {
workingDir = localClone.asFile
commandLine("git", "checkout", branch.get(), "-q")
}
exec.exec {
workingDir = localClone.asFile
commandLine("git", "reset", "--hard", "origin/${branch.get()}", "-q")
}
}
}
}
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ coverage:

ignore:
- "server/src/main/java/com/hedera/block/server/Server.java"
- "server/src/main/java/com/hedera/block/server/Translator.java"
23 changes: 21 additions & 2 deletions gradle/modules.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,24 @@ com.lmax.disruptor=com.lmax:disruptor
io.helidon.webserver=io.helidon.webserver:helidon-webserver
io.helidon.webserver.grpc=io.helidon.webserver:helidon-webserver-grpc
io.helidon.webserver.testing.junit5=io.helidon.webserver.testing.junit5:helidon-webserver-testing-junit5
io.grpc=io.grpc:grpc-stub
grpc.protobuf=io.grpc:grpc-protobuf
google.proto=com.google.protobuf:protoc

org.antlr.antlr4.runtime=org.antlr:antlr4-runtime

com.google.common=com.google.guava:guava
io.grpc.protobuf=io.grpc:grpc-protobuf
io.grpc.stub=io.grpc:grpc-stub
io.grpc=io.grpc:grpc-api
com.hedera.pbj.runtime=com.hedera.pbj:pbj-runtime

com.google.protobuf=com.google.protobuf:protobuf-java
com.google.protobuf.util=com.google.protobuf:protobuf-java-util
com.apache.commons.codec=commons-codec:commons-codec
org.apache.commons.collections4=org.apache.commons:commons-collections4
org.apache.commons.io=commons-io:commons-io
org.apache.commons.lang3=org.apache.commons:commons-lang3
org.apache.commons.compress=org.apache.commons:commons-compress

org.slf4j=org.apache.logging.log4j:log4j-slf4j2-impl
java.annotation=javax.annotation:javax.annotation-api
org.apache.logging.log4j.slf4j2.impl=org.apache.logging.log4j:log4j-slf4j2-impl
Loading
Loading