1- buildscript {
2- repositories {
3- mavenCentral()
4- }
5-
6- dependencies {
7- classpath group : ' com.google.protobuf' , name : ' protobuf-gradle-plugin' , version : ' 0.9.5'
8- }
1+ plugins {
2+ id ' com.google.protobuf' version ' 0.9.5'
3+ id ' java-library'
4+ id ' java-test-fixtures'
95}
106
117description = " Core functionality to fetch, process and validate X.509 and JWT SVIDs and Bundles from the Workload API."
128
13- apply plugin : ' com.google.protobuf'
14- apply plugin : ' java-test-fixtures'
15-
169sourceSets {
1710 main {
1811 java {
@@ -22,80 +15,107 @@ sourceSets {
2215 }
2316
2417 integrationTest {
25- java {
26- compileClasspath + = main. output + test. output
27- runtimeClasspath + = main. output + test. output
28- srcDir file(' src/integrationTest/java' )
29- }
18+ java. srcDir file(' src/integrationTest/java' )
3019 resources. srcDir file(' src/integrationTest/resources' )
20+
21+ compileClasspath + = sourceSets. main. output + sourceSets. test. output
22+ runtimeClasspath + = sourceSets. main. output + sourceSets. test. output
3123 }
3224}
3325
34- sourcesJar. duplicatesStrategy = DuplicatesStrategy . INCLUDE
26+ tasks. named(' sourcesJar' ) {
27+ duplicatesStrategy = DuplicatesStrategy . INCLUDE
28+ }
3529
3630configurations {
37- integrationTestImplementation. extendsFrom testImplementation
38- integrationTestCompile. extendsFrom testCompile
39- integrationTestCompileOnly. extendsFrom testCompileOnly
40- integrationTestRuntime. extendsFrom testRuntime
41- integrationTestRuntimeOnly. extendsFrom testRuntimeOnly
31+ integrationTestImplementation. extendsFrom(testImplementation)
32+ integrationTestRuntimeOnly. extendsFrom(testRuntimeOnly)
33+ integrationTestCompileOnly. extendsFrom(testCompileOnly)
34+
35+ protocTool
36+ grpcTool
4237}
4338
44- task integrationTest (type : Test ) {
39+ tasks. register(' integrationTest' , Test ) {
40+ description = ' Runs integration tests.'
41+ group = ' verification'
42+
4543 useJUnitPlatform()
4644 testClassesDirs = sourceSets. integrationTest. output. classesDirs
4745 classpath = sourceSets. integrationTest. runtimeClasspath
48- outputs. upToDateWhen { false }
49- }
5046
51- protobuf {
52- protoc {
53- artifact = ' com.google.protobuf:protoc:3.25.5'
54- }
55- plugins {
56- grpc {
57- artifact = " io.grpc:protoc-gen-grpc-java:${ grpcVersion} "
58- }
59- }
60- generateProtoTasks {
61- all()* . plugins {
62- grpc {}
63- }
64- }
47+ shouldRunAfter(tasks. named(' test' ))
6548}
6649
50+ def protocExe = " com.google.protobuf:protoc:3.25.5:${ osdetector.classifier} @exe"
51+ def grpcExe = " io.grpc:protoc-gen-grpc-java:${ grpcVersion} :${ osdetector.classifier} @exe"
52+
6753dependencies {
68- if (osdetector. os. is(' osx' ) ) {
69- project. ext. osArch = System . getProperty(" os.arch" )
70- if (" x86_64" == project. ext. osArch) {
54+ protocTool protocExe
55+ grpcTool grpcExe
56+
57+ def osArch = System . getProperty(" os.arch" )
58+
59+ if (osdetector. os. is(' osx' )) {
60+ if (osArch == " x86_64" ) {
7161 compileOnly(project(' grpc-netty-macos' ))
7262 testImplementation(project(' grpc-netty-macos' ))
73- } else if (" aarch64 " == project . ext . osArch ) {
63+ } else if (osArch == " aarch64 " ) {
7464 compileOnly(project(' grpc-netty-macos-aarch64' ))
7565 testImplementation(project(' grpc-netty-macos-aarch64' ))
7666 } else {
77- throw new GradleException (" Architecture not supported: " + project . ext . osArch)
67+ throw new GradleException (" Architecture not supported: ${ osArch} " )
7868 }
7969 } else {
8070 compileOnly(project(' grpc-netty-linux' ))
8171 testImplementation(project(' grpc-netty-linux' ))
8272 }
8373
84- project. ext. osArch = System . getProperty(" os.arch" )
74+ implementation " io.grpc:grpc-protobuf:${ grpcVersion} "
75+ implementation " io.grpc:grpc-stub:${ grpcVersion} "
76+ testImplementation " io.grpc:grpc-inprocess:${ grpcVersion} "
77+ testImplementation " io.grpc:grpc-testing:${ grpcVersion} "
78+
79+ compileOnly " org.apache.tomcat:annotations-api:6.0.53"
80+
81+ implementation " com.nimbusds:nimbus-jose-jwt:${ nimbusVersion} "
82+ testFixturesImplementation " com.nimbusds:nimbus-jose-jwt:${ nimbusVersion} "
8583
84+ testFixturesImplementation " org.bouncycastle:bcpkix-jdk15on:1.70"
85+ testFixturesImplementation " org.apache.commons:commons-lang3:3.20.0"
86+ }
87+
88+ protobuf {
89+ protoc {
90+ path = configurations. protocTool. singleFile. absolutePath
91+ }
92+ plugins {
93+ grpc {
94+ path = configurations. grpcTool. singleFile. absolutePath
95+ }
96+ }
97+ generateProtoTasks {
98+ all(). configureEach {
99+ plugins {
100+ grpc {}
101+ }
102+ }
103+ }
104+ }
86105
87- implementation group : ' io.grpc' , name : ' grpc-protobuf' , version : " ${ grpcVersion} "
88- implementation group : ' io.grpc' , name : ' grpc-stub' , version : " ${ grpcVersion} "
89- testImplementation group : ' io.grpc' , name : ' grpc-inprocess' , version : " ${ grpcVersion} "
90- testImplementation group : ' io.grpc' , name : ' grpc-testing' , version : " ${ grpcVersion} "
91- compileOnly group : ' org.apache.tomcat' , name : ' annotations-api' , version : ' 6.0.53' // necessary for Java 9+
106+ import com.google.protobuf.gradle.GenerateProtoTask
92107
93- // library for processing JWT tokens and JOSE JWK bundles
94- implementation group : ' com.nimbusds' , name : ' nimbus-jose-jwt' , version : " ${ nimbusVersion} "
95- testFixturesImplementation group : ' com.nimbusds' , name : ' nimbus-jose-jwt' , version : " ${ nimbusVersion} "
108+ def protocBin = configurations. protocTool. singleFile
109+ def grpcBin = configurations. grpcTool. singleFile
96110
97- // using bouncy castle for generating X.509 certs for testing purposes
98- testFixturesImplementation group : ' org.bouncycastle' , name : ' bcpkix-jdk15on' , version : ' 1.70'
99- testFixturesImplementation group : ' org.apache.commons' , name : ' commons-lang3' , version : ' 3.20.0'
111+ tasks. register(" makeProtoToolsExecutable" ) {
112+ inputs. files(protocBin, grpcBin)
113+ doLast {
114+ protocBin. setExecutable(true , false )
115+ grpcBin. setExecutable(true , false )
116+ }
100117}
101118
119+ tasks. withType(GenerateProtoTask ). configureEach {
120+ dependsOn(tasks. named(" makeProtoToolsExecutable" ))
121+ }
0 commit comments