Author: boisvert
Date: Tue Oct 12 01:11:54 2010
New Revision: 1021566

URL: http://svn.apache.org/viewvc?rev=1021566&view=rev
Log:
BUILDR-517 package(:jar).include(directory, :as=>"foo") produces a corrupted jar

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/packaging/archive.rb
    buildr/trunk/lib/buildr/packaging/ziptask.rb

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1021566&r1=1021565&r2=1021566&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Tue Oct 12 01:11:54 2010
@@ -1,13 +1,14 @@
 1.4.3 (Pending)
 * Added:  BUILDR-514 New 'run' local task. 
http://buildr.apache.org/more_stuff.html#run
-* Added:  BUILDR-518 Load _buildr.rb or .buildr.rb from same directory as 
Buildfile 
+* Added:  BUILDR-518 Load _buildr.rb or .buildr.rb from same directory as 
Buildfile
           if they exist (Peter Donald)
 * Added:  BUILDR-519 Load repositories.release_to from build settings (Peter 
Donald)
 * Fixed:  BUILDR-520 Scaladoc 2.8 no longer support -windowtitle, use 
-doc-title instead.
 * Fixed:  BUILDR-512 Buildr::Util.ruby invokes non existent method (Peter 
Donald)
-* Fixed:  BUILDR-513 --trace fails with NoMethodError : undefined method 
+* Fixed:  BUILDR-513 --trace fails with NoMethodError : undefined method
           `include?' for nil:NilClass
 * Fixed:  BUILDR-515 -update-snapshot doesn't work as expected
+* Fixed:  BUILDR-517 package(:jar).include(directory, :as=>"foo") produces a 
corrupted jar
 * Fixed:  BUILDR-525 Documentation refers to repositories.upload_to rather than
           repositories.release_to (Peter Donald)
 * Fixed:  BUILDR-526 Gracefully handle h2 sections with no id in documentation 
(Peter Donald)
@@ -58,10 +59,10 @@
 * Fixed:  BUILDR-482 Javadoc : cannot load class 
java.com.sun.tools.javadoc.Main
 * Fixed:  BUILDR-488 artifact poms not reinstalled
 * Fixed:  BUILDR-491 sftp download goes into infinite loop
-* Fixed:  BUILDR-498 Artifact download fails with "negative argument" if 
+* Fixed:  BUILDR-498 Artifact download fails with "negative argument" if
           terminal capabilities are undefined
-* Fixed:  BUILDR-499 Java package caching through constants 
-          e.g. (Java.java.lang.String cached as Java::Lang::String) 
+* Fixed:  BUILDR-499 Java package caching through constants
+          e.g. (Java.java.lang.String cached as Java::Lang::String)
           can shadow Ruby modules
 * Fixed:  BUILDR-501 Fix buildr label when listing tasks (Peter Donald)
 * Fixed:  BUILDR-503 Include with as includes directories as files when the 
directory has the same name as the path

Modified: buildr/trunk/lib/buildr/packaging/archive.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/archive.rb?rev=1021566&r1=1021565&r2=1021566&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/archive.rb (original)
+++ buildr/trunk/lib/buildr/packaging/archive.rb Tue Oct 12 01:11:54 2010
@@ -202,7 +202,7 @@ module Buildr
     end
 
     def include_as(source, as)
-        
+
         @sources << proc { source }
         @actions << proc do |file_map|
           file = source.to_s
@@ -212,19 +212,19 @@ module Buildr
                 path = rel_path.split('/')[1..-1]
                 path.unshift as unless as == '.'
                 dest = "#...@path}#{path.join('/')}"
-                unless excluded?(dest) 
+                unless excluded?(dest)
                   trace "Adding #{dest}"
                   file_map[dest] = file
                 end
               end
               unless as == "."
                 trace "Adding #...@path}#{as}/"
-                file_map["#...@path}#{as}/"] = file #as is a folder, so the 
trailing / is required.
+                file_map["#...@path}#{as}/"] = nil # :as is a folder, so the 
trailing / is required.
               end
             else
               file_map["#...@path}#{as}"] = file
             end
-            
+
           end
         end
       end

Modified: buildr/trunk/lib/buildr/packaging/ziptask.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/ziptask.rb?rev=1021566&r1=1021565&r2=1021566&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/ziptask.rb (original)
+++ buildr/trunk/lib/buildr/packaging/ziptask.rb Tue Oct 12 01:11:54 2010
@@ -61,7 +61,8 @@ module Buildr
         mkpath = lambda do |dir|
           unless dir == '.' || seen[dir]
             mkpath.call File.dirname(dir)
-            zip.put_next_entry(dir + '/', compression_level)
+            dirname = (dir[-1..-1] =~ /\/$/) ? dir : dir + '/'
+            zip.put_next_entry(dirname, compression_level)
             seen[dir] = true
           end
         end


Reply via email to