lib/java/java.rb in buildr-0.15.0 vs lib/java/java.rb in buildr-0.16.0

- old
+ new

@@ -9,41 +9,39 @@ fu_check_options options, *JAVA_OPTIONS name = options[:name] || "java #{args.first}" cmd_args = [] classpath = classpath_from(options) - cmd_args << "-cp" << classpath unless classpath.empty? + cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty? cmd_args += options[:java_args].flatten if options[:java_args] cmd_args += args.flatten.compact cmd_args << { :verbose=>options[:verbose] } unless options[:noop] - verbose { puts "Running #{name}" } + puts "Running #{name}" if verbose sh(path_to_bin("java"), *cmd_args) { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } end end def self.apt(*args) options = Hash === args.last ? args.pop : {} options[:verbose] ||= Rake.application.options.trace || false - fu_check_options options, :verbose, :noop, :compile, :source, :output, :cp, :classpath, :sourcepath + fu_check_options options, :verbose, :noop, :compile, :source, :output, :cp, :classpath files = args.collect { |arg| File.directory?(arg) ? FileList[File.join(arg, "**", "*.java")] : arg }.flatten args = [ options[:verbose] ? "-verbose" : "-nowarn" ] if options[:compile] args << "-d" << options[:output] else args << "-nocompile" << "-s" << options[:output] end args << "-source" << options[:source] if options[:source] classpath = classpath_from(options) - args << "-cp" << classpath unless classpath.empty? - sourcepath = (options[:sourcepath] || []).collect.join(File::PATH_SEPARATOR) - args << "-sourcepath" << sourcepath unless sourcepath.empty? + args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty? args += files args << { :verbose=>options[:verbose] } unless options[:noop] - verbose { puts "Running apt" } + puts "Running apt" if verbose sh(path_to_bin("apt"), *args) { |ok, res| fail "Failed to execute apt, see errors above" unless ok } end end class AptTask < Rake::FileTask @@ -82,18 +80,18 @@ name = options[:name] || Dir.pwd cmd_args = [] classpath = classpath_from(options) #classpath += options[:output] if options[:output] - cmd_args << "-cp" << classpath unless classpath.empty? + cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty? cmd_args << "-sourcepath" << options[:sourcepath].join(File::PATH_SEPARATOR) if options[:sourcepath] cmd_args << "-d" << options[:output] if options[:output] cmd_args += options[:javac_args].flatten if options[:javac_args] cmd_args += files cmd_args << { :verbose=>options[:verbose] } unless options[:noop] || files.empty? - verbose { puts "Compiling #{files.size} source files in #{name}" } + puts "Compiling #{files.size} source files in #{name}" if verbose sh(path_to_bin("javac"), *cmd_args) { |ok, res| fail "Failed to compile, see errors above" unless ok } end end protected @@ -102,11 +100,10 @@ ENV["JAVA_HOME"] ? File.join(ENV["JAVA_HOME"], "bin", name) : name end def self.classpath_from(options) classpath = (options[:classpath] || []).collect | (options[:cp] || []).collect - artifacts(classpath).each { |t| t.invoke if t.respond_to?(:invoke) }. - map(&:to_s).join(File::PATH_SEPARATOR) + artifacts(classpath).each { |t| t.invoke if t.respond_to?(:invoke) }.map(&:to_s) end end def java(*args)