Class: Source::PomFromWarFileReader

Inherits:
PomFileReader show all
Defined in:
lib/gpm/source/war.rb

Constant Summary collapse

POM_FILE_NAME =
%r{^META-INF/maven/.*/pom\.xml$}

Instance Attribute Summary

Attributes included from HasOptionMethods

#options

Instance Method Summary collapse

Methods inherited from PomFileReader

#effective_pom, #read, #tempfile

Methods included from HasOptionMethods

included

Methods included from HasDirectories

#in_directory

Constructor Details

#initialize(warfile, options) ⇒ PomFromWarFileReader

Returns a new instance of PomFromWarFileReader.



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

def initialize(warfile,options)
  super(nil,options)
  @warfile=warfile
end

Instance Method Details

#raw_pomObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gpm/source/war.rb', line 15

def raw_pom
  @logger.info "Extracting raw pom from #{warfile}..."
  Archive::Zip.open(warfile) do |f|
    #inspect war file to find pom.xml
    pom_file_entries = f.select { |entry| entry.ftype == :file && entry.zip_path =~ POM_FILE_NAME }
    raise "Wrong number of POM files (#{pom_file_entries.size}):\n #{pom_file_entries.join("\n")}" unless pom_file_entries.size == 1
    #Write it to temporary file to maven can use it
    extract_target = Tempfile.new("from_pom", work_dir).path
    pom_file_entries.first.extract(:file_path => extract_target)
    #Return the name of the temporary file
    extract_target
  end
end