<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/java/ant_spec.rb</filename>
    </added>
    <added>
      <filename>spec/java/test_coverage_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -16,6 +16,7 @@
 $LOADED_FEATURES &lt;&lt; 'jruby' unless RUBY_PLATFORM =~ /java/ # Pretend to have JRuby, keeps Nailgun happy.
 require 'buildr/jetty'
 require 'buildr/nailgun'
+require 'buildr/scala'
 repositories.remote &lt;&lt; 'http://repo1.maven.org/maven2'
 repositories.remote &lt;&lt; 'http://scala-tools.org/repo-releases/'
 
@@ -23,10 +24,14 @@ repositories.remote &lt;&lt; 'http://scala-tools.org/repo-releases/'
 define 'buildr' do
   compile.using :source=&gt;'1.4', :target=&gt;'1.4', :debug=&gt;false
 
-  define 'java' do  
+  define 'java' do
     compile.using(:javac).from(FileList['lib/buildr/java/**/*.java']).into('lib/buildr/java')
   end
 
+  define 'scala' do
+    compile.using(:scalac).from(FileList['lib/buildr/scala/**/*.scala']).into('lib/buildr/scala')
+  end
+
   desc 'Buildr extra packages (Antlr, Cobertura, Hibernate, Javacc, JDepend, Jetty, OpenJPA, XmlBeans)'
   define 'extra', :version=&gt;'1.0' do
     compile.using(:javac).from(FileList['addon/buildr/**/*.java']).into('addon/buildr').with(Buildr::Jetty::REQUIRES, Buildr::Nailgun::ARTIFACT_SPEC)</diff>
      <filename>buildr.buildfile</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,11 @@
 # the License.
 
 
+# TODO: Antwrap 0.7 requires this monkeypatch, have it fixed.
+class Array #:nodoc:
+  alias :nitems :size
+end
+
 require 'buildr/core/common'
 require 'buildr/core/application'
 require 'buildr/core/project'</diff>
      <filename>lib/buildr/core.rb</filename>
    </modified>
    <modified>
      <diff>@@ -244,7 +244,7 @@ module Buildr
     #
     # For example:
     #   compile.from('src/java').into('classes').with('module1.jar')
-    def from(*sources)  
+    def from(*sources)
       @sources |= sources.flatten
       guess_compiler if @compiler.nil? &amp;&amp; sources.flatten.any? { |source| File.exist?(source) }
       self</diff>
      <filename>lib/buildr/core/compile.rb</filename>
    </modified>
    <modified>
      <diff>@@ -285,7 +285,7 @@ module Buildr
           @config = configurer.call(*args, &amp;block)
         else
           raise ArgumentError, &quot;Missing hash argument after :#{mapper_type}&quot; unless args.size == 1 &amp;&amp; Hash === args[0]
-          @config = *args
+          @config = args.first
         end
         @mapper_type = mapper_type
       end
@@ -312,10 +312,8 @@ module Buildr
       
       def erb_transform(content, path = nil)
         case config
-        when Binding, Proc
+        when Binding
           bnd = config
-        when Method
-          bnd = config.to_proc
         when Hash
           bnd = OpenStruct.new
           table = config.inject({}) { |h, e| h[e.first.to_sym] = e.last; h }</diff>
      <filename>lib/buildr/core/filter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -222,7 +222,7 @@ module Buildr
             @on_define.each { |callback| callback[project] }
           end if @on_define
           # Enhance the project using the definition block.
-          project.enhance { project.instance_eval &amp;block } if block
+          project.enhance { project.instance_exec project, &amp;block } if block
 
           # Top-level project? Invoke the project definition. Sub-project? We don't invoke
           # the project definiton yet (allow project calls to establish order of evaluation),</diff>
      <filename>lib/buildr/core/project.rb</filename>
    </modified>
    <modified>
      <diff>@@ -148,11 +148,10 @@ module URI
         # worse than not having a file at all, so download to temporary
         # file and then move over.
         modified = File.stat(target).mtime if File.exist?(target)
