Class: Buildr::Shell::ShellTask

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Rake::Task

#invoke, #invoke_with_call_chain

Constructor Details

#initialize(*args) ⇒ ShellTask

:nodoc:



109
110
111
112
113
# File 'lib/buildr/shell.rb', line 109

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

Instance Attribute Details

#classpathObject

Classpath dependencies.



101
102
103
# File 'lib/buildr/shell.rb', line 101

def classpath
  @classpath
end

#optionsObject (readonly)

Returns the run options.



104
105
106
# File 'lib/buildr/shell.rb', line 104

def options
  @options
end

#projectObject (readonly)

:nodoc:



98
99
100
# File 'lib/buildr/shell.rb', line 98

def project
  @project
end

#providerObject (readonly)

Underlying shell provider



107
108
109
# File 'lib/buildr/shell.rb', line 107

def provider
  @provider
end

Instance Method Details

#java_argsObject



154
155
156
# File 'lib/buildr/shell.rb', line 154

def java_args
  @options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split
end

#prerequisitesObject

:nodoc:



150
151
152
# File 'lib/buildr/shell.rb', line 150

def prerequisites #:nodoc:
  super + classpath
end

#propertiesObject



158
159
160
# File 'lib/buildr/shell.rb', line 158

def properties
  @options[:properties] || {}
end

#runObject



145
146
147
148
# File 'lib/buildr/shell.rb', line 145

def run
  fail "No shell provider defined in project '#{project.name}' for language '#{project.compile.language.inspect}'" unless provider
  provider.launch(self)
end

#using(*args) ⇒ Object

:call-seq:

using(options) => self

Sets the run options from a hash and returns self.

For example:

shell.using :properties => {'foo' => 'bar'}
shell.using :bsh


132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/buildr/shell.rb', line 132

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

  until args.empty?
    new_shell = Shell.select_by_name(args.pop)
    @provider = new_shell.new(project) unless new_shell.nil?
  end

  self
end

#with(*specs) ⇒ Object

:call-seq:

with(*artifacts) => self

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



119
120
121
122
# File 'lib/buildr/shell.rb', line 119

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