buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Kelley" <>
Subject Buildr::Java::CompileTask NOT needed if only package-info.class files are missing
Date Wed, 09 Apr 2008 11:06:04 GMT
I'm running buildr 1.2.10 against a project that contains files. The Java compiler happily ignores them
although comments in them are later incorporated into javadoc.

The problem is that the CompileTask is always considered necessary
(always rebuilds) because there aren't .class files to match the files. I'm new to buildr/ruby so I'm far from sure
this is the best solution to problem, but here is one:
class Buildr::Java::CompileTask
  def valid_class_file?(c) #:nodoc:
    not File.basename(c).include? '-'  # no package-info.class, for example

  def needed?() #:nodoc:
    return false if source_files.empty?
    return true unless File.exist?(target.to_s)
    compiled_source_files = []
    source_files.each do |j, c|
      compiled_source_files << [j, c] if valid_class_file? c
    return true if compiled_source_files.any? { |j, c| !File.exist?(c)
|| File.stat(j).mtime > File.stat(c).time }
    oldest = { |j, c| File.stat(c).mtime }.min
    return classpath.any? { |path| application[path].timestamp > oldest }


Does this or something it like seem like an appropriate change to make
down at the task level (rather than mucking with source file filtering
in all buildfiles)?  If so (Assaf and company), would this be more
welcome as a patch? :)


View raw message