Class: BuildrGemjar::GemjarTask

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

Defined Under Namespace

Classes: FileSourcedGem, NamedGem

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ GemjarTask

Returns a new instance of GemjarTask.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/buildr-gemjar.rb', line 5

def initialize(*args)
  super
  @target = 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.)
  mkdir_p @target

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

Instance Method Details

#add_source(source) ⇒ Object



39
40
41
42
# File 'lib/buildr-gemjar.rb', line 39

def add_source(source)
  sources << source
  self
end

#clear_sourcesObject



34
35
36
37
# File 'lib/buildr-gemjar.rb', line 34

def clear_sources
  sources.clear
  self
end

#gem_homeObject



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

def gem_home
  @target
end

#gemsObject



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

def gems
  @gems ||= []
end

#sourcesObject



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

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

#with_gem(*args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/buildr-gemjar.rb', line 22

def with_gem(*args)
  new_gem =
    if args.first.respond_to?(:has_key?)
      FileSourcedGem.new(args.first[:file])
    else
      NamedGem.new(args[0], args[1])
    end
  gems << new_gem
  enhance new_gem.dependencies
  self
end