You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by bo...@apache.org on 2010/01/23 20:52:12 UTC

svn commit: r902468 - in /buildr/trunk: CHANGELOG lib/buildr/core/test.rb lib/buildr/groovy/compiler.rb lib/buildr/java/bdd.rb lib/buildr/java/tests.rb lib/buildr/scala/bdd.rb lib/buildr/scala/compiler.rb

Author: boisvert
Date: Sat Jan 23 19:52:11 2010
New Revision: 902468

URL: http://svn.apache.org/viewvc?rev=902468&view=rev
Log:
BUILDR-366 Scala dependencies should be lazily loaded into Java.classpath
and refactoring of compile/test classpath handling + plugin dependencies

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/core/test.rb
    buildr/trunk/lib/buildr/groovy/compiler.rb
    buildr/trunk/lib/buildr/java/bdd.rb
    buildr/trunk/lib/buildr/java/tests.rb
    buildr/trunk/lib/buildr/scala/bdd.rb
    buildr/trunk/lib/buildr/scala/compiler.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=902468&r1=902467&r2=902468&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sat Jan 23 19:52:11 2010
@@ -42,6 +42,8 @@
 * Fixed:  BUILDR-364 Package spec should be set to a Symbol when :file is
           used (Klaas Prause)
 * Fixed:  BUILDR-365 test task should use test compile dependencies
+* Fixed:  BUILDR-366 Scala dependencies should be lazily loaded into
+          Java.classpath
 * Fixed:  Fail-fast if package.with() or include() called with nil values
 * Fixed:  Failures not reported correctly for ScalaTest (Alex Eagle)
 * Fixed:  Test dependencies should include test compile dependencies

Modified: buildr/trunk/lib/buildr/core/test.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/test.rb?rev=902468&r1=902467&r2=902468&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/test.rb (original)
+++ buildr/trunk/lib/buildr/core/test.rb Sat Jan 23 19:52:11 2010
@@ -176,7 +176,7 @@
         # all sub-projects, but only invoke test on the local project.
         Project.projects.each { |project| project.test.send :only_run, tests }
       end
-      
+
       # Used by the test/integration rule to only run tests that failed the last time.
       def only_run_failed() #:nodoc:
         # Since the tests may reside in a sub-project, we need to set the include/exclude pattern on
@@ -406,17 +406,17 @@
     def report_to
       @report_to ||= file(@project.path_to(:reports, framework)=>self)
     end
-    
+
     # :call-seq:
     #   failures_to => file
     #
     # We record the list of failed tests for the current framework in this file.
     #
-    # 
+    #
     def failures_to
       @failures_to ||= file(@project.path_to(:target, "#{framework}-failed")=>self)
     end
-    
+
     # :call-seq:
     #    last_failures => array
     #
@@ -466,7 +466,7 @@
 
     # Runs the tests using the selected test framework.
     def run_tests
-      dependencies = Buildr.artifacts(self.dependencies).map(&:to_s).uniq
+      dependencies = (Buildr.artifacts(self.dependencies + compile.dependencies) + [compile.target]).map(&:to_s).uniq
       rm_rf report_to.to_s
       rm_rf failures_to.to_s
       @tests = @framework.tests(dependencies).select { |test| include?(test) }.sort
@@ -476,7 +476,7 @@
         info "Running tests in #{@project.name}"
         begin
           # set the baseDir system property if not set
-          @framework.options[:properties] = { 'baseDir' => @project.test.compile.target.to_s }.merge(@framework.options[:properties] || {})
+          @framework.options[:properties] = { 'baseDir' => compile.target.to_s }.merge(@framework.options[:properties] || {})
           @passed_tests = @framework.run(@tests, dependencies)
         rescue Exception=>ex
           error "Test framework error: #{ex.message}"
@@ -505,7 +505,7 @@
       @exclude.clear
       @forced_need = true
     end
-    
+
     # Limit running tests to those who failed the last time.
     def only_run_failed()
       @include = Array(last_failures)
@@ -582,10 +582,10 @@
     first_time do
       desc 'Run all tests'
       task('test') { TestTask.run_local_tests false }
