class Maven::Tools::DSL::Jarfile

Public Class Methods

new( parent, file = 'Jarfile', skip_lock = false ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 79
def initialize( parent, file = 'Jarfile', skip_lock = false )
  warn "DEPRECATED to have nil as parent" unless parent
  lockfile = JarfileLock.new( skip_lock ? nil : file )

  # the dependencies are only add if they are not locked
  @parent = ParentWithLock.new( parent, lockfile )

  # parse jarfile DSL
  eval( File.read( file ) )

  # fill dependencies from lockfile
  lockfile.coordinates.each do |d|
    a = Maven::Tools::Artifact.from_coordinate( d )
    add( a ) unless a[:systemPath]
  end
  scope( :test ) do
    lockfile.coordinates( :test ).each do |d|
      a = Maven::Tools::Artifact.from_coordinate( d )
      add( a ) unless a[:systemPath]
    end
  end
end

Public Instance Methods

add( artifact ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 102
def add( artifact )
  dep = Dependency.new

  # use the fill_options to fill up the dependency
  self.class.fill_options( dep, artifact, :type )

  # adjust the scope
  dep.scope = @scope if @scope

  # use the original parent if present
  (@parent.parent || @parent ).dependencies << dep
end
artifacts() click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 64
def artifacts
  # TODO remove this part
  @artifacts ||= []
end
help() click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 115
def help
  warn "\n# Jarfile DSL #\n"
  warn self.class.help_block( :local => "path-to-local-jar", :jar => nil, :pom => nil, :repository => nil, :snapshot_repository => nil, :scope => nil)[0..-2]
end
jar( *args, &block ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 130
def jar( *args, &block )
  a = DependencyDSL.create( @parent, :jar, @scope, *args, &block )
  # TODO remove this part
  artifacts << a
  a
end
jruby( *args, &block ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 166
def jruby( *args, &block )
  warn "DEPRECATED jruby declaration has no effect anymore"
  # if args.empty? && !block
  #   @jruby ? @jruby.legacy_version : nil
  # else
  #   @jruby = JRubyDSL.create( @parent, :provided, *args, &block )
  # end
end
local( path ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 120
def local( path )
  jar_path = ::File.expand_path( path )
  jar_path.sub!( /#{@parent.basedir}/, '${basedir}' )
  a = Artifact.new_local( jar_path, :jar )
  add( a )
  # TODO remove this part
  artifacts << a
  a
end
pom( *args, &block ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 137
def pom( *args, &block )
  a = DependencyDSL.create( @parent, :pom, @scope, *args, &block )
  # TODO remove this part
  artifacts << a
  a
end
repositories() click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 69
def repositories
  # TODO remove this part
  @repositories ||= []
end
repository( name, url = nil ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 151
def repository( name, url = nil )
  if url.nil?
    url = name
  end
  repositories << { :name => name.to_s, :url => url }
end
Also aliased as: source
scope( scope ) { || ... } click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 159
def scope( scope )
  @scope = scope
  yield if block_given?
ensure
  @scope = nil
end
snapshot_repositories() click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 74
def snapshot_repositories
  # TODO remove this part
  @snapshot_repositories ||= []
end
snapshot_repository( name, url = nil ) click to toggle source
# File lib/maven/tools/dsl/jarfile.rb, line 144
def snapshot_repository( name, url = nil )
  if url.nil?
    url = name
  end
  snapshot_repositories << { :name => name.to_s, :url => url }
end
source( name, url = nil )
Alias for: repository