Author: vborja
Date: Wed Jun 4 16:03:09 2008
New Revision: 663402
URL: http://svn.apache.org/viewvc?rev=663402&view=rev
Log:
BUILDR-76.
Modified:
incubator/buildr/trunk/lib/buildr/core/compile.rb
incubator/buildr/trunk/spec/compile_spec.rb
Modified: incubator/buildr/trunk/lib/buildr/core/compile.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/compile.rb?rev=663402&r1=663401&r2=663402&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/compile.rb Wed Jun 4 16:03:09 2008
@@ -168,17 +168,17 @@
def compile_map(sources, target)
target_ext = self.class.target_ext
ext_glob = Array(self.class.source_ext).join(',')
- sources.flatten.inject({}) do |map, source|
+ sources.flatten.map{|f| File.expand_path(f)}.inject({}) do |map,
source|
if File.directory?(source)
FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file|
File.directory?(file) }.
- each { |file| map[file] = File.join(target,
Util.relative_path(source, file).ext(target_ext)) }
+ each { |file| map[file] = File.join(target,
Util.relative_path(file, source).ext(target_ext)) }
else
map[source] = File.join(target,
File.basename(source).ext(target_ext))
end
map
end
end
-
+
end
end
@@ -223,7 +223,7 @@
raise 'No compiler selected and can\'t determine which compiler to
use' unless compiler
raise 'No target directory specified' unless target
mkpath target.to_s, :verbose=>false
- puts "Compiling #{task.name.gsub(/:[^:]*$/, '')}" if verbose
+ puts "Compiling #{task.name.gsub(/:[^:]*$/, '')} into
#{target.to_s}" if verbose
@compiler.compile(sources.map(&:to_s), target.to_s,
dependencies.map(&:to_s))
# By touching the target we let other tasks know we did something,
# and also prevent recompiling again for dependencies.
Modified: incubator/buildr/trunk/spec/compile_spec.rb
URL:
http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/compile_spec.rb?rev=663402&r1=663401&r2=663402&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/compile_spec.rb (original)
+++ incubator/buildr/trunk/spec/compile_spec.rb Wed Jun 4 16:03:09 2008
@@ -23,19 +23,18 @@
end
def sources
- @sources ||= ['Test1.java', 'Test2.java'].map { |f| File.join('src/java',
f) }.
+ @sources ||= ['Test1.java', 'Test2.java'].map { |f|
File.join('src/main/java', f) }.
each { |src| write src, "class #{src.pathmap('%n')} {}" }
end
def jars
@jars ||= begin
- write 'src/main/java/Dependency.java', 'class Dependency { }'
- define 'jars', :version=>'1.0' do
- compile.into('dependency')
+ write 'jars/src/main/java/Dependency.java', 'class Dependency { }'
+ define 'jars', :version=>'1.0', :base_dir => 'jars' do
package(:jar, :id=>'jar1')
package(:jar, :id=>'jar2')
end
- project('jars').packages.each(&:invoke).map(&:to_s)
+ project('jars').packages.map(&:to_s)
end
end
end
@@ -188,7 +187,7 @@
end
it 'should allow artifacts' do
- artifact('group:id:jar:1.0') { |task| mkpath File.dirname(task.to_s) ; cp
jars.first.to_s, task.to_s }
+ artifact('group:id:jar:1.0') { |task| mkpath File.dirname(task.to_s) ; cp
jars.first.to_s, task.to_s }.enhance jars
compile_task.from(sources).with('group:id:jar:1.0').into('classes').invoke
end
@@ -325,6 +324,7 @@
end
it 'should force compilation if dependencies newer than compiled' do
+ jars; project('jars').task("package").invoke
# On my machine the times end up the same, so need to push dependencies in
the past.
time = Time.now
sources.map { |src| src.pathmap("#{compile_task.target}/%n.class") }.
@@ -334,10 +334,11 @@
end
it 'should not force compilation if dependencies older than compiled' do
+ jars; project('jars').task("package").invoke
time = Time.now
- sources.map { |src| src.pathmap("#{compile_task.target}/%n.class") }.
+ jars.each { |jar| File.utime(time - 1 , time - 1, jar) }
+ sources.map { |src| File.utime(time, time, src);
src.pathmap("#{compile_task.target}/%n.class") }.
each { |kls| write kls ; File.utime(time, time, kls) }
- jars.each { |jar| File.utime(time - 1, time - 1, jar) }
lambda { compile_task.from(sources).with(jars).invoke }.should_not
run_task('foo:compile')
end