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/04/09 20:15:44 UTC

svn commit: r646458 - in /incubator/buildr/trunk: CHANGELOG Rakefile lib/buildr/java/packaging.rb lib/buildr/packaging/gems.rb rakelib/setup.rake

Author: assaf
Date: Wed Apr  9 11:15:40 2008
New Revision: 646458

URL: http://svn.apache.org/viewvc?rev=646458&view=rev
Log:
In theory, rake setup should now install any version or RJB but 1.1.3, which is broken on Windows.


Modified:
    incubator/buildr/trunk/CHANGELOG
    incubator/buildr/trunk/Rakefile
    incubator/buildr/trunk/lib/buildr/java/packaging.rb
    incubator/buildr/trunk/lib/buildr/packaging/gems.rb
    incubator/buildr/trunk/rakelib/setup.rake

Modified: incubator/buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/CHANGELOG?rev=646458&r1=646457&r2=646458&view=diff
==============================================================================
--- incubator/buildr/trunk/CHANGELOG (original)
+++ incubator/buildr/trunk/CHANGELOG Wed Apr  9 11:15:40 2008
@@ -23,9 +23,9 @@
 JavaWrapper.
 * Added: JRuby 1.1 support (Victor Hugo Borja, Nick Sieger).
 * Added: IDEA 7 task: use buildr idea7x (Shane Witbeck).
-* Added: Experimental support for addons.
-* Added: Experimental support for YAML configurtion files settings.yaml (in
-~/.buildr), build.yaml (next to buildfile) and profiles.yaml.
+* Added: Experimental support for installing/loading Gems as part of a build.
+* Added: Experimental support for YAML configurtion files:
+~/.buildr/settings.yaml, build.yaml and profiles.yaml.
 * Added: Ability to create a package that is not an artifact and specify the
 target file using the :file argument.
 * Changed: JUnit/TestNG test cases are selected by superClass or annotations,

Modified: incubator/buildr/trunk/Rakefile
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=646458&r1=646457&r2=646458&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Wed Apr  9 11:15:40 2008
@@ -51,7 +51,9 @@
     spec.add_dependency 'xml-simple',           '~> 1.0'
     spec.add_dependency 'archive-tar-minitar',  '~> 0.5'
     spec.add_dependency 'rubyforge',            '~> 0.4'
-    spec.add_dependency 'rjb',                  '~> 1.1' unless platform =~ /java/
+    unless platform =~ /java/
+      spec.add_dependency 'rjb',                  '~> 1.1', '!= 1.1.3'
+    end
   end
 end
 

Modified: incubator/buildr/trunk/lib/buildr/java/packaging.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/packaging.rb?rev=646458&r1=646457&r2=646458&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/packaging.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/packaging.rb Wed Apr  9 11:15:40 2008
@@ -31,6 +31,10 @@
 
         class << self
 
+          # :call_seq:
+          #   parse(str) => manifest
+          #
+          # Parse a string in MANIFEST.MF format and return a new Manifest.
           def parse(str)
             sections = str.split(SECTION_SEPARATOR).reject { |s| s.strip.empty? }
             new sections.map { |section|
@@ -47,6 +51,10 @@
             }
           end
 
+          # :call_seq:
+          #   from_zip(file) => manifest
+          #
+          # Parse the MANIFEST.MF entry of a ZIP (or JAR) file and return a new Manifest.
           def from_zip(file)
             Zip::ZipFile.open(file.to_s) do |zip|
               return Manifest.new unless zip.get_entry('META-INF/MANIFEST.MF')
@@ -54,7 +62,12 @@
             end
           end
 
-          # update_manifest(file) { |manifest| ... }
+          # :call_seq:
+          #   update_manifest(file) { |manifest| ... }
+          #
+          # Updates the MANIFEST.MF entry of a ZIP (or JAR) file.  Reads the MANIFEST.MF,
+          # yields to the block with the Manifest object, and writes the modified object
+          # back to the file.
           def update_manifest(file)
             manifest = from_zip(file)
             result = yield manifest
@@ -69,29 +82,39 @@
 
         end
 