-      
+
       desc 'Run failed tests'
       task('test:failed') {
-        TestTask.only_run_failed 
+        TestTask.only_run_failed
         task('test').invoke
       }
 
@@ -632,8 +632,8 @@
       # Define these tasks once, otherwise we may get a namespace error.
       test.setup ; test.teardown
     end
-    
-    
+
+
 
     after_define(:test => :compile) do |project|
       test = project.test

Modified: buildr/trunk/lib/buildr/groovy/compiler.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/groovy/compiler.rb?rev=902468&r1=902467&r2=902468&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/groovy/compiler.rb (original)
+++ buildr/trunk/lib/buildr/groovy/compiler.rb Sat Jan 23 19:52:11 2010
@@ -33,9 +33,9 @@
   # * :encoding          -- Encoding of source files
   # * :verbose           -- Asks the compiler for verbose output, true when running in verbose mode.
   # * :fork              -- Whether to execute groovyc using a spawned instance of the JVM; defaults to no
-  # * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise. 
+  # * :memoryInitialSize -- The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise.
   #                                     Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
-  # * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise. 
+  # * :memoryMaximumSize -- The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise.
   #                                     Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
   # * :listfiles         -- Indicates whether the source files to be compiled will be listed; defaults to no
   # * :stacktrace        -- If true each compile error message will contain a stacktrace
@@ -49,7 +49,7 @@
   # * :javac             -- Hash of options passed to the ant javac task
   #
   class Groovyc < Compiler::Base
-    
+
     # The groovyc compiler jars are added to classpath at load time,
     # if you want to customize artifact versions, you must set them on the
     #
@@ -62,7 +62,7 @@
       ns.asm!          'asm:asm:jar:>=2.2'
       ns.antlr!        'antlr:antlr:jar:>=2.7.7'
     end
-    
+
     ANT_TASK = 'org.codehaus.groovy.ant.Groovyc'
     GROOVYC_OPTIONS = [:encoding, :verbose, :fork, :memoryInitialSize, :memoryMaximumSize, :listfiles, :stacktrace]
     JAVAC_OPTIONS = [:optimise, :warnings, :debug, :deprecation, :source, :target, :javac]
@@ -80,10 +80,10 @@
         paths.any? { |path| !Dir["#{path}/**/*.groovy"].empty? }
       end
     end
-    
-    Java.classpath << dependencies
-    
-    specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java], 
+
+    Java.classpath << lambda { dependencies }
+
+    specify :language => :groovy, :sources => [:groovy, :java], :source_ext => [:groovy, :java],
             :target => 'classes', :target_ext => 'class', :packaging => :jar
 
     def initialize(project, options) #:nodoc:
@@ -100,7 +100,7 @@
     def compile(sources, target, dependencies) #:nodoc:
       return if Buildr.application.options.dryrun
       Buildr.ant 'groovyc' do |ant|
-        classpath = dependencies | self.class.dependencies.map(&:to_s)
+        classpath = dependencies
         ant.taskdef :name => 'groovyc', :classname => ANT_TASK, :classpath => classpath.join(File::PATH_SEPARATOR)
         ant.groovyc groovyc_options(sources, target) do
           sources.each { |src| ant.src :path => src }
@@ -112,7 +112,7 @@
       end
     end
 
-   private 
+   private
     def groovyc_options(sources, target)
       check_options options, OPTIONS
       groovyc_options = options.to_hash.only(*GROOVYC_OPTIONS)
@@ -129,7 +129,7 @@
       javac_options.merge!(other)
       javac_options
     end
-    
+
   end
 end
 

Modified: buildr/trunk/lib/buildr/java/bdd.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/bdd.rb?rev=902468&r1=902467&r2=902468&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/bdd.rb (original)
+++ buildr/trunk/lib/buildr/java/bdd.rb Sat Jan 23 19:52:11 2010
@@ -31,7 +31,7 @@
     def initialize(task, options)
       self.bdd_dir = self.class.bdd_dir
       project = task.project
-      project.task('test:compile').tap do |comp| 
+      project.task('test:compile').tap do |comp|
         comp.send :associate_with, project, bdd_dir
         self.lang = comp.language || self.class.lang
       end
