Class: BuildrGemjar::GemjarTask

Inherits:
Buildr::Packaging::Java::JarTask
  • Object
show all
Defined in:
lib/buildr-gemjar.rb

Defined Under Namespace

Modules: GemProperties Classes: FileSourcedGem, NamedGem

Constant Summary collapse

DEFAULT_UNPACK_GLOBS =
['lib/**/*.jar']

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ GemjarTask

Returns a new instance of GemjarTask.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/buildr-gemjar.rb', line 8

def initialize(*args)
  super
  @target = Pathname.new File.expand_path("../gem_home", self.to_s)
  # It doesn't seem like this should be necessary or useful --
  # the directory is also created by a task dependency.
  # However, if it isn't here, the file gem dependency is not
  # correctly taken into account.  (Try commenting it out and
  # running the specs.)
  @target.mkpath

  clean
  include(@target.to_s, :as => '.')
  enhance do
    install_gems
    unpack_jars
  end
end

Instance Method Details

#add_source(source) ⇒ Object



48
49
50
51
# File 'lib/buildr-gemjar.rb', line 48

def add_source(source)
  sources << source
  self
end

#clear_sourcesObject



43
44
45
46
# File 'lib/buildr-gemjar.rb', line 43

def clear_sources
  sources.clear
  self
end

#gem_homeObject



61
62
63
# File 'lib/buildr-gemjar.rb', line 61

def gem_home
  @target
end

#gemsObject



53
54
55
# File 'lib/buildr-gemjar.rb', line 53

def gems
  @gems ||= []
end

#sourcesObject



57
58
59
# File 'lib/buildr-gemjar.rb', line 57

def sources
  @sources ||= ['http://rubygems.org']
end

#with_gem(*args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/buildr-gemjar.rb', line 26

def with_gem(*args)
  options = args.last.respond_to?(:has_key?) ? args.pop : {}

  new_gem =
    if options.has_key?(:file)
      FileSourcedGem.new(options[:file])
    else
      NamedGem.new(args[0], args[1])
    end

  new_gem.unpack_globs = determine_unpack_globs(options[:unpack_jars])

  gems << new_gem
  enhance new_gem.dependencies
  self
end