Class: Buildr::Run::RunTask

Inherits:
Rake::Task show all
Defined in:
lib/buildr/run.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Rake::Task

#invoke, #invoke_with_call_chain

Constructor Details

#initialize(*args) ⇒ RunTask

:nodoc:



82
83
84
85
86
87
# File 'lib/buildr/run.rb', line 82

def initialize(*args) # :nodoc:
  super
  @options = {}
  @classpath = []
  @files = FileList[]
end

Instance Attribute Details

#classpathObject

Classpath dependencies.



72
73
74
# File 'lib/buildr/run.rb', line 72

def classpath
  @classpath
end

#filesObject (readonly)

Returns file dependencies



78
79
80
# File 'lib/buildr/run.rb', line 78

def files
  @files
end

#optionsObject (readonly)

Returns the run options.



75
76
77
# File 'lib/buildr/run.rb', line 75

def options
  @options
end

#projectObject (readonly)

:nodoc:



80
81
82
# File 'lib/buildr/run.rb', line 80

def project
  @project
end

Instance Method Details

#prerequisitesObject

:nodoc:



142
143
144
# File 'lib/buildr/run.rb', line 142

def prerequisites #:nodoc:
  super + @files + classpath
end

#requires(*files) ⇒ Object

:call-seq:

requires(*files) => self

Adds additional files and directories as dependencies to the task and returns self. When specifying a directory, includes all files in that directory.



121
122
123
124
# File 'lib/buildr/run.rb', line 121

def requires(*files)
  @files.include *files.flatten.compact
  self
end

#runObject



138
139
140
# File 'lib/buildr/run.rb', line 138

def run
  runner.run(self) if runner?
end

#runnerObject



126
127
128
# File 'lib/buildr/run.rb', line 126

def runner
  @runner ||= guess_runner
end

#runner?Boolean

Returns:

  • (Boolean)


130
131
132
133
134
135
136
# File 'lib/buildr/run.rb', line 130

def runner?
  @runner ||= begin
    guess_runner if project.compile.language
  rescue
    nil
  end
end

#using(*args) ⇒ Object

:call-seq:

using(options) => self

Sets the run options from a hash and returns self.

For example:

run.using :main=>'org.example.Main'


105
106
107
108
109
110
111
112
113
114
# File 'lib/buildr/run.rb', line 105

def using(*args)
  args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last

  until args.empty?
    new_runner = Run.select_by_name(args.pop)
    @runner = new_runner.new(project) unless new_runner.nil?
  end

  self
end

#with(*specs) ⇒ Object

:call-seq:

with(*artifacts) => self

Adds files and artifacts as classpath dependencies, and returns self.



93
94
95
96
# File 'lib/buildr/run.rb', line 93

def with(*specs)
  @classpath |= Buildr.artifacts(specs.flatten).uniq
  self
end