lib/buildmaster/ant_driver.rb in BuildMaster-0.8.1 vs lib/buildmaster/ant_driver.rb in BuildMaster-0.9.0

- old
+ new

@@ -1,16 +1,18 @@ module BuildMaster class AntDriver - include Shell def AntDriver.from_file(ant_file) return AntDriver.new(ant_file) end - def initialize(ant_file = nil, &command_runner) + def initialize(ant_file = nil) + @cotta = Cotta.new(ant_file.system) @ant_file = ant_file - @ant_home = check_directory(get_environment('ANT_HOME')) + 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? #ISSUE: what java wants to split up classpath varies from platform to platform #and ruby, following perl, is not too hot at hinting which box it is on. #here I assume ":" except on win32, dos, and netware. Add extra tests here as needed. #This is the only way I know how to check if on windows if File.directory?('C:') @@ -19,23 +21,22 @@ else @class_path_delimiter = ':' @path_seperator='/' end @java_command = get_java_command() - @ant_options = get_environment_or_default('ANT_OPTS').split(' ') - @ant_arguments = get_environment_or_default('ANT_ARGS').split(' ') + @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'] - @command_runner = command_runner end def get_java_command - java_home = get_environment_or_default('JAVA_HOME') + java_home = @cotta.environment('JAVA_HOME') if java_home command = [java_home, 'bin', 'java'].join(@path_seperator) else - command = get_environment_or_default('JAVA_CMD', 'java') + command = @cotta.environment('JAVA_CMD', 'java') end return command end def project_help @@ -45,22 +46,22 @@ def target(name) launch(name) end def launch(arguments) - local_path = "#{@ant_home}/lib/ant-launcher.jar" + 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}") + 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) if @ant_file + all_arguments.push('-f', @ant_file.path) if @ant_file all_arguments.push(arguments) command_line = "#{@java_command} #{all_arguments.join(' ')}" - run_command(command_line) + @cotta.shell(command_line) end def method_missing(method, *args) target(method) end \ No newline at end of file