lib/java/compile.rb in buildr-1.1.3 vs lib/java/compile.rb in buildr-1.2.0

- old
+ new

@@ -79,11 +79,11 @@ # Resets all the options. def clear() OPTIONS.each { |name| send "#{name}=", nil } end - def to_s() + def to_s() #:nodoc: OPTIONS.inject({}){ |hash, name| hash[name] = send(name) ; hash }.reject{ |name,value| value.nil? }.inspect end # Returns Javac command line arguments from the set of options. def javac_args() @@ -189,12 +189,13 @@ # # Sets the compiler options from a hash and returns self. # # For example: # compile.using(:warnings=>true, :source=>"1.5") - def using(hash) - hash.each { |k, v| options.send "#{k}=", v } + def using(*args) + args.pop.each { |key, value| options.send "#{key}=", value } if Hash === args.last + args.each { |key| options.send "#{key}=", value = true } self end def timestamp() #:nodoc: # If we compiled successfully, then the target directory reflects that. @@ -252,11 +253,11 @@ attr_reader :filter def initialize(*args) #:nodoc: super @filter = Buildr::Filter.new - enhance { filter.run } + enhance { filter.run if filter.source && filter.target } end # :call-seq: # include(*files) => self # @@ -383,12 +384,13 @@ # # Sets the Javadoc options from a hash and returns self. # # For example: # javadoc.using :windowtitle=>"My application" - def using(options) - options.each { |key, value| @options[key] = value } + def using(*args) + args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last + args.each { |key| @options[key.to_sym] = true } self end # :call-seq: # from(*sources) => self @@ -446,23 +448,13 @@ desc "Create the Javadocs for this project" Project.local_task("javadoc") class Project - # :call-seq: - # prepare(*prereqs) => task - # prepare(*prereqs) { |task| .. } => task - # - # The prepare task executes before the #compile task. Use it for pre-compilation - # tasks, e.g. generating source code. - # - # This method returns the project's prepare task. It also accepts a list of - # prerequisites and a block, used to enhance the prepare task. - # - # For example: - # prepare { schema_to_java } + # *Deprecated* Add a prerequisite to the compile task instead. def prepare(*prereqs, &block) + warn_deprecated "Add a prerequisite to the compile task instead of using the prepare task." task("prepare").enhance prereqs, &block end # :call-seq: # compile(*sources) => CompileTask @@ -534,11 +526,11 @@ Project.on_define do |project| prepare = task("prepare") # Resources task is a filter. resources = Java::ResourcesTask.define_task("resources") - resources.filter.from project.path_to("src/main/resources") + project.path_to("src/main/resources").tap { |dir| resources.filter.from dir if File.exist?(dir) } # Compile task requires prepare and performs resources, if anything compiled. compile = Java::CompileTask.define_task("compile"=>[prepare, resources]) project.path_to("src/main/java").tap { |dir| compile.from dir if File.exist?(dir) } compile.into project.path_to(:target, "classes") resources.filter.into project.compile.target @@ -562,15 +554,15 @@ # Runs the compile in debugging mode when true (default). # # You can turn this option off directly, or by setting the environment variable # DEBUG to "no". For example: - # rake build DEBUG=no + # buildr build DEBUG=no # # The release tasks runs a build with <tt>DEBUG=no</tt>. attr_accessor :debug - def debug() + def debug() #:nodoc: @debug = (ENV["DEBUG"] || ENV["debug"]) !~ /(no|off|false)/ if @debug.nil? @debug end end