@@ -42,7 +42,7 @@
       end
       super
     end
-    
+
   end
 
   module TestFramework::JRubyBased
@@ -58,9 +58,12 @@
       def jruby_artifact
         "org.jruby:jruby-complete:jar:#{version}"
       end
-      
+
       def dependencies
-        [jruby_artifact]
+        unless @dependencies
+          @dependencies = [jruby_artifact]
+        end
+        @dependencies
       end
 
       def included(mod)
@@ -71,18 +74,20 @@
 
     module ClassMethods
       def dependencies
-        deps = super
-        unless RUBY_PLATFORM[/java/] && TestFramework::JRubyBased.jruby_installed?
-          deps |= TestFramework::JRubyBased.dependencies
+        unless @dependencies
+          super
+          unless RUBY_PLATFORM[/java/] && TestFramework::JRubyBased.jruby_installed?
+            @dependencies |= TestFramework::JRubyBased.dependencies
+          end
         end
-        deps
+        @dependencies
       end
     end
 
     def run(tests, dependencies)
       maybe_install_jruby
       dependencies |= [task.compile.target.to_s]
-      
+
       spec_dir = task.project.path_to(:source, :spec, :ruby)
       report_dir = task.report_to.to_s
       rm_rf report_dir
@@ -91,7 +96,7 @@
 
       runner = runner_config
       runner.content = runner_content(binding)
-      
+
       Buildr.write(runner.file, runner.content)
       rm_f runner.result
 
@@ -104,7 +109,7 @@
         cmd_options.update(:classpath => dependencies, :project => task.project)
         jruby runner.file, tests, cmd_options
       end
-      
+
       result = YAML.load(File.read(runner.result))
       if Exception === result
         raise [result.message, result.backtrace].flatten.join("\n")
@@ -113,14 +118,14 @@
     end
 
     def jruby_home
-      @jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] : 
+      @jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] :
         ( ENV['JRUBY_HOME'] || File.expand_path('~/.jruby') )
     end
 
     def jruby_installed?
       !Dir.glob(File.join(jruby_home, 'lib', 'jruby*.jar')).empty?
     end
-    
+
   protected
     def maybe_install_jruby
       unless jruby_installed?
@@ -137,7 +142,7 @@
           jruby_artifact.invoke
           Java::Commands.java('-jar', jruby_artifact.to_s, '-S', 'extract', jruby_home)
         end
-        
+
         fail msg unless jruby_installed?
       end
     end
@@ -164,7 +169,7 @@
       yield config if block_given?
       Java.org.jruby.Ruby.newInstance config
     end
-    
+
     def jruby_gem
       %{
        require 'jruby'
@@ -204,7 +209,7 @@
       runner.rspec.push '--format', "Buildr::TestFramework::TestResult::YamlFormatter:#{runner.result}"
       runner
     end
-    
+
   end
 
   # <a href="http://rspec.info">RSpec</a> is the defacto BDD framework for ruby.
@@ -227,7 +232,7 @@
     @bdd_dir = :spec
 
     include TestFramework::JRubyBased
-  
+
     TESTS_PATTERN = [ /_spec.rb$/ ]
     OPTIONS = [:properties, :java_args]
 
@@ -236,7 +241,7 @@
     end
 
     def tests(dependencies) #:nodoc:
-      Dir[task.project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].select do |name| 
+      Dir[task.project.path_to(:source, bdd_dir, lang, '**/*_spec.rb')].select do |name|
         selector = ENV['SPEC']
         selector.nil? || Regexp.new(selector) === name
       end
@@ -267,7 +272,7 @@
         argv.push *<%= tests.inspect %>
         parser.order!(argv)
         $rspec_options = parser.options
-        
+
         Buildr::TestFramework::TestResult::Error.guard('<%= runner.result %>') do
           ::Spec::Runner::CommandLine.run($rspec_options)
         end
@@ -296,12 +301,12 @@
   # * :java_args  -- Arguments passed to the JVM.
   class JtestR < TestFramework::JavaBDD
     @lang = :ruby
-    @bdd_dir = :spec    
+    @bdd_dir = :spec
 
     include TestFramework::JRubyBased
 
     VERSION = '0.5'
-    
+
     # pattern for rspec stories
     STORY_PATTERN    = /_(steps|story)\.rb$/
     # pattern for test_unit files
@@ -318,10 +323,14 @@
       end
 
       def dependencies
-        @dependencies ||= Array(super) + ["org.jtestr:jtestr:jar:#{version}"] +
-          JUnit.dependencies + TestNG.dependencies
+        unless @dependencies
+          super
+          @dependencies |= ["org.jtestr:jtestr:jar:#{version}"] +
+                           JUnit.dependencies + TestNG.dependencies
+        end
+        @dependencies
       end
-    
+
       def applies_to?(project) #:nodoc:
         File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) ||
           Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } ||
