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:



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

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

Instance Attribute Details

#classpathObject

Classpath dependencies.



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

def classpath
  @classpath
end

#optionsObject (readonly)

Returns the run options.



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

def options
  @options
end

#projectObject (readonly)

:nodoc:



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

def project
  @project
end

#providerObject (readonly)

Underlying shell provider



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

def provider
  @provider
end

Instance Method Details

#java_argsObject



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

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

#prerequisitesObject

:nodoc:



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

def prerequisites #:nodoc:
  super + classpath
end

#propertiesObject



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

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

#runObject



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

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


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

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.



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

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