Class: Raven::DependencyTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/raven/deps_tasks.rb

Overview

Task used to declare a set of dependencies your project relies upon. As many dependency tasks as necessary can be declared (each grouping as many dependency as you like). For each declared dependency, a Gem is searched in your local repository and then if it can’t be found, in the specified remote repositories (by setting sources). Gems are searched by name ENDING with the name you provided.

As an example, specifying ‘wsdl4j’ will correctly find the Gem named wsdl4j-wsdl4j but specifying ‘axis2’ WILL NOT give you all axis2 Gems. Actually only one Gem can be selected by each of the specified Gem, otherwise you’ll see an error asking you to be more specific.

Once the correct Gem has been found, if it’s not local it will be automatically be downloaded and installed.

If no version is provided, and the Gem isn’t present locally, the latest version will be fetched. If a local version can be found locally, this version will be used without any download.

Example of dependency specification:

dependency ‘deps’ do |t|

t.deps << [{'commons-logging' => '1.1'}, 'commons-pool']
t.deps << ['commons-lang', 'wsdl4j', 'log4j']

end

See also Raven::MavenLocalRepoImport and Raven::GemRepoBuilder to learn more about how to build a Gem repository to get started.

Alternatively dependencies can be directly declared manually on jar files in your file system. This allows you to manage your dependencies yourself without using Gem or any other repository.

dependency ‘deps’ do |t|

t.libs = Dir.glob('lib/**/*.jar')

end

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gem_depsObject (readonly)

Returns the value of attribute gem_deps.



66
67
68
# File 'lib/raven/deps_tasks.rb', line 66

def gem_deps
  @gem_deps
end

Instance Method Details

#depsObject



96
97
98
# File 'lib/raven/deps_tasks.rb', line 96

def deps
  @deps ||= []
end

#executeObject

Check dependencies and installs them sometimes.



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
94
# File 'lib/raven/deps_tasks.rb', line 69

def execute
  super
  ambiguous, notfound = [], []
  # Installing missing Gems (if there are)
  if @deps
    @gem_deps = @deps.flatten.collect do |dep|
      # Wrapping in an array, we might not have an array with version
      # as dependency.
      deparr = dep.respond_to?(:to_a) ? dep.to_a.flatten : [dep]
      begin
        Raven::GemInstaller.install_or_not(*deparr)
      rescue GemNotFoundException => gnfe
        notfound << gnfe.message
      rescue AmbiguousGemException => age
        ambiguous << age
      end
    end
    unless notfound.empty? && ambiguous.empty?
      raise(RuntimeError, notfound.join($/) + $/ + ambiguous.join($/))
    end
  end
  # Getting dependencies from eventual prerequisites
  Raven.prereq_filter(prerequisites, :gem_deps) do |dep_task|
    @gem_deps += dep_task.gem_deps if dep_task.gem_deps
  end
end

#libsObject



100
101
102
# File 'lib/raven/deps_tasks.rb', line 100

def libs 
  @libs ||= [] 
end

#libs=(l) ⇒ Object



103
104
105
# File 'lib/raven/deps_tasks.rb', line 103

def libs=(l)
  @libs = l
end