Skip to content
Open
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,31 @@
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")

Check warning on line 51 in sdk/build.gradle.kts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

sdk/build.gradle.kts#L51

Multiple occurrences of the same string literal within a single file detected. Prefer extracting the string literal into a property or constant.
.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 {
Expand Down