public
Rubygem
Description: Apache Buildr
Homepage: http://incubator.apache.org/buildr
Clone URL: git://github.com/vic/buildr.git
BUILDR-76.


git-svn-id: https://svn.apache.org/repos/asf/incubator/buildr/trunk@663402 
13f79535-47bb-0310-9956-ffa450edef68
vic (author)
Wed Jun 04 16:03:09 -0700 2008
commit  75df4bc95cb94dc5df08f352249afdffd47e45fb
tree    fecd19230e4235889b878c8cccfe2e524bb34248
parent  7cf277ca0a7e087181f071b3ab621f9119532b83
...
168
169
170
171
 
172
173
174
 
175
176
177
178
179
180
181
 
182
183
184
...
223
224
225
226
 
227
228
229
...
168
169
170
 
171
172
173
 
174
175
176
177
178
179
180
 
181
182
183
184
...
223
224
225
 
226
227
228
229
0
@@ -168,17 +168,17 @@ module Buildr
0
       def compile_map(sources, target)
0
         target_ext = self.class.target_ext
0
         ext_glob = Array(self.class.source_ext).join(',')
0
- sources.flatten.inject({}) do |map, source|
0
+ sources.flatten.map{|f| File.expand_path(f)}.inject({}) do |map, source|
0
           if File.directory?(source)
0
             FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file| File.directory?(file) }.
0
- each { |file| map[file] = File.join(target, Util.relative_path(source, file).ext(target_ext)) }
0
+ each { |file| map[file] = File.join(target, Util.relative_path(file, source).ext(target_ext)) }
0
           else
0
             map[source] = File.join(target, File.basename(source).ext(target_ext))
0
           end
0
           map
0
         end
0
       end
0
-
0
+
0
     end
0
 
0
   end
0
@@ -223,7 +223,7 @@ module Buildr
0
           raise 'No compiler selected and can\'t determine which compiler to use' unless compiler
0
           raise 'No target directory specified' unless target
0
           mkpath target.to_s, :verbose=>false
0
- puts "Compiling #{task.name.gsub(/:[^:]*$/, '')}" if verbose
0
+ puts "Compiling #{task.name.gsub(/:[^:]*$/, '')} into #{target.to_s}" if verbose
0
           @compiler.compile(sources.map(&:to_s), target.to_s, dependencies.map(&:to_s))
0
           # By touching the target we let other tasks know we did something,
0
           # and also prevent recompiling again for dependencies.
...
23
24
25
26
 
27
28
29
30
31
32
33
34
 
 
35
36
37
38
 
39
40
41
...
188
189
190
191
 
192
193
194
...
325
326
327
 
328
329
330
...
334
335
336
 
337
338
 
 
339
340
341
342
343
...
23
24
25
 
26
27
28
29
30
31
 
 
 
32
33
34
35
36
 
37
38
39
40
...
187
188
189
 
190
191
192
193
...
324
325
326
327
328
329
330
...
334
335
336
337
338
 
339
340
341
 
342
343
344
0
@@ -23,19 +23,18 @@ module CompilerHelper
0
   end
0
 
0
   def sources
0
- @sources ||= ['Test1.java', 'Test2.java'].map { |f| File.join('src/java', f) }.
0
+ @sources ||= ['Test1.java', 'Test2.java'].map { |f| File.join('src/main/java', f) }.
0
       each { |src| write src, "class #{src.pathmap('%n')} {}" }
0
   end
0
 
0
   def jars
0
     @jars ||= begin
0
- write 'src/main/java/Dependency.java', 'class Dependency { }'
0
- define 'jars', :version=>'1.0' do
0
- compile.into('dependency')
0
+ write 'jars/src/main/java/Dependency.java', 'class Dependency { }'
0
+ define 'jars', :version=>'1.0', :base_dir => 'jars' do
0
         package(:jar, :id=>'jar1')
0
         package(:jar, :id=>'jar2')
0
       end
0
- project('jars').packages.each(&:invoke).map(&:to_s)
0
+ project('jars').packages.map(&:to_s)
0
     end
0
   end
0
 end
0
@@ -188,7 +187,7 @@ describe Buildr::CompileTask, '#dependencies' do
0
   end
0
 
0
   it 'should allow artifacts' do
0
- artifact('group:id:jar:1.0') { |task| mkpath File.dirname(task.to_s) ; cp jars.first.to_s, task.to_s }
0
+ artifact('group:id:jar:1.0') { |task| mkpath File.dirname(task.to_s) ; cp jars.first.to_s, task.to_s }.enhance jars
0
     compile_task.from(sources).with('group:id:jar:1.0').into('classes').invoke
0
   end
0
 
0
@@ -325,6 +324,7 @@ describe Buildr::CompileTask, '#invoke' do
0
   end
0
 
0
   it 'should force compilation if dependencies newer than compiled' do
0
+ jars; project('jars').task("package").invoke
0
     # On my machine the times end up the same, so need to push dependencies in the past.
0
     time = Time.now
0
     sources.map { |src| src.pathmap("#{compile_task.target}/%n.class") }.
0
@@ -334,10 +334,11 @@ describe Buildr::CompileTask, '#invoke' do
0
   end
0
 
0
   it 'should not force compilation if dependencies older than compiled' do
0
+ jars; project('jars').task("package").invoke
0
     time = Time.now
0
- sources.map { |src| src.pathmap("#{compile_task.target}/%n.class") }.
0
+ jars.each { |jar| File.utime(time - 1 , time - 1, jar) }
0
+ sources.map { |src| File.utime(time, time, src); src.pathmap("#{compile_task.target}/%n.class") }.
0
       each { |kls| write kls ; File.utime(time, time, kls) }
0
- jars.each { |jar| File.utime(time - 1, time - 1, jar) }
0
     lambda { compile_task.from(sources).with(jars).invoke }.should_not run_task('foo:compile')
0
   end
0
 

Comments

    No one has commented yet.