281
281
282
282
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:compile` output
283
283
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:testCompile` output
284
+ # Handle `mvn org.codehaus.gmaven:gmaven-plugin:testCompile` output
284
285
#
285
- # Example:
286
+ # Example for maven-compiler-plugin :
286
287
# [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ mystamps ---
287
288
# [INFO] Changes detected - recompiling the module!
288
289
# [INFO] Compiling 206 source files to /home/coder/mystamps.git/target/classes
298
299
# [INFO] BUILD FAILURE
299
300
# [INFO] ------------------------------------------------------------------------
300
301
#
302
+ # Example for gmaven-plugin:testCompile:
303
+ # [INFO] --- gmaven-plugin:1.4:testCompile (default-cli) @ mystamps ---
304
+ # [INFO] ------------------------------------------------------------------------
305
+ # [INFO] BUILD FAILURE
306
+ # [INFO] ------------------------------------------------------------------------
307
+ # [INFO] Total time: 2.006 s
308
+ # [INFO] Finished at: 2017-03-01T22:25:47+01:00
309
+ # [INFO] Final Memory: 24M/322M
310
+ # [INFO] ------------------------------------------------------------------------
311
+ # [ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.4:testCompile (default-cli) on project mystamps: startup failed:
312
+ # [ERROR] /home/coder/mystamps/src/test/groovy/ru/mystamps/web/service/SiteServiceImplTest.groovy: 27: unable to resolve class Specification
313
+ # [ERROR] @ line 27, column 1.
314
+ # [ERROR] @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace'])
315
+ # [ERROR] ^
316
+ # [ERROR]
317
+ # [ERROR] 1 error
318
+ # [ERROR] -> [Help 1]
319
+ # [ERROR]
320
+ # [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
321
+ # [ERROR] Re-run Maven using the -X switch to enable full debug logging.
322
+ #
301
323
# We're parsing file with `mvn test` output because compilation occurs before executing tests.
302
324
# Also because goals are executing in order and the process stops if one of
303
325
# them failed, we're using the same array to collect errors from different goals.
@@ -308,19 +330,28 @@ else
308
330
errors = [ ]
309
331
plugin_output_started = false
310
332
errors_detected = false
311
- goal = 'unknown'
333
+ plugin = 'unknown'
312
334
File . readlines ( test_output ) . each do |line |
313
- # We 're interesting in everything between
335
+ # For maven-compiler-plugin we 're interesting in everything between
314
336
# [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ mystamps ---
315
337
# and
316
338
# [INFO] --- gmaven-plugin:1.4:compile (default) @ mystamps ---
317
339
# or
318
340
# [INFO] BUILD FAILURE
319
-
320
341
if line . start_with? '[INFO] --- maven-compiler-plugin:'
342
+ plugin = 'maven-compiler-plugin'
343
+ plugin_output_started = true
344
+ errors << line . rstrip
345
+ next
346
+ end
347
+
348
+ # For maven-compiler-plugin we're interesting in everything between
349
+ # [ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.4:testCompile (default-cli) on project mystamps: startup failed:
350
+ # and
351
+ # [ERROR] -> [Help 1]
352
+ if line . start_with? '[ERROR] Failed to execute goal org.codehaus.gmaven:'
353
+ plugin = 'gmaven-plugin'
321
354
plugin_output_started = true
322
- parsed = line . match ( /:[^:]+:(?<goal>[^ ]+)/ )
323
- goal = parsed [ 'goal' ]
324
355
errors << line . rstrip
325
356
next
326
357
end
@@ -341,8 +372,18 @@ else
341
372
next
342
373
end
343
374
344
- # build failed => error output was collected, stop processing
345
375
if line =~ /BUILD FAILURE/
376
+ if errors . empty?
377
+ # when gmaven plugin fails we need to collect errors after this message
378
+ next
379
+ else
380
+ # build failed => error output is collected, stop processing
381
+ break
382
+ end
383
+ end
384
+
385
+ # stop collecting error message for the gmaven-plugin
386
+ if line . start_with? '[ERROR] -> [Help'
346
387
break
347
388
end
348
389
354
395
errors . pop # remove last useless line
355
396
end
356
397
error_msgs = errors . join ( "\n " )
357
- fail ( "maven-compiler-plugin: #{ goal } has failed. Please, fix compilation errors. " \
398
+ fail ( "#{ plugin } has failed. Please, fix compilation errors. " \
358
399
"Here is its output:\n ```\n #{ error_msgs } \n ```" )
359
400
end
360
401
end
0 commit comments