class Maven::Tools::DSL::Gemspec
Attributes
parent[R]
Public Class Methods
new( parent, name = nil, options = {} )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 30 def initialize( parent, name = nil, options = {} ) @parent = parent case name when Hash options = name name = options[ 'name' ] || options[ :name ] when Gem::Specification process_gem_spec( name, options ) return end name = find_gemspec_file( name ) spec = gem_specification( name ) name ||= "#{spec.name}-#{spec.version}.gemspec" process( spec, name, options ) JarsLock.new( parent ) if parent.respond_to? :profile end
Public Instance Methods
gem( scope, coord )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 53 def gem( scope, coord ) DependencyDSL.create( @parent.current, :gem, scope, coord ) end
help()
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 49 def help warn "\n# gemspec(filename) - default find gemspec in current directory #\n" end
jar( line )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 57 def jar( line ) maven_dependency( "jar #{line}" ) end
method_missing( m, *args )
click to toggle source
Calls superclass method
# File lib/maven/tools/dsl/gemspec.rb, line 65 def method_missing( m, *args ) if args.size == 1 warn "unknown declaration: #{m} " + args[0] else super end end
pom( line )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 61 def pom( line ) maven_dependency( "pom #{line}" ) end
Private Instance Methods
find_gemspec_file( name )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 86 def find_gemspec_file( name ) if name ::File.join( @parent.basedir, name ) else gemspecs = Dir[ ::File.join( @parent.basedir, "*.gemspec" ) ] raise "more then one gemspec file found" if gemspecs.size > 1 raise "no gemspec file found" if gemspecs.size == 0 gemspecs.first end end
gem_deps( spec, options )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 129 def gem_deps( spec, options ) spec.dependencies.each do |dep| versions = dep.requirement.requirements.collect do |req| # use this construct to get the same result in 1.8.x and 1.9.x req.collect{ |i| i.to_s }.join end scope = dep.type == :development ? :test : nil gem( scope, "rubygems:#{dep.name}:#{to_version( *versions )}" ) end end
gem_specification( name )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 97 def gem_specification( name ) path = File.expand_path( name ) spec_file = File.read( path ) if spec_file.start_with?( '--- !ruby/object:Gem::Specification' ) Gem::Specification.from_yaml( spec_file ) else FileUtils.cd( @parent.basedir ) do return eval( spec_file, nil, path ) end end end
maven_dependency( line )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 157 def maven_dependency( line ) coord = to_split_coordinate_with_scope( line ) if coord && coord.size > 1 DependencyDSL.create( @parent.current, nil, nil, *coord ) end end
other_deps( spec )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 140 def other_deps( spec ) spec.requirements.each do |req| req = req.sub( /#.*^/, '' ) method = req.sub(/\s.*$/, '' ).to_sym line = req.sub(/^[^\s]*\s/, '' ) if respond_to? method if spec.platform.to_s == 'java' send method, line else warn "jar dependency found on non-java platform gem - ignoring: #{req}" end else warn "unknown declaration: #{req}" end end end
process( spec, name, options )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 109 def process( spec, name, options ) if name config = { :gemspec => name.sub( /^#{@parent.basedir}\/?/, '' ) } end if options[ :include_jars ] || options[ 'include_jars' ] config[ :includeDependencies ] = true config[ :useRepositoryLayout ] = true @parent.plugin :dependency do @parent.execute_goal( 'copy-dependencies', :phase => 'generate-test-resources', :outputDirectory => spec.require_path, :useRepositoryLayout => true ) end end @parent.jruby_plugin!( :gem, config ) gem_deps( spec, options ) unless options[ :no_gems ] other_deps( spec ) end
process_gem_spec( spec, options )
click to toggle source
# File lib/maven/tools/dsl/gemspec.rb, line 77 def process_gem_spec( spec, options ) if spec.spec_file name = File.basename( spec.spec_file ) else name = nil end process( spec, name, options ) end