lib/java/compile.rb in buildr-0.20.0 vs lib/java/compile.rb in buildr-0.21.0
- old
+ new
@@ -1,10 +1,10 @@
require "core/project"
require "core/build"
+require "core/common"
require "java/artifact"
require "java/java"
-require "tasks/filter"
module Buildr
module Java
# Wraps Javac in a task that does all the heavy lifting.
@@ -251,11 +251,11 @@
# Returns the filter used to copy resources over. See Buildr::Filter.
attr_reader :filter
def initialize(*args) #:nodoc:
super
- @filter = Buildr::filter
+ @filter = Buildr::Filter.new
enhance { filter.run }
end
# :call-seq:
# include(*files) => self
@@ -273,12 +273,28 @@
def exclude(*files)
filter.exclude *files
self
end
+ # :call-seq:
+ # source() => task
+ #
+ # Returns the filter's source directory as a file task.
+ def source()
+ filter.source
+ 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.sources
+ super + [filter.source].compact
end
end
@@ -518,10 +534,10 @@
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.include project.path_to(dir, "*") if File.exist?(dir) }
+ resources.filter.from project.path_to("src/main/resources")
# Compile task requires prepare and performs resources, if anything compiled.
compile = Java::CompileTask.define_task("compile"=>[prepare, resources]) { |task| project.resources.invoke }
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