@@ -368,7 +377,7 @@
 
     def runner_config
       runner = super
-      # JtestR 0.3.1 comes with rspec 1.1.4 (and any other jtestr dependency) included, 
+      # JtestR 0.3.1 comes with rspec 1.1.4 (and any other jtestr dependency) included,
       # so the rspec version used depends on the jtestr jar.
       runner.requires.unshift 'jtestr'
       runner
@@ -378,16 +387,16 @@
       runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
       Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
     end
-    
+
   end
 
-  
+
   # JBehave is a Java BDD framework. To use in your project:
   #   test.using :jbehave
-  # 
+  #
   # This framework will search in your project for:
   #   src/spec/java/**/*Behaviour.java
-  # 
+  #
   # JMock libraries are included on runtime.
   #
   # Support the following options:
@@ -399,15 +408,19 @@
 
     VERSION = '1.0.1'
     TESTS_PATTERN = [ /Behaviou?r$/ ] #:nodoc:
-    
+
     class << self
       def version
         Buildr.settings.build['jbehave'] || VERSION
       end
 
       def dependencies
-        @dependencies ||= ["org.jbehave:jbehave:jar:#{version}", 'cglib:cglib-full:jar:2.0.2'] +
-          JMock.dependencies + JUnit.dependencies
+        unless @dependencies
+          super
+          @dependencies |= ["org.jbehave:jbehave:jar:#{version}", 'cglib:cglib-full:jar:2.0.2'] +
+                           JMock.dependencies + JUnit.dependencies
+        end
+        @dependencies
       end
 
       def applies_to?(project) #:nodoc:
@@ -428,7 +441,7 @@
       filter_classes(dependencies, :class_names => TESTS_PATTERN,
                      :interfaces => %w{ org.jbehave.core.behaviour.Behaviours })
     end
-    
+
     def run(tests, dependencies) #:nodoc:
       cmd_args = ['org.jbehave.core.BehaviourRunner']
       cmd_options = { :properties=>options[:properties], :java_args=>options[:java_args], :classpath=>dependencies }
@@ -441,7 +454,7 @@
         end
       end
     end
-    
+
   end
 
 end

Modified: buildr/trunk/lib/buildr/java/tests.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/tests.rb?rev=902468&r1=902467&r2=902468&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/tests.rb (original)
+++ buildr/trunk/lib/buildr/java/tests.rb Sat Jan 23 19:52:11 2010
@@ -24,13 +24,21 @@
   class TestFramework::Java < TestFramework::Base
 
     class << self
-      
+
       def applies_to?(project) #:nodoc:
         project.test.compile.language == :java
       end
-      
+
+      def dependencies
+        unless @dependencies
+          super
+          # Add buildr utility classes (e.g. JavaTestFilter)
+          @dependencies |= [ File.join(File.dirname(__FILE__)) ]
+        end
+        @dependencies
+      end
     end
-    
+
   private
 
     # Add buildr utilities (JavaTestFilter) to classpath
@@ -38,8 +46,8 @@
 
     # :call-seq:
     #     filter_classes(dependencies, criteria)
-    # 
-    # Return a list of classnames that match the given criteria. 
+    #
+    # Return a list of classnames that match the given criteria.
     # The criteria parameter is a hash that must contain at least one of:
     #
     # * :class_names -- List of patterns to match against class name
@@ -62,7 +70,7 @@
         Java.load
         filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
         if criteria[:interfaces]
