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:



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

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

Instance Attribute Details

#classpathObject

Classpath dependencies.



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

def classpath
  @classpath
end

#filesObject (readonly)

Returns file dependencies



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

def files
  @files
end

#optionsObject (readonly)

Returns the run options.



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

def options
  @options
end

#projectObject (readonly)

:nodoc:



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

def project
  @project
end

Instance Method Details

#prerequisitesObject

:nodoc:



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

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.



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

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

#runObject



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

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

#runnerObject



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

def runner
  @runner ||= guess_runner
end

#runner?Boolean

Returns:

  • (Boolean)


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

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'


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

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.



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

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