-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
123 lines (107 loc) · 3.91 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
123 lines (107 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// SPDX-License-Identifier: Apache-2.0
plugins {
id("org.hiero.gradle.module.library")
id("org.hiero.gradle.feature.test-integration")
id("org.hiero.gradle.feature.protobuf")
id("org.hiero.gradle.feature.publish-dependency-constraints")
}
description = "Hedera™ Hashgraph SDK for Java"
javaModuleDependencies.moduleNameToGA.put(
"com.google.protobuf",
"com.google.protobuf:protobuf-javalite",
)
// Define dependency constraints for gRPC implementations so that clients automatically get the
// correct version
dependencies {
publishDependencyConstraint("io.grpc:grpc-netty")
publishDependencyConstraint("io.grpc:grpc-netty-shaded")
publishDependencyConstraint("io.grpc:grpc-okhttp")
}
testModuleInfo {
requires("com.fasterxml.jackson.annotation")
requires("com.fasterxml.jackson.core")
requires("com.fasterxml.jackson.databind")
requires("json.snapshot")
requires("org.assertj.core")
requires("org.junit.jupiter.api")
requires("org.junit.jupiter.params")
requires("org.mockito")
requires("jdk.httpserver")
runtimeOnly("io.grpc.netty.shaded")
runtimeOnly("org.slf4j.simple")
}
testIntegrationModuleInfo {
runtimeOnly("io.grpc.netty.shaded")
runtimeOnly("org.slf4j.simple")
}
// Remap protobuf java_package to SDK namespace to avoid FQCN conflicts
// when used alongside hedera-protobuf-java-api
val transformProtos by tasks.registering(Copy::class) {
from("src/main/proto")
into(layout.buildDirectory.dir("transformed-protos"))
filter { line ->
if (line.trim().startsWith("option java_package")) {
line.replace("com.hedera.hapi", "com.hedera.hashgraph.sdk.proto")
.replace("com.hederahashgraph.api.proto.java", "com.hedera.hashgraph.sdk.proto")
.replace("com.hederahashgraph.service.proto.java", "com.hedera.hashgraph.sdk.proto")
.replace("com.hedera.mirror.api.proto", "com.hedera.hashgraph.sdk.proto.mirror")
} else {
line
}
}
}
sourceSets {
main {
proto {
setSrcDirs(listOf(transformProtos))
}
}
}
protobuf {
generateProtoTasks {
all().configureEach {
builtins.named("java") { option("lite") }
plugins.named("grpc") { option("lite") }
}
}
}
tasks.withType<Test>().configureEach {
systemProperty("CONFIG_FILE", providers.gradleProperty("CONFIG_FILE").getOrElse(""))
systemProperty("HEDERA_NETWORK", providers.gradleProperty("HEDERA_NETWORK").getOrElse(""))
systemProperty("OPERATOR_ID", providers.gradleProperty("OPERATOR_ID").getOrElse(""))
systemProperty("OPERATOR_KEY", providers.gradleProperty("OPERATOR_KEY").getOrElse(""))
}
tasks.testIntegration {
maxParallelForks = 1
failFast = true
}
tasks.withType<JavaCompile>().configureEach { options.compilerArgs.add("-Xlint:-exports,-dep-ann") }
dependencyAnalysis.abi {
exclusions {
// Exposes: org.slf4j.Logger
excludeClasses("logger")
// Exposes: com.google.common.base.MoreObjects.ToStringHelper
excludeClasses(".*\\.CustomFee")
// Exposes: com.esaulpaugh.headlong.abi.Tuple
excludeClasses(".*\\.ContractFunctionResult")
// Exposes: org.bouncycastle.crypto.params.KeyParameter
excludeClasses(".*\\.PrivateKey.*")
// Exposes: io.grpc.stub.AbstractFutureStub (and others)
excludeClasses(".*Grpc")
}
}
tasks.register<Delete>("updateSnapshots") {
delete(sourceSets.test.get().allSource.matching { include("**/*.snap") })
finalizedBy(tasks.test)
}
tasks.register<Exec>("updateProto") {
executable = File(rootDir, "scripts/update_protobufs.py").absolutePath
args("main") // argument is the branch/tag
}
tasks.withType<Test>().configureEach {
if (project.hasProperty("skipNodeUpdateTest")) {
exclude(
"com/hedera/hashgraph/sdk/test/integration/NodeUpdateTransactionIntegrationTest.class"
)
}
}