@@ -234,6 +234,58 @@ else
234
234
print_errors_summary 'rflint' , errors_count , 'https://github.com/php-coder/mystamps/wiki/rflint'
235
235
end
236
236
237
+ # Handle `mvn enforcer:enforce` results
238
+ #
239
+ # Example:
240
+ # [INFO] --- maven-enforcer-plugin:1.4.1:enforce (default-cli) @ mystamps ---
241
+ # [WARNING] Rule 0: org.apache.maven.plugins.enforcer.BannedDependencies failed with message:
242
+ # Found Banned Dependency: junit:junit:jar:4.12
243
+ # Use 'mvn dependency:tree' to locate the source of the banned dependencies.
244
+ # [INFO] ------------------------------------------------------------------------
245
+ # [INFO] BUILD FAILURE
246
+ # [INFO] ------------------------------------------------------------------------
247
+ #
248
+ enforcer_output = 'enforcer.log'
249
+ unless File . file? ( enforcer_output )
250
+ warn ( "Couldn't find #{ enforcer_output } . maven-enforcer-plugin result is unknown" )
251
+ else
252
+ errors = [ ]
253
+ plugin_output_started = false
254
+ File . readlines ( enforcer_output ) . each do |line |
255
+ # We're interesting in everything between
256
+ # [INFO] --- maven-enforcer-plugin:1.4.1:enforce (default-cli) @ mystamps ---
257
+ # and
258
+ # [INFO] ------------------------------------------------------------------------
259
+ # lines
260
+
261
+ if line . start_with? '[INFO] --- maven-enforcer-plugin:'
262
+ plugin_output_started = true
263
+ next
264
+ end
265
+
266
+ unless plugin_output_started
267
+ next
268
+ end
269
+
270
+ if line . start_with? '[INFO] -----'
271
+ break
272
+ end
273
+
274
+ if line . start_with? '[INFO] Download'
275
+ next
276
+ end
277
+
278
+ line . sub! ( '[WARNING] ' , '' )
279
+ errors << line . rstrip
280
+ end
281
+
282
+ unless errors . empty?
283
+ error_msgs = errors . join ( "\n " )
284
+ fail ( "maven-enforcer-plugin reported about errors. Please, fix them. " \
285
+ "Here is its output:\n ```\n #{ error_msgs } \n ```" )
286
+ end
287
+ end
288
+
237
289
# Handle `mvn findbugs:check` results
238
290
#
239
291
# Example:
0 commit comments