Module: Maven::Tools::DSL::GemSupport

Included in:
ProfileGemspec, ProjectGemspec
Defined in:
lib/maven/tools/dsl/gem_support.rb

Instance Method Summary collapse

Instance Method Details

#setup_gem_support(project, options, spec = nil) ⇒ Object



33
34
35
36
37
38
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/maven/tools/dsl/gem_support.rb', line 33

def setup_gem_support( project, options, spec = nil )
  unless project.properties.member?( 'project.build.sourceEncoding' )
    @parent.properties( 'project.build.sourceEncoding' => 'utf-8' )
  end
  if spec.nil?
    require_path = '.'
    name = ::File.basename( ::File.expand_path( '.' ) )
  else
    require_path = spec.require_path
    name = spec.name
  end

  if ( nil == project.current.repositories.detect { |r| r.id == 'rubygems-releases' } && options[ :no_rubygems_repo ] != true )
      
    @parent.repository( 'rubygems-releases',
                        'http://rubygems-proxy.torquebox.org/releases' )
  end
  @parent.needs_torquebox = true
    
  setup_jruby_plugins_version( project )
  
  if options.key?( :jar ) || options.key?( 'jar' )
    jarpath = options[ :jar ] || options[ 'jar' ]
    if jarpath
      jar = ::File.basename( jarpath ).sub( /.jar$/, '' )
      output = ::File.dirname( "#{require_path}/#{jarpath}" )
      output.sub!( /\/$/, '' )
    end
  else
    jar = "#{name}"
    output = "#{require_path}"
  end
  if options.key?( :source ) || options.key?( 'source' )
    source = options[ :source ] || options[ 'source' ]
    @parent.build do
      @parent.source_directory source
    end
  end
  # TODO rename "no_rubygems_repo" to "no_jar_support"
  if(  options[ :no_rubygems_repo ] != true && 
       jar &&
       ( source || File.exists?( File.join( project.basedir, 
                                            'src/main/java' ) ) ) )
    
    unless spec.nil? || spec.platform.to_s.match( /java|jruby/ )
      warn "gem is not a java platform gem but has a jar and source"
    end
    
    @parent.plugin( :jar, VERSIONS[ :jar_plugin ],
                    :outputDirectory => output,
                    :finalName => jar ) do
      @parent.execute_goals :jar, :phase => 'prepare-package'
    end
    @parent.plugin( :clean, VERSIONS[ :clean_plugin ],
                    :filesets => [ { :directory => output,
                                     :includes => [ "#{jar}.jar", '*/**/*.jar' ] } ] )
    true
  else
    false
  end
end

#setup_jruby_plugins_version(project) ⇒ Object



26
27
28
29
30
31
# File 'lib/maven/tools/dsl/gem_support.rb', line 26

def setup_jruby_plugins_version( project )
  if not @parent.properties.key?( 'jruby.plugins.version' ) and
      not project.properties.key?( 'jruby.plugins.version' )
    @parent.properties( 'jruby.plugins.version' => VERSIONS[ :jruby_plugins ] )
  end
end