+        # Returns a new Manifest object based on the argument:
+        # * nil         -- Empty Manifest.
+        # * Hash        -- Manifest with main section using the hash name/value pairs.
+        # * Array       -- Manifest with one section from each entry (must be hashes).
+        # * String      -- Parse (see Manifest#parse).
+        # * Proc/Method -- New Manifest from result of calling proc/method.
         def initialize(arg = nil)
           case arg
           when nil, Hash then @sections = [arg || {}]
           when Array then @sections = arg
           when String then @sections = Manifest.parse(arg).sections
-          when Proc, Method then @sections = Manifest.parse(arg.call).sections
+          when Proc, Method then @sections = Manifest.new(arg.call).sections
           else
             fail 'Invalid manifest, expecting Hash, Array, file name/task or proc/method.'
           end
         end
 
+        # The sections of this manifest.
         attr_reader :sections
 
+        # The main (first) section of this manifest.
         def main
           sections.first
         end
 
         include Enumerable
 
+        # Iterate over each section and yield to block.
         def each(&block)
           @sections.each(&block)
         end
 
+        # Convert to MANIFEST.MF format.
         def to_s
           @sections.map { |section|
             keys = section.keys

Modified: incubator/buildr/trunk/lib/buildr/packaging/gems.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/packaging/gems.rb?rev=646458&r1=646457&r2=646458&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/packaging/gems.rb (original)
+++ incubator/buildr/trunk/lib/buildr/packaging/gems.rb Wed Apr  9 11:15:40 2008
@@ -17,6 +17,7 @@
 require 'buildr/packaging/package'
 require 'buildr/packaging/zip'
 require 'rubyforge'
+require 'rubygems/package'
 
 
 module Buildr
@@ -26,8 +27,13 @@
     def initialize(*args)
       super
       @spec = Gem::Specification.new
+      prepare do
+        include(changelog) if changelog
+      end
     end
 
+    attr_accessor :changelog
+
     def spec
       yield @spec if block_given?
       @spec
@@ -44,8 +50,7 @@
     def upload
       rubyforge = RubyForge.new
       rubyforge.login
-      #File.open('.changes', 'w'){|f| f.write(current)}
-      #rubyforge.userconfig.merge!('release_changes' => '.changes',  'preformatted' => true)
+      rubyforge.userconfig.merge!('release_changes'=>changelog.to_s, 'preformatted'=>true) if changelog
       rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, package(:gem).to_s
     end
 
@@ -54,20 +59,19 @@
     def create_from(file_map)
       spec.mark_version
       spec.validate
-      Gem::Package.open(name, 'w', signer) do |pkg|
+      Gem::Package.open(name, 'w', nil) do |pkg|
         pkg.metadata = spec.to_yaml
         file_map.each do |path, content|
           next if content.nil? || File.directory?(content.to_s)
           pkg.add_file_simple(path, File.stat(name).mode & 0777, File.size(content.to_s)) do |os|
-              os.write File.open(content.to_s, 'rb') { |f| f.read }
+            File.open(content.to_s, "rb") do |file|
+              os.write file.read(4096)  until file.eof?
+            end
           end
         end
       end
     end
 
-    def signer
-      # TODO: implement.
-    end
   end
 
 

Modified: incubator/buildr/trunk/rakelib/setup.rake
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/setup.rake?rev=646458&r1=646457&r2=646458&view=diff
==============================================================================
--- incubator/buildr/trunk/rakelib/setup.rake (original)
+++ incubator/buildr/trunk/rakelib/setup.rake Wed Apr  9 11:15:40 2008
@@ -16,6 +16,9 @@
 # which returns true if running on the Windows platform of MRI, false when using JRuby.
 
 
+require 'rubygems/source_info_cache'
+
+
 def windows?
   Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
 end
@@ -35,11 +38,12 @@
 
 def install_gem(name, ver_requirement = nil)
   dep = Gem::Dependency.new(name, ver_requirement)
-  if Gem::SourceIndex.from_installed_gems.search(dep).empty? 
-    puts "Installing #{name} #{ver_requirement} ..."
-    args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', name]
+  if Gem::SourceIndex.from_installed_gems.search(dep).empty?
+    spec = Gem::SourceInfoCache.search(dep).last
+    fail "#{dep} not found in local or remote repository!" unless spec
+    puts "Installing #{spec} ..."
+    args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', spec.name, '-v', spec.version.to_s]
     args.unshift('sudo') unless windows?
-    args << '-v' << ver_requirement.to_s if ver_requirement
     sh *args
   end
 end