Skip to content

Commit a6bbc1b

Browse files
committed
add support for enforcer plugin
1 parent cf4b4e1 commit a6bbc1b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Dangerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,44 @@ else
194194
print_errors_summary 'rflint', errors_count, 'https://github.com/php-coder/mystamps/wiki/rflint'
195195
end
196196

197+
# Handle `mvn enforcer:enforce` results
198+
enforcer_output = 'enforcer.log'
199+
unless File.file?(enforcer_output)
200+
warn("Couldn't find #{enforcer_report}. maven-enforcer-plugin result is unknown")
201+
else
202+
errors = []
203+
plugin_output_started = false
204+
File.readlines(enforcer_output).each do |line|
205+
# We're interesting in everything between
206+
# [INFO] --- maven-enforcer-plugin:1.4.1:enforce (default-cli) @ mystamps ---
207+
# and
208+
# [INFO] ------------------------------------------------------------------------
209+
# lines
210+
211+
if line.start_with? '[INFO] --- maven-enforcer-plugin:'
212+
plugin_output_started = true
213+
next
214+
end
215+
216+
unless plugin_output_started
217+
next
218+
end
219+
220+
if line.start_with? '[INFO] -----'
221+
break
222+
end
223+
224+
line.sub!('[WARNING] ', '')
225+
errors << line
226+
end
227+
228+
unless errors.empty?
229+
error_msgs = errors.join()
230+
fail("maven-enforcer-plugin reported about errors. Please, fix them. "\
231+
"Here is its output:\n```\n#{error_msgs}```")
232+
end
233+
end
234+
197235
# Handle `mvn findbugs:check` results
198236
findbugs_report = 'target/findbugsXml.xml'
199237
unless File.file?(findbugs_report)

0 commit comments

Comments
 (0)