Class: Jars::MavenExec

Inherits:
Object
  • Object
show all
Defined in:
lib/jars/maven_exec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec = nil) ⇒ MavenExec

Returns a new instance of MavenExec.



21
22
23
# File 'lib/jars/maven_exec.rb', line 21

def initialize( spec = nil )
  setup( spec )
end

Instance Attribute Details

#basedirObject (readonly)

Returns the value of attribute basedir.



19
20
21
# File 'lib/jars/maven_exec.rb', line 19

def basedir
  @basedir
end

#specObject (readonly)

Returns the value of attribute spec.



19
20
21
# File 'lib/jars/maven_exec.rb', line 19

def spec
  @spec
end

#specfileObject (readonly)

Returns the value of attribute specfile.



19
20
21
# File 'lib/jars/maven_exec.rb', line 19

def specfile
  @specfile
end

Instance Method Details

#resolve_dependencies(file) ⇒ Object



66
67
68
# File 'lib/jars/maven_exec.rb', line 66

def resolve_dependencies( file )
  do_resolve_dependencies( *setup_arguments( 'jars_lock_pom.rb', 'dependency:copy-dependencies', '-DexcludeTransitive=true' , "-Djars.lock=#{file}") )
end

#resolve_dependencies_list(file) ⇒ Object



62
63
64
# File 'lib/jars/maven_exec.rb', line 62

def resolve_dependencies_list( file )
  do_resolve_dependencies( *setup_arguments( 'jar_pom.rb', 'dependency:copy-dependencies', 'dependency:list', "-DoutputFile=#{file}" ) )
end

#ruby_maven_install_options=(options) ⇒ Object



57
58
59
60
# File 'lib/jars/maven_exec.rb', line 57

def ruby_maven_install_options=( options )
  @options = options.dup
  @options.delete( :ignore_dependencies )
end

#setup(spec = nil, allow_no_file = false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/jars/maven_exec.rb', line 25

def setup( spec = nil, allow_no_file = false )
  spec ||= find_spec( allow_no_file )

  case spec
  when String
    @specfile = File.expand_path( spec )
    @basedir = File.dirname( @specfile )
    spec =  Dir.chdir( File.dirname(@specfile) ) do
      eval( File.read( @specfile ) )
    end
  when Gem::Specification
    if File.exists?( spec.spec_file )
      @basedir = spec.gem_dir
      @specfile = spec.spec_file
    else
      # this happens with bundle and local gems
      # there the spec_file is "not installed" but inside
      # the gem_dir directory
      Dir.chdir( spec.gem_dir ) do
        setup( nil, true )
      end
    end
  when NilClass
  else
    raise 'spec must be either String or Gem::Specification'
  end

  @spec = spec
rescue
  # for all those strange gemspec we skip looking for jar-dependencies
end