-        temp = nil
-        Tempfile.open File.basename(target) do |temp|
-          temp.binmode
-          read({:progress=&gt;verbose}.merge(options || {}).merge(:modified=&gt;modified)) { |chunk| temp.write chunk }
-        end
+        temp = Tempfile.new(File.basename(target))
+        temp.binmode
+        read({:progress=&gt;verbose}.merge(options || {}).merge(:modified=&gt;modified)) { |chunk| temp.write chunk }
+        temp.close
         mkpath File.dirname(target)
         mv temp.path, target
       when File
@@ -537,20 +536,18 @@ module URI
 
     def write_internal(options, &amp;block) #:nodoc:
       raise ArgumentError, 'Either you\'re attempting to write a file to another host (which we don\'t support), or you used two slashes by mistake, where you should have file:///&lt;path&gt;.' if host
-      temp = nil
-      Tempfile.open File.basename(path) do |temp|
-        temp.binmode
-        with_progress_bar options[:progress] &amp;&amp; options[:size], path.split('/'), options[:size] || 0 do |progress|
-          while chunk = yield(RW_CHUNK_SIZE)
-            temp.write chunk
-            progress &lt;&lt; chunk
-          end
+      temp = Tempfile.new(File.basename(path))
+      temp.binmode
+      with_progress_bar options[:progress] &amp;&amp; options[:size], path.split('/'), options[:size] || 0 do |progress|
+        while chunk = yield(RW_CHUNK_SIZE)
+          temp.write chunk
+          progress &lt;&lt; chunk
         end
       end
-      real_path.tap do |path|
-        mkpath File.dirname(path)
-        mv temp.path, path
-      end
+      temp.close
+      mkpath File.dirname(real_path)
+      mv temp.path, real_path
+      real_path
     end
 
     @@schemes['FILE'] = FILE</diff>
      <filename>lib/buildr/core/transports.rb</filename>
    </modified>
    <modified>
      <diff>@@ -159,24 +159,54 @@ module Buildr
 end
 
 
