@@ -33,17 +33,27 @@ if (apiTargetFile.exists()) {
3333 println " Adding api file from a template ($apiTemplateFile )."
3434}
3535
36- def proc = new ProcessBuilder ([" mvn" , " wrapper:wrapper" , " initialize" , " initialize" ])
37- .directory(outputDir)
38- .redirectErrorStream(true )
39- .start()
40- proc. inputStream. eachLine {println it}
41- proc. waitForOrKill(10000 )
42- if ( proc. exitValue() != 0 ){
43- String errorMsg = " ERROR during the maven execution."
44- println " -> $errorMsg "
45- throw new Exception (" $errorMsg " )
46- } else {
47- println " -> Finished maven execution"
36+ def runMaven (File workDir , String ... args ) {
37+ def baseCommand = [" mvn" ]
38+ def command = baseCommand + args. toList()
39+
40+ def proc = new ProcessBuilder (command)
41+ .directory(workDir)
42+ .redirectErrorStream(true )
43+ .start()
44+
45+ proc. inputStream. eachLine { println it }
46+ proc. waitForOrKill(10000 )
47+
48+ if (proc. exitValue() != 0 ) {
49+ def errorMsg = " ERROR during maven execution: ${ args.join(' ')} "
50+ println " -> $errorMsg "
51+ throw new Exception (errorMsg)
52+ }
53+
54+ println " -> Finished maven execution: ${ args.join(' ')} "
4855}
4956
57+ runMaven(outputDir, " wrapper:wrapper" )
58+ runMaven(outputDir, " initialize" )
59+ runMaven(outputDir, " initialize" )
0 commit comments