331
331
332
332
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:compile` output
333
333
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:testCompile` output
334
+ # Handle `mvn org.codehaus.gmaven:gmaven-plugin:testCompile` output
334
335
#
335
- # Example:
336
+ # Example for maven-compiler-plugin :
336
337
# [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ mystamps ---
337
338
# [INFO] Changes detected - recompiling the module!
338
339
# [INFO] Compiling 206 source files to /home/coder/mystamps/target/classes
348
349
# [INFO] BUILD FAILURE
349
350
# [INFO] ------------------------------------------------------------------------
350
351
#
352
+ # Example for gmaven-plugin:testCompile:
353
+ # [INFO] --- gmaven-plugin:1.4:testCompile (default-cli) @ mystamps ---
354
+ # [INFO] ------------------------------------------------------------------------
355
+ # [INFO] BUILD FAILURE
356
+ # [INFO] ------------------------------------------------------------------------
357
+ # [INFO] Total time: 2.006 s
358
+ # [INFO] Finished at: 2017-03-01T22:25:47+01:00
359
+ # [INFO] Final Memory: 24M/322M
360
+ # [INFO] ------------------------------------------------------------------------
361
+ # [ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.4:testCompile (default-cli) on project mystamps: startup failed:
362
+ # [ERROR] /home/coder/mystamps/src/test/groovy/ru/mystamps/web/service/SiteServiceImplTest.groovy: 27: unable to resolve class Specification
363
+ # [ERROR] @ line 27, column 1.
364
+ # [ERROR] @SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace'])
365
+ # [ERROR] ^
366
+ # [ERROR]
367
+ # [ERROR] 1 error
368
+ # [ERROR] -> [Help 1]
369
+ # [ERROR]
370
+ # [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
371
+ # [ERROR] Re-run Maven using the -X switch to enable full debug logging.
372
+ #
351
373
# We're parsing file with `mvn test` output because compilation occurs before executing tests.
352
374
# Also because goals are executing in order and the process stops if one of
353
375
# them failed, we're using the same array to collect errors from different goals.
@@ -358,19 +380,28 @@ else
358
380
errors = [ ]
359
381
plugin_output_started = false
360
382
errors_detected = false
361
- goal = 'unknown'
383
+ plugin = 'unknown'
362
384
File . readlines ( test_output ) . each do |line |
363
- # We 're interesting in everything between
385
+ # For maven-compiler-plugin we 're interesting in everything between
364
386
# [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ mystamps ---
365
387
# and
366
388
# [INFO] --- gmaven-plugin:1.4:compile (default) @ mystamps ---
367
389
# or
368
390
# [INFO] BUILD FAILURE
369
-
370
391
if line . start_with? '[INFO] --- maven-compiler-plugin:'
392
+ plugin = 'maven-compiler-plugin'
393
+ plugin_output_started = true
394
+ errors << line . rstrip
395
+ next
396
+ end
397
+
398
+ # For maven-compiler-plugin we're interesting in everything between
399
+ # [ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.4:testCompile (default-cli) on project mystamps: startup failed:
400
+ # and
401
+ # [ERROR] -> [Help 1]
402
+ if line . start_with? '[ERROR] Failed to execute goal org.codehaus.gmaven:'
403
+ plugin = 'gmaven-plugin'
371
404
plugin_output_started = true
372
- parsed = line . match ( /:[^:]+:(?<goal>[^ ]+)/ )
373
- goal = parsed [ 'goal' ]
374
405
errors << line . rstrip
375
406
next
376
407
end
@@ -391,8 +422,18 @@ else
391
422
next
392
423
end
393
424
394
- # build failed => error output was collected, stop processing
395
425
if line =~ /BUILD FAILURE/
426
+ if errors . empty?
427
+ # when gmaven plugin fails we need to collect errors after this message
428
+ next
429
+ else
430
+ # build failed => error output is collected, stop processing
431
+ break
432
+ end
433
+ end
434
+
435
+ # stop collecting error message for the gmaven-plugin
436
+ if line . start_with? '[ERROR] -> [Help'
396
437
break
397
438
end
398
439
404
445
errors . pop # remove last useless line
405
446
end
406
447
error_msgs = errors . join ( "\n " )
407
- fail ( "maven-compiler-plugin: #{ goal } has failed. Please, fix compilation errors. " \
448
+ fail ( "#{ plugin } has failed. Please, fix compilation errors. " \
408
449
"Here is its output:\n ```\n #{ error_msgs } \n ```" )
409
450
end
410
451
end
0 commit comments