Issue #47: scaffold Java Gradle build
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'com.google.protobuf'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api "com.google.protobuf:protobuf-java:${protobufVersion}"
|
||||
api "io.grpc:grpc-protobuf:${grpcVersion}"
|
||||
api "io.grpc:grpc-stub:${grpcVersion}"
|
||||
|
||||
implementation "io.grpc:grpc-netty-shaded:${grpcVersion}"
|
||||
|
||||
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
proto {
|
||||
srcDir rootProject.file('../../src/MxGateway.Contracts/Protos')
|
||||
include 'mxaccess_gateway.proto'
|
||||
include 'mxaccess_worker.proto'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protobuf {
|
||||
protoc {
|
||||
artifact = "com.google.protobuf:protoc:${protobufVersion}"
|
||||
}
|
||||
|
||||
plugins {
|
||||
grpc {
|
||||
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
generatedFilesBaseDir = rootProject.file('src/main/generated').absolutePath
|
||||
|
||||
generateProtoTasks {
|
||||
all().configureEach {
|
||||
plugins {
|
||||
grpc {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.dohertylan.mxgateway.client;
|
||||
|
||||
public final class MxGatewayClientVersion {
|
||||
private static final int GATEWAY_PROTOCOL_VERSION = 1;
|
||||
private static final int WORKER_PROTOCOL_VERSION = 1;
|
||||
private static final String CLIENT_VERSION = "0.1.0";
|
||||
|
||||
private MxGatewayClientVersion() {
|
||||
}
|
||||
|
||||
public static String clientVersion() {
|
||||
return CLIENT_VERSION;
|
||||
}
|
||||
|
||||
public static int gatewayProtocolVersion() {
|
||||
return GATEWAY_PROTOCOL_VERSION;
|
||||
}
|
||||
|
||||
public static int workerProtocolVersion() {
|
||||
return WORKER_PROTOCOL_VERSION;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.dohertylan.mxgateway.client;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import mxaccess_gateway.v1.MxAccessGatewayGrpc;
|
||||
import mxaccess_gateway.v1.MxaccessGateway.OpenSessionRequest;
|
||||
import mxaccess_worker.v1.MxaccessWorker.WorkerEnvelope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
final class GeneratedContractSmokeTests {
|
||||
@Test
|
||||
void generatedGatewayAndWorkerContractsCompile() {
|
||||
OpenSessionRequest request = OpenSessionRequest.newBuilder()
|
||||
.setClientSessionName("junit")
|
||||
.build();
|
||||
WorkerEnvelope envelope = WorkerEnvelope.newBuilder()
|
||||
.setProtocolVersion(MxGatewayClientVersion.workerProtocolVersion())
|
||||
.build();
|
||||
|
||||
assertEquals("junit", request.getClientSessionName());
|
||||
assertEquals("mxaccess_gateway.v1.MxAccessGateway", MxAccessGatewayGrpc.SERVICE_NAME);
|
||||
assertEquals(1, envelope.getProtocolVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
void javaTwentyOneToolchainRunsTests() {
|
||||
assertEquals(21, Runtime.version().feature());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user