2 require 'rexml/document'
3 require 'rexml/streamlistener'
6 include REXML::StreamListener
8 attr_accessor :group_id, :artifact_id, :text
10 attr_accessor :callback
11 def initialize(callback)
16 def tag_start(name, attrs)
20 if attrs['xmlns'] and attrs['xmlns'] !~ /^http:\/\/maven\.apache\.org\/POM\//
21 # False alarm -- it contains a project element, but of another namespace
24 when 'plugin', 'dependency'
33 @group_id = clean(@text)
35 @artifact_id = clean(@text)
36 when /^(plugin|dependency)$/
37 if @is_pom_file && @group_id && @artifact_id
38 @callback.call($1, @group_id, @artifact_id)
43 # Remove whitespace from text values.
44 # Also, clear out variable substitutions, which we are incapable of performing correctly
46 s.strip.gsub(/\$\{.*\}/, '')