-if RUBY_VERSION &lt; '1.9.0'
-  module Kernel #:nodoc:
-    # Borrowed from Ruby 1.9.
+class Object #:nodoc:
+  unless defined? instance_exec # 1.9
+    module InstanceExecMethods #:nodoc:
+    end
+    include InstanceExecMethods
+
+    # Evaluate the block with the given arguments within the context of
+    # this object, so self is set to the method receiver.
+    #
+    # From Mauricio's http://eigenclass.org/hiki/bounded+space+instance_exec
+    def instance_exec(*args, &amp;block)
+      begin
+        old_critical, Thread.critical = Thread.critical, true
+        n = 0
+        n += 1 while respond_to?(method_name = &quot;__instance_exec#{n}&quot;)
+        InstanceExecMethods.module_eval { define_method(method_name, &amp;block) }
+      ensure
+        Thread.critical = old_critical
+      end
+
+      begin
+        send(method_name, *args)
+      ensure
+        InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil
+      end
+    end
+  end
+end
+
+module Kernel #:nodoc:
+  unless defined? tap # 1.9
     def tap
       yield self if block_given?
       self
-    end unless method_defined?('tap')
+    end
   end
+end
 
-
-  class Symbol #:nodoc:
+class Symbol #:nodoc:
+  unless defined? to_proc # 1.9
     # Borrowed from Ruby 1.9.
     def to_proc
       Proc.new{|*args| args.shift.__send__(self, *args)}
-    end unless method_defined?('to_proc')
+    end
   end
+end
 
-  # Also borrowed from Ruby 1.9.
+unless defined? BasicObject # 1.9
   class BasicObject #:nodoc:
     (instance_methods - ['__send__', '__id__', '==', 'send', 'send!', 'respond_to?', 'equal?', 'object_id']).
       each do |method|</diff>
      <filename>lib/buildr/core/util.rb</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>lib/buildr/java/org/apache/buildr/JavaTestFilter.class</filename>
    </modified>
    <modified>
      <diff>@@ -39,7 +39,7 @@ module Buildr
             sections = str.split(SECTION_SEPARATOR).reject { |s| s.strip.empty? }
             new sections.map { |section|
               lines = section.split(LINE_SEPARATOR).inject([]) { |merged, line|
-                if line[0] == 32
+                if line[/^ /] == ' '
                   merged.last &lt;&lt; line[1..-1]
                 else
                   merged &lt;&lt; line
@@ -302,7 +302,7 @@ module Buildr
           @wsdls = []
           prepare do
             path('META-INF').include @wsdls
-            path('META-INF').include @services_xml, :as=&gt;['services.xml'] if @services_xml
+            path('META-INF').include @services_xml, :as=&gt;'services.xml' if @services_xml
             path('lib').include Buildr.artifacts(@libs) unless @libs.nil? || @libs.empty?
           end
         end</diff>
      <filename>lib/buildr/java/packaging.rb</filename>
    </modified>
    <modified>
      <diff>@@ -134,7 +134,7 @@ module Java
 
     def __package__(name) #:nodoc:
       const = name.split('.').map { |part| part.gsub(/^./) { |char| char.upcase } }.join
-      return const_get(const) if constants.include?(const)
+      return const_get(const) if constants.include?(const) || constants.include?(const.to_sym)
       package = Module.new
       package.extend Package
       package.instance_variable_set :@name, name</diff>
      <filename>lib/buildr/java/rjb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -736,7 +736,7 @@ module Buildr
 
     # Like Hash#fetch
     def fetch(name, default = nil, &amp;block)
-      block ||= lambda { raise IndexError.new(&quot;No artifact found by name #{name.inspect} in namespace #{self}&quot;) }
+      block ||= proc { raise IndexError.new(&quot;No artifact found by name #{name.inspect} in namespace #{self}&quot;) }
       real_name = name.to_s[/^[\w\-\.]+$/] ? name : ArtifactRequirement.unversioned_spec(name)
       get(real_name.to_sym) || default || block.call(name)
     end</diff>
      <filename>lib/buildr/packaging/artifact_namespace.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,16 @@
 # the License.
 
 
-$LOADED_FEATURES.unshift 'ftools' if RUBY_VERSION &gt;= '1.9.0' # Required to properly load RubyZip under Ruby 1.9
+if RUBY_VERSION &gt;= '1.9.0' # Required to properly load RubyZip under Ruby 1.9
+  $LOADED_FEATURES.unshift 'ftools'
+  require 'fileutils'
+  def File.move(source, dest)
+    FileUtils.move source, dest
+  end
+  def File.rm_rf(path)
+    FileUtils.rm_rf path
+  end
+end
 require 'zip/zip'
 require 'zip/zipfilesystem'
 </diff>
      <filename>lib/buildr/packaging/zip.rb</filename>
    </modified>
    <modified>
      <diff>@@ -122,7 +122,8 @@ module Buildr
 
     # Initialize with hash argument of the form target=&gt;zip_file.
     def initialize(args)
-      @target, arg_names, @zip_file = Buildr.application.resolve_args([args])
+      @target, arg_names, zip_file = Buildr.application.resolve_args([args])
+      @zip_file = zip_file.first
       @paths = {}
     end
 </diff>
      <filename>lib/buildr/packaging/ziptask.rb</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class</filename>
    </modified>
    <modified>
      <diff>@@ -109,8 +109,9 @@ module Buildr::Scala
             ant.suite    :classname=&gt;suite
             ant.reporter :type=&gt;'stdout', :config=&gt;reporter_options
             ant.reporter :type=&gt;'file', :filename=&gt; reportFile, :config=&gt;reporter_options
-            ant.includes group_includes.join(&quot; &quot;) if group_includes
-            ant.excludes group_excludes.join(&quot; &quot;) if group_excludes
+            # TODO: This should be name=&gt;value pairs!
+            #ant.includes group_includes.join(&quot; &quot;) if group_includes
+            #ant.excludes group_excludes.join(&quot; &quot;) if group_excludes
             (options[:properties] || []).each { |name, value| ant.property :name=&gt;name, :value=&gt;value }
           end
         end</diff>
      <filename>lib/buildr/scala/tests.rb</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@ describe Buildr.method(:struct) do
   end
 
   it 'should return members when requested' do
-    @struct.members.sort.should eql(@hash.keys.map(&amp;:to_s).sort)
+    @struct.members.map(&amp;:to_s).sort.should eql(@hash.keys.map(&amp;:to_s).sort)
   end
 
   it 'should return valued when requested' do</diff>
      <filename>spec/core/common_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -293,7 +293,8 @@ describe Buildr::CompileTask, '#invoke' do
   end
 
   it 'should run all source files as prerequisites' do
-    file(mkpath('src')).should_receive :invoke_prerequisites
+    mkpath 'src'
+    file('src').should_receive :invoke_prerequisites
     compile_task.from('src').invoke
   end
 </diff>
      <filename>spec/core/compile_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -333,10 +333,10 @@ describe Buildr::TestTask, 'with passing tests' do
   it 'should execute teardown task' do
     lambda { test_task.invoke }.should run_task('foo:test:teardown')
   end
-  
+
   it 'should update the last successful run timestamp' do
     before = Time.now ; test_task.invoke ; after = Time.now
-    (before-1..after+1).should include(test_task.timestamp)
+    (before-1..after+1).should cover(test_task.timestamp)
   end
 end
 </diff>
      <filename>spec/core/test_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -151,6 +151,7 @@ describe 'groovyc compiler options' do
         return compile
       end
     end
+    project('foo').compile
   end
   
   it 'should set warning option to false by default' do </diff>
      <filename>spec/groovy/compiler_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,16 @@
 require File.join(File.dirname(__FILE__), '../spec_helpers')
 
 
+JAVA_CONTAINER  = 'org.eclipse.jdt.launching.JRE_CONTAINER'
+SCALA_CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
+
+SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
+JAVA_NATURE  = 'org.eclipse.jdt.core.javanature'
+
+SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
+JAVA_BUILDER  = 'org.eclipse.jdt.core.javabuilder'
+
+
 module EclipseHelper
   def classpath_xml_elements
     task('eclipse').invoke
@@ -52,6 +62,7 @@ module EclipseHelper
     task('eclipse').invoke
     REXML::Document.new(File.open('.project')).root.elements
   end
+
 end
 
 
@@ -60,15 +71,6 @@ describe Buildr::Eclipse do
   
   describe &quot;eclipse's .project file&quot; do
 
-    JAVA_CONTAINER  = 'org.eclipse.jdt.launching.JRE_CONTAINER'
-    SCALA_CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
-
-    SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
-    JAVA_NATURE  = 'org.eclipse.jdt.core.javanature'
-    
-    SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
-    JAVA_BUILDER  = 'org.eclipse.jdt.core.javabuilder'
-
     def project_natures
       project_xml_elements.collect(&quot;natures/nature&quot;) { |n| n.text }
     end</diff>
      <filename>spec/ide/eclipse_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@
 # the License.
 
 
-require File.join(File.dirname(__FILE__), 'test_coverage_spec')
+require File.join(File.dirname(__FILE__), 'test_coverage_helper')
 Sandbox.require_optional_extension 'buildr/java/cobertura'
 artifacts(Buildr::Cobertura::dependencies).map(&amp;:invoke)
 </diff>
      <filename>spec/java/cobertura_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@
 # the License.
 
 
-require File.join(File.dirname(__FILE__), 'test_coverage_spec')
+require File.join(File.dirname(__FILE__), 'test_coverage_helper')
 Sandbox.require_optional_extension 'buildr/java/emma'
 artifacts(Buildr::Emma::dependencies).map(&amp;:invoke)
 </diff>
      <filename>spec/java/emma_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -341,7 +341,7 @@ describe 'package with meta_inf', :shared=&gt;true do
     package.invoke
     assumed = Array(@meta_inf_ignore)
     Zip::ZipFile.open(package.to_s) do |zip|
-      entries = zip.entries.map(&amp;:to_s).select { |f| File.dirname(f) == 'META-INF' }.map { |f| File.basename(f) }
+      entries = zip.entries.map(&amp;:name).select { |f| File.dirname(f) == 'META-INF' }.map { |f| File.basename(f) }
       assumed.each { |f| entries.should include(f) }
       yield entries - assumed if block_given?
     end
@@ -659,7 +659,7 @@ describe Packaging, 'ear' do
         tmp.write ear.file.read(package)
       end
       manifest = Buildr::Packaging::Java::Manifest.from_zip('tmp.zip')
-      yield manifest.main['Class-Path'].to_s.split(' ')
+      yield manifest.main['Class-Path'].split(' ')
     end
   end
 
@@ -911,7 +911,7 @@ describe Packaging, 'ear' do
       package(:ear) &lt;&lt; { :jar=&gt;package(:jar) } &lt;&lt; { :jar=&gt;package(:jar, :id=&gt;'bar') }
     end
     inspect_application_xml do |xml|
-      jars = xml.get_elements('/application/jar').map(&amp;:texts).map(&amp;:to_s)
+      jars = xml.get_elements('/application/jar').map(&amp;:texts).map(&amp;:join)
       jars.should include('jar/foo-1.0.jar', 'jar/bar-1.0.jar')
     end
   end</diff>
      <filename>spec/java/packaging_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -231,7 +231,7 @@ describe Repositories, 'remote' do
   it 'should deal well with repositories URL that lack the last slash' do
     repositories.remote = 'http://example.com/base'
     uri = nil
-    URI.should_receive(:download).twice.and_return { |uri, target, options| }
+    URI.should_receive(:download).twice.and_return { |_uri, args| uri = _uri }
     artifact('group:id:jar:1.0').invoke
     uri.to_s.should eql('http://example.com/base/group/id/1.0/id-1.0.pom')
   end
@@ -239,7 +239,7 @@ describe Repositories, 'remote' do
   it 'should deal well with repositories URL that have the last slash' do
     repositories.remote = 'http://example.com/base/'
     uri = nil
-    URI.should_receive(:download).twice.and_return { |uri, target, options| }
+    URI.should_receive(:download).twice.and_return { |_uri, args| p args ; uri = _uri }
     artifact('group:id:jar:1.0').invoke
     uri.to_s.should eql('http://example.com/base/group/id/1.0/id-1.0.pom')
   end</diff>
      <filename>spec/packaging/artifact_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -253,7 +253,16 @@ unless defined?(SpecHelpers)
       AbsolutePathMatcher.new(path)
     end
 
+    
+    # Value covered by range. For example:
+    #   (1..5).should cover(3)
+    def cover(value)
+      simple_matcher :cover do |given|
+        value &gt;= given.min &amp;&amp; value &lt;= given.max 
+      end
+    end
 
+  
     def suppress_stdout
       stdout = $stdout
       $stdout = StringIO.new</diff>
      <filename>spec/spec_helpers.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>addon/buildr/org/apache/buildr/BuildrNail$Main.class</filename>
    </removed>
    <removed>
      <filename>addon/buildr/org/apache/buildr/BuildrNail.class</filename>
    </removed>
    <removed>
      <filename>addon/buildr/org/apache/buildr/JettyWrapper$1.class</filename>
    </removed>
    <removed>
      <filename>addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class</filename>
    </removed>
    <removed>
      <filename>addon/buildr/org/apache/buildr/JettyWrapper.class</filename>
    </removed>
    <removed>
      <filename>spec/java/ant.rb</filename>
    </removed>
    <removed>
      <filename>spec/java/test_coverage_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>1a6dd608ad79b58605b6b5d652d9dce88f7ea50b</id>
    </parent>
  </parents>
  <author>
    <name>Assaf Arkin</name>
    <email>assaf@apache.org</email>
  </author>
  <url>http://github.com/assaf/buildr/commit/3caa28648a1a7b10754d9b161fc998560b85affb</url>
  <id>3caa28648a1a7b10754d9b161fc998560b85affb</id>
  <committed-date>2009-06-23T11:39:20-07:00</committed-date>
  <authored-date>2009-06-23T11:39:20-07:00</authored-date>
  <message>Ruby 1.9.1 compatibility:
- erb_transform works well with binding, not proc

- foo = *args fixed to foo = args.last

- Seems that Struct keys are now strings

- Proper Tempfile handling to get around scoped closure variables

- constants returns symbols instead of strings

- mkpath returns array not a string

- Array.nitems no longer exists, Antwrap requires this patch

- Added cover matcher since include? doesn't work on time range

- What we need is instance_exec, new in 1.9 and back-ported by RSpec 1.2.

- Fixed eclipse specs (1.8 and 1.9 don't lookup constants the same way).

Specs should end with _spec.rb (helps distinguish them from helpers and such).

Commented out groups in Scala tests.

git-svn-id: https://svn.apache.org/repos/asf/buildr/trunk@787782 13f79535-47bb-0310-9956-ffa450edef68</message>
  <tree>1790a0f2d51e4b8e679f6e4b8d6f5091ffdf987e</tree>
  <committer>
    <name>Assaf Arkin</name>
    <email>assaf@apache.org</email>
  </committer>
</commit>
