Skip to content

Commit bd07698

Browse files
committed
Dangerfile: handle gmaven-plugin:testCompile output.
1 parent fd95821 commit bd07698

File tree

1 file changed

+49
-8
lines changed

1 file changed

+49
-8
lines changed

Dangerfile

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,9 @@ end
331331

332332
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:compile` output
333333
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:testCompile` output
334+
# Handle `mvn org.codehaus.gmaven:gmaven-plugin:testCompile` output
334335
#
335-
# Example:
336+
# Example for maven-compiler-plugin:
336337
# [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ mystamps ---
337338
# [INFO] Changes detected - recompiling the module!
338339
# [INFO] Compiling 206 source files to /home/coder/mystamps/target/classes
@@ -348,6 +349,27 @@ end
348349
# [INFO] BUILD FAILURE
349350
# [INFO] ------------------------------------------------------------------------
350351
#
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+
#
351373
# We're parsing file with `mvn test` output because compilation occurs before executing tests.
352374
# Also because goals are executing in order and the process stops if one of
353375
# them failed, we're using the same array to collect errors from different goals.
@@ -358,19 +380,28 @@ else
358380
errors = []
359381
plugin_output_started = false
360382
errors_detected = false
361-
goal = 'unknown'
383+
plugin = 'unknown'
362384
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
364386
# [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ mystamps ---
365387
# and
366388
# [INFO] --- gmaven-plugin:1.4:compile (default) @ mystamps ---
367389
# or
368390
# [INFO] BUILD FAILURE
369-
370391
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'
371404
plugin_output_started = true
372-
parsed = line.match(/:[^:]+:(?<goal>[^ ]+)/)
373-
goal = parsed['goal']
374405
errors << line.rstrip
375406
next
376407
end
@@ -391,8 +422,18 @@ else
391422
next
392423
end
393424

394-
# build failed => error output was collected, stop processing
395425
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'
396437
break
397438
end
398439

@@ -404,7 +445,7 @@ else
404445
errors.pop # remove last useless line
405446
end
406447
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. "\
408449
"Here is its output:\n```\n#{error_msgs}\n```")
409450
end
410451
end

0 commit comments

Comments
 (0)