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

- old
+ new

@@ -253,11 +253,11 @@ attr_reader :filter def initialize(*args) #:nodoc: super @filter = Buildr::Filter.new - enhance { filter.run if filter.source && filter.target } + enhance { filter.run unless filter.sources.empty? } end # :call-seq: # include(*files) => self # @@ -275,27 +275,42 @@ filter.exclude *files self end # :call-seq: - # source() => task + # from(*sources) => self # - # Returns the filter's source directory as a file task. + # Adds additional directories from which to copy resources. + # + # For example: + # resources.from _("src/etc") + def from(*sources) + filter.from *sources + self + end + + # *Deprecated* Use #sources instead. def source() + warn_deprecated "Please use sources instead." filter.source end + # Returns the list of source directories (each being a file task). + def sources() + filter.sources + end + # :call-seq: # target() => task # # Returns the filter's target directory as a file task. def target() filter.target end def prerequisites() #:nodoc: - super + [filter.source].compact + super + filter.sources.flatten end end @@ -497,11 +512,11 @@ # By default the resources task copies files from the src/main/resources into the # same target directory as the #compile task. It does so using a filter that you # can access by calling resources.filter (see Buildr::Filter). # # For example: - # resources.filter.include "config.xml" + # resources.from _("src/etc") # resources.filter.using "Copyright"=>"Acme Inc, 2007" def resources(*prereqs, &block) task("resources").enhance prereqs, &block end @@ -526,11 +541,11 @@ Project.on_define do |project| prepare = task("prepare") # Resources task is a filter. resources = Java::ResourcesTask.define_task("resources") - project.path_to("src/main/resources").tap { |dir| resources.filter.from dir if File.exist?(dir) } + project.path_to("src/main/resources").tap { |dir| resources.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 @@ -550,21 +565,24 @@ end class Options - # Runs the compile in debugging mode when true (default). + # Returns the debug option (environment variable DEBUG). + def debug() + (ENV["DEBUG"] || ENV["debug"]) !~ /(no|off|false)/ + end + + # Sets the debug option (environment variable DEBUG). # # You can turn this option off directly, or by setting the environment variable # DEBUG to "no". For example: # buildr build DEBUG=no # # The release tasks runs a build with <tt>DEBUG=no</tt>. - attr_accessor :debug - - def debug() #:nodoc: - @debug = (ENV["DEBUG"] || ENV["debug"]) !~ /(no|off|false)/ if @debug.nil? - @debug + def debug=(flag) + ENV["debug"] = nil + ENV["DEBUG"] = flag.to_s end end end