Class: Maven::Ruby::PomMagic

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/maven/ruby/pom_magic.rb

Instance Method Summary collapse

Constructor Details

#initialize(default_pom = '.pom.xml') ⇒ PomMagic

Returns a new instance of PomMagic.



29
30
31
# File 'lib/ruby/maven/ruby/pom_magic.rb', line 29

def initialize( default_pom = '.pom.xml' )
  @default_pom = default_pom
end

Instance Method Details

#dump_pom(dir = '.', force = false, file = 'pom.xml') ⇒ Object



33
34
35
36
37
# File 'lib/ruby/maven/ruby/pom_magic.rb', line 33

def dump_pom( dir = '.', force = false, file = 'pom.xml' )
  if force || !File.exists?( file )
    generate_pom( dir, '--pom', file )
  end
end

#generate_pom(dir = '.', *args) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby/maven/ruby/pom_magic.rb', line 39

def generate_pom( dir = '.', *args )
  dir = File.expand_path( dir )
  Dir.chdir(dir) do
    skip_some_files = false
    if index = (args.index("-f") || args.index("--file"))
      filename = args[index + 1]
      if filename =~ /.gemspec$/
        skip_some_files = true
        proj = ::Maven::Tools::GemProject.new
        proj.load_gemspec(filename)
      elsif filename =~ /Gemfile/
        skip_some_files = true
        proj = ::Maven::Tools::GemProject.new
        proj.load_gemfile(filename)
      end
    else
      proj =
        if File.exists? File.join( 'config', 'application.rb' )
          ::Maven::Tools::RailsProject.new
        else
          ::Maven::Tools::GemProject.new
        end
    end
    if proj

      ensure_mavenfile( dir )

      load_standard_files( dir, proj, skip_some_files )

      pom_xml( dir, proj, args )

    end
  end
end