-          filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String)) 
+          filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String))
         end
         if criteria[:class_annotations]
           filter.add_class_annotations(criteria[:class_annotations].to_java(Java.java.lang.String))
@@ -79,15 +87,15 @@
         raise
       end
     end
-    
+
   end
 
 
   # JMock is available when using JUnit and TestNG, JBehave.
   module JMock
-    
+
     VERSION = '1.2.0'
-    
+
     class << self
       def version
         Buildr.settings.build['jmock'] || VERSION
@@ -96,14 +104,14 @@
       def dependencies
         @dependencies ||= ["jmock:jmock:jar:#{version}"]
       end
-      
+
     private
       def const_missing(const)
         return super unless const == :REQUIRES # TODO: remove in 1.5
         Buildr.application.deprecated "Please use JMock.dependencies/.version instead of JMock::REQUIRES/VERSION"
         dependencies
       end
-    end    
+    end
   end
 
 
@@ -147,7 +155,7 @@
       def generate(projects, target = @target.to_s)
         html_in = File.join(target, 'html')
         rm_rf html_in ; mkpath html_in
-        
+
         Buildr.ant('junit-report') do |ant|
           ant.taskdef :name=>'junitreport', :classname=>'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
             :classpath=>Buildr.artifacts(JUnit.ant_taskdef).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
@@ -184,25 +192,25 @@
       def version
         Buildr.settings.build['junit'] || VERSION
       end
-      
+
       def dependencies
         @dependencies ||= ["junit:junit:jar:#{version}"]+ JMock.dependencies
       end
-      
+
       def ant_taskdef #:nodoc:
         "org.apache.ant:ant-junit:jar:#{Ant.version}"
       end
-      
+
     private
       def const_missing(const)
         return super unless const == :REQUIRES # TODO: remove in 1.5
         Buildr.application.deprecated "Please use JUnit.dependencies/.version instead of JUnit::REQUIRES/VERSION"
         dependencies
       end
-    end          
+    end
 
     def tests(dependencies) #:nodoc:
