1 require 'rexml/document'
4 class MavenRule < FileRule
6 attr_accessor :group, :artifact, :type
8 # Type is either 'dependency' or 'plugin'
13 @group = /^#{Regexp.escape(@group.to_s)}$/ unless @group.is_a? Regexp
15 @artifact = args.shift || /.*/
16 @artifact = /^#{Regexp.escape(@artifact.to_s)}$/ unless @artifact.is_a? Regexp
21 def process_source_file(source_file)
22 callback = lambda do |type, group, artifact|
23 if type == @type and group =~ @group and artifact =~ @artifact
28 if source_file.filename =~ /\bpom\.xml$/ && source_file.language_breakdown('xml')
30 REXML::Document.parse_stream(source_file.language_breakdown('xml').code, MavenListener.new(callback))
31 rescue REXML::ParseException
32 # Malformed XML! -- ignore and move on