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/17 02:50:58 UTC
svn commit: r612678 - in /incubator/buildr/trunk: lib/ lib/core/ lib/java/
spec/
Author: assaf
Date: Wed Jan 16 17:50:55 2008
New Revision: 612678
URL: http://svn.apache.org/viewvc?rev=612678&view=rev
Log:
Now down to 8 failing tests with JRuby
Modified:
incubator/buildr/trunk/lib/buildr.rb
incubator/buildr/trunk/lib/core/compile.rb
incubator/buildr/trunk/lib/core/test.rb
incubator/buildr/trunk/lib/java/compilers.rb
incubator/buildr/trunk/lib/java/java.rb
incubator/buildr/trunk/lib/java/jruby.rb
incubator/buildr/trunk/lib/java/rjb.rb
incubator/buildr/trunk/lib/java/test_frameworks.rb
incubator/buildr/trunk/spec/archive_spec.rb
incubator/buildr/trunk/spec/common_spec.rb
incubator/buildr/trunk/spec/compile_spec.rb
Modified: incubator/buildr/trunk/lib/buildr.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr.rb (original)
+++ incubator/buildr/trunk/lib/buildr.rb Wed Jan 16 17:50:55 2008
@@ -23,10 +23,10 @@
VERSION = '1.3.0'.freeze # unless const_defined?(:VERSION)
end
-require 'core'
-require 'tasks'
-require 'java'
-require 'ide'
+require File.join(File.dirname(__FILE__), 'core')
+require File.join(File.dirname(__FILE__), 'tasks')
+require File.join(File.dirname(__FILE__), 'java')
+require File.join(File.dirname(__FILE__), 'ide')
# Methods defined in Buildr are both instance methods (e.g. when included in Project)
Modified: incubator/buildr/trunk/lib/core/compile.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/compile.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/core/compile.rb Wed Jan 16 17:50:55 2008
@@ -122,7 +122,7 @@
# Expands a list of source directories/files into a list of files that have the #source_ext extension.
def files_from_sources(sources)
sources.map { |source| File.directory?(source) ? FileList["#{source}/**/*.#{self.class.source_ext}"] : source }.
- flatten.reject { |file| File.directory?(file) }.uniq
+ flatten.reject { |file| File.directory?(file) }.map { |file| File.expand_path(file) }.uniq
end
# The compile map is a hash that associates source files with target files based
@@ -312,8 +312,9 @@
# Selects which compiler to use.
def compiler=(name) #:nodoc:
- raise "#{compiler} compiler already selected for this project" if @compiler
cls = Compiler.select(name) or raise ArgumentError, "No #{name} compiler available. Did you install it?"
+ return self if cls === @compiler
+ raise "#{compiler} compiler already selected for this project" if @compiler
@compiler = cls.new(options)
from Array(cls.sources).map { |path| @project.path_to(:source, @usage, path) }.
select { |path| File.exist?(path) } if sources.empty?
Modified: incubator/buildr/trunk/lib/core/test.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/test.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/test.rb (original)
+++ incubator/buildr/trunk/lib/core/test.rb Wed Jan 16 17:50:55 2008
@@ -155,7 +155,7 @@
tests = tests.map { |name| name =~ /\*/ ? name : "*#{name}*" }
# Since the tests may reside in a sub-project, we need to set the include/exclude pattern on
# all sub-projects, but only invoke test on the local project.
- Project.projects.each { |project| project.test.instance_eval { @include = tests ; @exclude.clear } }
+ Project.projects.each { |project| project.test.send :only_run, tests }
end
end
@@ -418,6 +418,12 @@
end
end
+ # Limit running tests to specific list.
+ def only_run(tests)
+ @include = Array(tests)
+ @exclude.clear
+ end
+
end
@@ -499,7 +505,8 @@
# Similar to test:[pattern] but for integration tests.
rule /^integration:.*$/ do |task|
unless task.name.split(':')[1] =~ /^(setup|teardown)$/
- TestTask.only_run task.name.scan(/integration:(.*)/)[0][0].split(',')
+ # The map works around a JRuby bug whereby the string looks fine, but fails in fnmatch.
+ TestTask.only_run task.name[/integration:(.*)/, 1].split(',').map { |t| "#{t}" }
task('integration').invoke
end
end
Modified: incubator/buildr/trunk/lib/java/compilers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/compilers.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/compilers.rb (original)
+++ incubator/buildr/trunk/lib/java/compilers.rb Wed Jan 16 17:50:55 2008
@@ -41,14 +41,14 @@
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?
- cmd_args << '-d' << target
+ cmd_args << '-d' << File.expand_path(target)
cmd_args += javac_args
cmd_args += files_from_sources(sources)
unless Rake.application.options.dryrun
puts (['javac'] + cmd_args).join(' ') if Rake.application.options.trace
- #cmd_args = cmd_args.to_java_array(::Java.java.lang.String) if Java.jruby?
Java.load
- Java.com.sun.tools.javac.Main.compile(cmd_args.map(&:to_s)) == 0 or fail 'Failed to compile, see errors above'
+ Java.com.sun.tools.javac.Main.compile(cmd_args.to_java(Java.java.lang.String)) == 0 or
+ fail 'Failed to compile, see errors above'
end
end
@@ -256,8 +256,7 @@
puts "Generating Javadoc for #{name}" if verbose
puts (['javadoc'] + cmd_args).join(' ') if Rake.application.options.trace
Java.load
- #cmd_args = cmd_args.to_java_array(::Java.java.lang.String) if Java.jruby?
- Java.com.sun.tools.javadoc.Main.execute(cmd_args.map(&:to_s)) == 0 or
+ Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or
fail 'Failed to generate Javadocs, see errors above'
end
end
@@ -328,8 +327,7 @@
unless Rake.application.options.dryrun
puts 'Running apt' if verbose
puts (['apt'] + cmd_args).join(' ') if Rake.application.options.trace
- #cmd_args = cmd_args.to_java_array(Java.java.lang.String) if Java.jruby?
- Java.com.sun.tools.apt.Main.process(cmd_args.map(&:to_s)) == 0 or
+ Java.com.sun.tools.apt.Main.process(cmd_args.to_java(Java.java.lang.String)) == 0 or
fail 'Failed to process annotations, see errors above'
end
end
Modified: incubator/buildr/trunk/lib/java/java.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/java.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/java.rb (original)
+++ incubator/buildr/trunk/lib/java/java.rb Wed Jan 16 17:50:55 2008
@@ -80,8 +80,7 @@
unless Rake.application.options.dryrun
puts 'Running apt' if verbose
puts (['apt'] + cmd_args).join(' ') if Rake.application.options.trace
- #cmd_args = cmd_args.to_java_array(Java.java.lang.String) if Java.jruby?
- Java.com.sun.tools.apt.Main.process(cmd_args.map(&:to_s)) == 0 or
+ Java.com.sun.tools.apt.Main.process(cmd_args.to_java(Java.java.lang.String)) == 0 or
fail 'Failed to process annotations, see errors above'
end
end
@@ -116,8 +115,7 @@
unless Rake.application.options.dryrun
puts "Compiling #{files.size} source files in #{name}" if verbose
puts (['javac'] + cmd_args).join(' ') if Rake.application.options.trace
- #cmd_args = cmd_args.to_java_array(Java.java.lang.String) if Java.jruby?
- Java.com.sun.tools.javac.Main.compile(cmd_args.map(&:to_s)) == 0 or
+ Java.com.sun.tools.javac.Main.compile(cmd_args.to_java(Java.java.lang.String)) == 0 or
fail 'Failed to compile, see errors above'
end
end
@@ -167,8 +165,7 @@
puts "Generating Javadoc for #{name}" if verbose
puts (['javadoc'] + cmd_args).join(' ') if Rake.application.options.trace
Java.load
- cmd_args = cmd_args.to_java_array(Java.java.lang.String) if Java.jruby?
- Java.com.sun.tools.javadoc.Main.execute(cmd_args.map(&:to_s)) == 0 or
+ Java.com.sun.tools.javadoc.Main.execute(cmd_args.to_java(Java.java.lang.String)) == 0 or
fail 'Failed to generate Javadocs, see errors above'
end
end
Modified: incubator/buildr/trunk/lib/java/jruby.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/jruby.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/jruby.rb (original)
+++ incubator/buildr/trunk/lib/java/jruby.rb Wed Jan 16 17:50:55 2008
@@ -56,21 +56,77 @@
# used in the build, giving the Buildfile a chance to load all extensions
# that append to the classpath and specify which remote repositories to use.
def load
- return self unless @loaded
+ return self if @loaded
cp = Buildr.artifacts(classpath).map(&:to_s).each { |path| file(path).invoke }
- $LOAD_PATH.concat cp
+ cp.each do |lib|
+ if File.file?(lib)
+ require lib # JRuby can load jars in runtime
+ else
+ $CLASSPATH << lib
+ end
+ end
+ load_java_tools
+ @loaded = true
self
end
+ def load_java_tools
+ unless RUBY_PLATFORM =~ /darwin/i
+ home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'
+ tools = File.expand_path('lib/tools.jar', home)
+ raise "Missing #{tools}, perhaps your JAVA_HOME is not correclty set" unless File.file?(tools)
+ require tools
+ end
+
+ str_args = lambda do |obj, method_name|
+ (class << obj; self; end).module_eval <<-RUBY
+ alias_method :#{method_name}_native, :#{method_name}
+ def #{method_name}(args)
+ #{method_name}_native(args.to_java(java.lang.String))
+ end
+ RUBY
+ end
+ #str_args.call(com.sun.tools.javac.Main, :compile)
+ #str_args.call(com.sun.tools.javadoc.Main, :execute)
+ #str_args.call(com.sun.tools.apt.Main, :process)
+ com.sun.tools.doclets.standard.Standard.new # just load the class
+ end
+
end
end
-# Convert a RubyArray to a Java Object[] array of the specified element_type
-class Array #:nodoc:
- def to_java_array(element_type)
- java_array = ::Java.java.lang.reflect.Array.newInstance(element_type, self.size)
- self.each_index { |i| java_array[i] = self[i] }
- return java_array
+
+module FileUtils
+ def touch(list, options = {})
+ fu_check_options options, OPT_TABLE['touch']
+ list = fu_list(list)
+ created = nocreate = options[:nocreate]
+ t = options[:mtime]
+ if options[:verbose]
+ fu_output_message "touch #{nocreate ? ' -c' : ''}#{t ? t.strftime(' -t %Y%m%d%H%M.%S') : ''}#{list.join ' '}"
+ end
+ t ||= Time.now # Otherwise JRuby breaks, and not in a nice way.
+ return if options[:noop]
+ list.each do |path|
+ created = nocreate
+ begin
+ File.utime(t, t, path)
+ rescue Errno::ENOENT
+ raise if created
+ File.open(path, 'a') {
+ ;
+ }
+ created = true
+ retry if t
+ end
+ end
end
+ module_function :touch
+end
+
+
+# Misnamed in RC1.
+class IO #:nodoc:
+ alias :isatty :isatty?
end
Modified: incubator/buildr/trunk/lib/java/rjb.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/rjb.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/rjb.rb (original)
+++ incubator/buildr/trunk/lib/java/rjb.rb Wed Jan 16 17:50:55 2008
@@ -72,7 +72,7 @@
# used in the build, giving the Buildfile a chance to load all extensions
# that append to the classpath and specify which remote repositories to use.
def load
- return self unless @loaded
+ return self if @loaded
unless RUBY_PLATFORM =~ /darwin/i
home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'
tools = File.expand_path('lib/tools.jar', home)
@@ -113,4 +113,12 @@
end
+end
+
+
+class Array
+ # JRuby requires casting an array, so we fake it.
+ def to_java(cls)
+ map { |item| cls.new(item) }
+ end
end
Modified: incubator/buildr/trunk/lib/java/test_frameworks.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/test_frameworks.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/test_frameworks.rb (original)
+++ incubator/buildr/trunk/lib/java/test_frameworks.rb Wed Jan 16 17:50:55 2008
@@ -115,8 +115,9 @@
map { |file| Pathname.new(file).relative_path_from(target).to_s.ext('').gsub(File::SEPARATOR, '.') }.
reject { |name| name =~ /\$/ }
classpath = [target.to_s + '/'] + Buildr.artifacts(dependencies).map(&:to_s)
- Java.load
- Java.org.apache.buildr.JUnitTestFilter.new(classpath).filter(candidates)
+ Java.load # JRuby necessiated casting.
+ Java.org.apache.buildr.JUnitTestFilter.new(classpath.map(&:to_s).to_java(Java.java.lang.String)).
+ filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
end
def run(tests, task, dependencies) #:nodoc:
Modified: incubator/buildr/trunk/spec/archive_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/archive_spec.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/archive_spec.rb (original)
+++ incubator/buildr/trunk/spec/archive_spec.rb Wed Jan 16 17:50:55 2008
@@ -325,10 +325,10 @@
it "should touch target directory" do
with_zip do
mkdir @target
- File.utime(Time.now - 100, Time.now - 100, @target)
+ File.utime(Time.now - 10, Time.now - 10, @target)
unzip(@target=>@zip).target.invoke
end
- File.stat(@target).mtime.should be_close(Time.now, 5)
+ File.stat(@target).mtime.should be_close(Time.now, 2)
end
it "should expand files" do
Modified: incubator/buildr/trunk/spec/common_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/common_spec.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/common_spec.rb (original)
+++ incubator/buildr/trunk/spec/common_spec.rb Wed Jan 16 17:50:55 2008
@@ -372,7 +372,7 @@
it 'should touch target directory' do
mkpath 'target' ; File.utime @early, @early, 'target'
@filter.from('src').into('target').run
- File.mtime('target').should be_close(Time.now, 10)
+ File.stat('target').mtime.should be_close(Time.now, 10)
end
it 'should not touch target directory unless running' do
@@ -413,7 +413,7 @@
Dir['target/*'].sort.each do |file|
File.readable?(file).should be_true
File.writable?(file).should be_true
- (File.stat(file).mode & 0x0fff).should be(0664)
+ (File.stat(file).mode & 0x0fff).should == 0664
end
end
end
Modified: incubator/buildr/trunk/spec/compile_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/compile_spec.rb?rev=612678&r1=612677&r2=612678&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/compile_spec.rb (original)
+++ incubator/buildr/trunk/spec/compile_spec.rb Wed Jan 16 17:50:55 2008
@@ -541,7 +541,7 @@
task.should be(project('foo').javadoc)
end
- it 'should respond to info() and change target directory' do
+ it 'should respond to into() and change target directory' do
define('foo') { javadoc.into('docs') }
project('foo').javadoc.should_receive(:invoke_prerequisites)
file('docs').invoke