You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2008/01/29 07:47:14 UTC

svn commit: r616185 - in /incubator/buildr/trunk: lib/core/compile.rb lib/java/compilers.rb spec/java_compilers.rb

Author: assaf
Date: Mon Jan 28 22:47:14 2008
New Revision: 616185

URL: http://svn.apache.org/viewvc?rev=616185&view=rev
Log:
Nicer handling of Scalac dependencies

Modified:
    incubator/buildr/trunk/lib/core/compile.rb
    incubator/buildr/trunk/lib/java/compilers.rb
    incubator/buildr/trunk/spec/java_compilers.rb

Modified: incubator/buildr/trunk/lib/core/compile.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/compile.rb?rev=616185&r1=616184&r2=616185&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/core/compile.rb Mon Jan 28 22:47:14 2008
@@ -81,7 +81,7 @@
         # test framework picks on these, you can use the JUnit framework with Scala.
         # Defaults to obtaining a list of artifact specifications from the REQUIRES constant.
         def dependencies
-          @dependencies ||= FileList[*(const_get('REQUIRES') rescue [])]
+          []
         end
 
       end
@@ -333,7 +333,7 @@
       from Array(cls.sources).map { |path| @project.path_to(:source, @usage, path) }.
         select { |path| File.exist?(path) } if sources.empty?
       into @project.path_to(:target, @usage, cls.target) unless target
-      with @compiler.dependencies
+      with Array(@compiler.dependencies)
       self
     end
 

Modified: incubator/buildr/trunk/lib/java/compilers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/compilers.rb?rev=616185&r1=616184&r2=616185&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/compilers.rb (original)
+++ incubator/buildr/trunk/lib/java/compilers.rb Mon Jan 28 22:47:14 2008
@@ -38,8 +38,8 @@
       def compile(sources, target, dependencies) #:nodoc:
         check_options options, OPTIONS
         cmd_args = []
-        tools = File.expand_path('lib/tools.jar', ENV['JAVA_HOME']) if ENV['JAVA_HOME']
-        dependencies << tools if tools && File.exist?(tools)
+        #tools = File.expand_path('lib/tools.jar', ENV['JAVA_HOME']) if ENV['JAVA_HOME']
+        #dependencies << tools if tools && File.exist?(tools)
         cmd_args << '-cp' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
         source_paths = sources.select { |source| File.directory?(source) }
         cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
@@ -91,13 +91,11 @@
     class Scalac < Base
       class << self
         def scala_home
-          home = ENV['SCALA_HOME'] or fail 'Missing SCALA_HOME environment variable'
-          fail 'Invalid SCALA_HOME environment variable' unless File.directory?(home)
-          home
+          @home ||= ENV['SCALA_HOME']
         end
 
         def dependencies
-          FileList["#{scala_home}/lib/*.jar"]
+          FileList[scala_home && "#{scala_home}/lib/*.jar"].compact
         end
 
         def use_fsc
@@ -106,7 +104,7 @@
       end
 
       OPTIONS = [:warnings, :deprecation, :optimise, :source, :target, :debug, :other]
-      Java.classpath << dependencies if ENV['SCALA_HOME']
+      Java.classpath << dependencies unless use_fsc
 
       specify :language=>:scala, :target=>'classes', :target_ext=>'class', :packaging=>:jar
 
@@ -130,6 +128,7 @@
         cmd_args += files_from_sources(sources)
 
         unless Rake.application.options.dryrun
+          Scalac.scala_home or fail 'Are we forgetting something? SCALA_HOME not set.'
           puts (['scalac'] + cmd_args).join(' ') if Rake.application.options.trace
           if Scalac.use_fsc
             system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' '))

Modified: incubator/buildr/trunk/spec/java_compilers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java_compilers.rb?rev=616185&r1=616184&r2=616185&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/java_compilers.rb (original)
+++ incubator/buildr/trunk/spec/java_compilers.rb Mon Jan 28 22:47:14 2008
@@ -41,6 +41,15 @@
     define('foo').compile.from('src/test').with(project('dependency')).invoke
     file('target/classes/DependencyTest.class').should exist
   end
+
+  it 'should include tools.jar dependency' do
+    write 'src/main/java/UseApt.java', <<-JAVA
+      import com.sun.mirror.apt.AnnotationProcessor;
+      public class UseApt { }
+    JAVA
+    define('foo').compile.invoke
+    file('target/classes/UseApt.class').should exist
+  end
 end