1plugins { 2 // Provide convenience executables for trying out the examples. 3 id 'application' 4 // ASSUMES GRADLE 5.6 OR HIGHER. Use plugin version 0.8.10 with earlier gradle versions 5 id 'com.google.protobuf' version '0.8.17' 6 // Generate IntelliJ IDEA's .idea & .iml project files 7 id 'idea' 8} 9 10repositories { 11 maven { // The google mirror is less flaky than mavenCentral() 12 url "https://maven-central.storage-download.googleapis.com/maven2/" 13 } 14 mavenLocal() 15} 16 17sourceCompatibility = 1.8 18targetCompatibility = 1.8 19 20// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you 21// are looking at a tagged version of the example and not "master"! 22 23// Feel free to delete the comment at the next line. It is just for safely 24// updating the version in our release process. 25def grpcVersion = '1.56.1-SNAPSHOT' // CURRENT_GRPC_VERSION 26def protobufVersion = '3.22.3' 27def protocVersion = protobufVersion 28 29dependencies { 30 implementation "io.grpc:grpc-protobuf:${grpcVersion}" 31 implementation "io.grpc:grpc-stub:${grpcVersion}" 32 implementation "io.jsonwebtoken:jjwt:0.9.1" 33 implementation "javax.xml.bind:jaxb-api:2.3.1" 34 35 compileOnly "org.apache.tomcat:annotations-api:6.0.53" 36 37 runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}" 38 39 testImplementation "io.grpc:grpc-testing:${grpcVersion}" 40 testImplementation "junit:junit:4.13.2" 41 testImplementation "org.mockito:mockito-core:3.4.0" 42} 43 44protobuf { 45 protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" } 46 plugins { 47 grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" } 48 } 49 generateProtoTasks { 50 all()*.plugins { grpc {} } 51 } 52} 53 54// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code. 55sourceSets { 56 main { 57 java { 58 srcDirs 'build/generated/source/proto/main/grpc' 59 srcDirs 'build/generated/source/proto/main/java' 60 } 61 } 62} 63 64startScripts.enabled = false 65 66task hellowWorldJwtAuthServer(type: CreateStartScripts) { 67 mainClass = 'io.grpc.examples.jwtauth.AuthServer' 68 applicationName = 'auth-server' 69 outputDir = new File(project.buildDir, 'tmp/scripts/' + name) 70 classpath = startScripts.classpath 71} 72 73task hellowWorldJwtAuthClient(type: CreateStartScripts) { 74 mainClass = 'io.grpc.examples.jwtauth.AuthClient' 75 applicationName = 'auth-client' 76 outputDir = new File(project.buildDir, 'tmp/scripts/' + name) 77 classpath = startScripts.classpath 78} 79 80applicationDistribution.into('bin') { 81 from(hellowWorldJwtAuthServer) 82 from(hellowWorldJwtAuthClient) 83 fileMode = 0755 84} 85