Class: BuildMaster::AntDriver
- Inherits:
-
Object
- Object
- BuildMaster::AntDriver
show all
- Defined in:
- lib/buildmaster/project/ant_driver.rb
Overview
ANT launcher class to run targets on an ANT build file.
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ant_file = nil) ⇒ AntDriver
Create the instance given a CottaFile
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/buildmaster/project/ant_driver.rb', line 12
def initialize(ant_file = nil)
@cotta = Cotta.new(ant_file.system)
@ant_file = ant_file
ant_path = @cotta.environment!('ANT_HOME')
@ant_home = @cotta.dir(ant_path)
raise 'ANT_HOME need to point to ANT home directory' unless @ant_home.exists?
if RUBY_PLATFORM =~ /[^r]win/ @class_path_delimiter = ';'
@path_seperator='\\'
else
@class_path_delimiter = ':'
@path_seperator='/'
end
@java_command = get_java_command()
@ant_options = @cotta.environment('ANT_OPTS').split(' ')
@ant_arguments = @cotta.environment('ANT_ARGS').split(' ')
@ant_options.putsh(ENV['JIKESPATH']) if ENV['JIKESPATH']
@classpath=ENV['CLASSPATH']
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
70
71
72
|
# File 'lib/buildmaster/project/ant_driver.rb', line 70
def method_missing(method, *args)
target(method)
end
|
Class Method Details
.from_file(ant_file) ⇒ Object
Create the instance given a CottaFile instance
7
8
9
|
# File 'lib/buildmaster/project/ant_driver.rb', line 7
def AntDriver.from_file(ant_file)
return AntDriver.new(ant_file)
end
|
Instance Method Details
#launch(arguments, &block) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/buildmaster/project/ant_driver.rb', line 50
def launch(arguments, &block)
local_path = "#{@ant_home.path}/lib/ant-launcher.jar"
if (@classpath and @classpath.length() > 0)
local_path = "#{local_path}#{@class_path_delimiter}#{@classpath}"
end
all_arguments = Array.new()
all_arguments.push(@ant_options)
all_arguments.push('-classpath', "\"#{local_path}\"")
all_arguments.push("-Dant.home=#{@ant_home.path}")
all_arguments.push('org.apache.tools.ant.launch.Launcher', @ant_arguments);
all_arguments.push('-f', @ant_file.path) if @ant_file
all_arguments.push(arguments)
command_line = "#{@java_command} #{all_arguments.join(' ')}"
@cotta.shell(command_line, &block)
end
|
#project_help ⇒ Object
42
43
44
|
# File 'lib/buildmaster/project/ant_driver.rb', line 42
def project_help
launch('-projecthelp')
end
|
#respond_to?(*args) ⇒ Boolean
66
67
68
|
# File 'lib/buildmaster/project/ant_driver.rb', line 66
def respond_to?(*args)
super(args)
end
|
#target(name) ⇒ Object
46
47
48
|
# File 'lib/buildmaster/project/ant_driver.rb', line 46
def target(name)
launch(name)
end
|