-      filter_classes(dependencies, 
+      filter_classes(dependencies,
                      :interfaces => %w{junit.framework.TestCase},
                      :class_annotations => %w{org.junit.runner.RunWith},
                      :method_annotations => %w{org.junit.Test})
@@ -284,21 +292,21 @@
       def version
         Buildr.settings.build['testng'] || VERSION
       end
-      
+
       def dependencies
         ["org.testng:testng:jar:jdk15:#{version}"]+ JMock.dependencies
-      end  
-      
+      end
+
     private
       def const_missing(const)
         return super unless const == :REQUIRES # TODO: remove in 1.5
         Buildr.application.deprecated "Please use TestNG.dependencies/.version instead of TestNG::REQUIRES/VERSION"
         dependencies
       end
-    end          
+    end
 
     def tests(dependencies) #:nodoc:
-      filter_classes(dependencies, 
+      filter_classes(dependencies,
                      :class_annotations => %w{org.testng.annotations.Test},
                      :method_annotations => %w{org.testng.annotations.Test})
     end

Modified: buildr/trunk/lib/buildr/scala/bdd.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/bdd.rb?rev=902468&r1=902467&r2=902468&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/bdd.rb (original)
+++ buildr/trunk/lib/buildr/scala/bdd.rb Sat Jan 23 19:52:11 2010
@@ -40,7 +40,14 @@
       end
 
       def dependencies
-        ["org.scala-tools.testing:specs:jar:#{version}"] + Check.dependencies + JUnit.dependencies
+        unless @dependencies
+          super
+          # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies
+          @dependencies |= [ File.join(File.dirname(__FILE__)) ] +
+                           ["org.scala-tools.testing:specs:jar:#{version}"] +
+                           Check.dependencies + JUnit.dependencies + Scalac.dependencies
+        end
+        @dependencies
       end
 
       def applies_to?(project)  #:nodoc:
@@ -76,8 +83,6 @@
     end
 
     def run(specs, dependencies)  #:nodoc:
-      dependencies += [task.compile.target.to_s, File.join(File.dirname(__FILE__))] + Scalac.dependencies
-
       cmd_options = { :properties => options[:properties],
                       :java_args => options[:java_args],
                       :classpath => dependencies,

Modified: buildr/trunk/lib/buildr/scala/compiler.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/compiler.rb?rev=902468&r1=902467&r2=902468&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/compiler.rb (original)
+++ buildr/trunk/lib/buildr/scala/compiler.rb Sat Jan 23 19:52:11 2010
@@ -20,10 +20,10 @@
 
 module Buildr::Scala
   DEFAULT_VERSION = '2.7.7'   # currently the latest (Oct 31, 2009)
-  
+
   class << self
-    
-    # Retrieves the Scala version string from the 
+
+    # Retrieves the Scala version string from the
     # standard library or nil if Scala is not
     # available.
     def version_str
@@ -34,7 +34,7 @@
         nil
       end
     end
-    
+
     def version
       if version_str
         # any consecutive sequence of numbers followed by dots
@@ -60,7 +60,7 @@
   # * :debug       -- Generate debugging info.
   # * :other       -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
   class Scalac < Buildr::Compiler::Base
-    
+
     # The scalac compiler jars are added to classpath at load time,
     # if you want to customize artifact versions, you must set them on the
     #
@@ -72,18 +72,18 @@
       ns.library!      'org.scala-lang:scala-library:jar:>=' + DEFAULT_VERSION
       ns.compiler!     'org.scala-lang:scala-compiler:jar:>=' + DEFAULT_VERSION
     end
-    
+
     class << self
       def scala_home
         env_home = ENV['SCALA_HOME']
-        
+
         @home ||= (if !env_home.nil? && File.exists?(env_home + '/lib/scala-library.jar') && File.exists?(env_home + '/lib/scala-compiler.jar')
           env_home
         else
           nil
         end)
       end
-      
+
       def installed?
         !scala_home.nil?
       end
@@ -99,21 +99,22 @@
       def use_fsc
         installed? && ENV["USE_FSC"] =~ /^(yes|on|true)$/i
       end
-      
+
       def applies_to?(project, task) #:nodoc:
         paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
         paths.flatten!
-        
+
         # Just select if we find .scala files
         paths.any? { |path| !Dir["#{path}/**/*.scala"].empty? }
       end
     end
-    
+
     Javac = Buildr::Compiler::Javac
 
     OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other, :javac]
-    
-    Java.classpath << dependencies
+
+    # Lazy evaluation to allow change in buildfile
+    Java.classpath << lambda { dependencies }
 
     specify :language=>:scala, :sources => [:scala, :java], :source_ext => [:scala, :java],
             :target=>'classes', :target_ext=>'class', :packaging=>:jar
@@ -125,7 +126,7 @@
       options[:deprecation] ||= false
       options[:optimise] ||= false
       options[:javac] ||= {}
-      
+
       @java = Javac.new(project, options[:javac])
     end
 
@@ -133,7 +134,7 @@
       check_options options, OPTIONS
 
       cmd_args = []
-      cmd_args << '-classpath' << (dependencies + Scalac.dependencies).join(File::PATH_SEPARATOR)
+      cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR)
       source_paths = sources.select { |source| File.directory?(source) }
       cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
       cmd_args << '-d' << File.expand_path(target)
@@ -142,7 +143,7 @@
 
       unless Buildr.application.options.dryrun
         trace((['scalac'] + cmd_args).join(' '))
-        
+
         if Scalac.use_fsc
           system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' ')) or
             fail 'Failed to compile, see errors above'
@@ -151,15 +152,15 @@
           begin
             Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
           rescue => e
-            fail "Scala compiler crashed:\n#{e.inspect}" 
+            fail "Scala compiler crashed:\n#{e.inspect}"
           end
           fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
         end
- 
+
         java_sources = java_sources(sources)
         unless java_sources.empty?
           trace 'Compiling mixed Java/Scala sources'
-          
+
           # TODO  includes scala-compiler.jar
           deps = dependencies + Scalac.dependencies + [ File.expand_path(target) ]
           @java.compile(java_sources, target, deps)
@@ -187,7 +188,7 @@
     end
 
   end
-    
+
 end
 
 # Scala compiler comes first, ahead of Javac, this allows it to pick