Class: Source::PomFileReader

Inherits:
Object
  • Object
show all
Includes:
HasDirectories, HasOptionMethods
Defined in:
lib/gpm/source/maven.rb

Direct Known Subclasses

PomFromWarFileReader

Instance Attribute Summary

Attributes included from HasOptionMethods

#options

Instance Method Summary collapse

Methods included from HasOptionMethods

included

Methods included from HasDirectories

#in_directory

Constructor Details

#initialize(pomfile, options) ⇒ PomFileReader

Returns a new instance of PomFileReader.



10
11
12
13
14
# File 'lib/gpm/source/maven.rb', line 10

def initialize(pomfile,options)
  @logger = create_logger
  @options = options
  @pomfile = pomfile
end

Instance Method Details

#effective_pomObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gpm/source/maven.rb', line 28

def effective_pom
  result = tempfile
  extracted_pom = raw_pom
  @logger.info "Invoking maven to generate effective POM in : mvn help:effective-pom -Doutput=#{result} -f #{extracted_pom}"
  mvn_output = `mvn help:effective-pom -Doutput=#{File.join(File.expand_path(Dir.getwd),result)} -f #{extracted_pom}`
  exit_code = $?
  unless exit_code.to_i == 0
    @logger.error "Maven failed with exit status #{exit_code}."
    @logger.error "Maven output was:\n==========\n#{mvn_output}"
    raise "Failed to invoke maven to generate effective pom."
  end
  result
end

#raw_pomObject



24
25
26
# File 'lib/gpm/source/maven.rb', line 24

def raw_pom
  @pomfile
end

#readObject



18
19
20
21
22
# File 'lib/gpm/source/maven.rb', line 18

def read
  in_directory work_dir do
    XmlSimple.xml_in(effective_pom)
  end
end

#tempfileObject



42
43
44
# File 'lib/gpm/source/maven.rb', line 42

def tempfile
  "effective_pom.xml"
end