File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,29 @@ dependencies {
31
31
testImplementation group : ' org.mockito' , name : ' mockito-junit-jupiter' , version : ' 3.12.4'
32
32
}
33
33
34
+ ext {
35
+ checkProtocVersion = { String output ->
36
+ // Line in format like: libprotoc 26.1
37
+ int majorVersion = java.lang.Integer . parseInt(output. split(" " )[1 ]. split(" \\ ." )[0 ]. trim());
38
+ int minorVersion = java.lang.Integer . parseInt(output. split(" " )[1 ]. split(" \\ ." )[1 ]. trim());
39
+ if (majorVersion < 26 || (majorVersion == 26 && minorVersion < 1 )) {
40
+ throw new GradleException (" Use Protoc version 26.1 or later" );
41
+ }
42
+ return output. split(" " )[1 ]
43
+ }
44
+ }
45
+
34
46
tasks. register(' protobuf' , Exec ) {
35
47
doFirst {
48
+ new ByteArrayOutputStream (). withStream { os ->
49
+ exec {
50
+ commandLine ' protoc' , ' --version'
51
+ workingDir Paths . get(project. rootDir. path, ' ..' ). toFile()
52
+ standardOutput = os
53
+ }
54
+ checkProtocVersion(os. toString())
55
+ }
56
+
36
57
project. mkdir(Paths . get(project. projectDir. path, ' src/main/java/glide/models/protobuf' ). toString())
37
58
}
38
59
commandLine ' protoc' ,
You can’t perform that action at this time.
0 commit comments