Author: vborja
Date: Wed Feb 27 16:41:29 2008
New Revision: 631791

URL: http://svn.apache.org/viewvc?rev=631791&view=rev
Log:
Make sure required gems are installed when user wants to run or compile from 
source distribution.

Modified:
    incubator/buildr/trunk/Rakefile
    incubator/buildr/trunk/buildfile

Modified: incubator/buildr/trunk/Rakefile
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=631791&r1=631790&r2=631791&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Wed Feb 27 16:41:29 2008
@@ -45,9 +45,15 @@
 end
 
 
+ruby_spec = specify(Gem::Platform::RUBY)
+ruby_package = Rake::GemPackageTask.new(ruby_spec) { |pkg| pkg.need_tar = 
pkg.need_zip = true }
+
+jruby_spec = specify('java')
+jruby_package = Rake::GemPackageTask.new(jruby_spec) { |pkg| pkg.need_tar = 
pkg.need_zip = false }
+
 # Packaging and local installation.
 #
-task 'compile' do
+task 'compile' => 'install-dependencies' do
   say 'Compiling Java libraries ... '
   cmd = [ RUBY_PLATFORM =~ /java/ ? 'jruby' : 'ruby' ] <<
     '-I' << File.join(File.dirname(__FILE__), 'lib') <<
@@ -58,11 +64,16 @@
 end
 task 'package'=>'compile'
 
-ruby_spec = specify(Gem::Platform::RUBY)
-ruby_package = Rake::GemPackageTask.new(ruby_spec) { |pkg| pkg.need_tar = 
pkg.need_zip = true }
-
-jruby_spec = specify('java')
-jruby_package = Rake::GemPackageTask.new(jruby_spec) { |pkg| pkg.need_tar = 
pkg.need_zip = false }
+task 'install-dependencies' do
+  gems = Gem::SourceIndex.from_installed_gems
+  specify(RUBY_PLATFORM).dependencies.each do |dep|
+    if gems.search(dep).empty?
+      puts "Installing gem: #{dep}"
+      require 'rubygems/dependency_installer'
+      Gem::DependencyInstaller.new(dep.name, dep.version_requirements).install
+    end
+  end
+end
 
 task('clobber') { rm_rf 'pkg' }
 desc 'Install the package locally'
@@ -201,9 +212,16 @@
 
 
 namespace 'release' do
-  require 'highline'
-  require 'highline/import'
-  Kernel.def_delegators :$terminal, :color
+  
+  begin 
+    require 'highline'
+    require 'highline/import'
+    Kernel.def_delegators :$terminal, :color
+  rescue LoadError 
+    unless ARGV.include? 'install-dependencies'
+      fail "Please install highline gem or run 'rake install-dependencies'"
+    end
+  end
 
   # This task does all prerequisites checks before starting the release, for 
example,
   # that we have Groovy and Scala to run all the test cases, or that we have 
Allison

Modified: incubator/buildr/trunk/buildfile
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/buildfile?rev=631791&r1=631790&r2=631791&view=diff
==============================================================================
--- incubator/buildr/trunk/buildfile (original)
+++ incubator/buildr/trunk/buildfile Wed Feb 27 16:41:29 2008
@@ -4,7 +4,7 @@
 
 options = :javac, { :source=>'1.4', :target=>'1.4', :debug=>false }
 define 'java' do
-  
compile.from(FileList['lib/java/**/*.java']).into('lib/java').using(*options).with(Buildr::JUnit::REQUIRES)
+  compile.from(FileList['lib/java/**/*.java']).into('lib/java').using(*options)
 end
 define 'buildr' do
   
compile.from(FileList['lib/buildr/**/*.java']).into('lib/buildr').using(*options).with(Buildr::Jetty::REQUIRES)


Reply via email to