buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r928148 - in /buildr/trunk: CHANGELOG lib/buildr/packaging/archive.rb spec/packaging/archive_spec.rb
Date Sat, 27 Mar 2010 05:16:15 GMT
Author: boisvert
Date: Sat Mar 27 05:16:14 2010
New Revision: 928148

URL: http://svn.apache.org/viewvc?rev=928148&view=rev
Log:
BUILDR-409 archive.include() should convert arguments to artifact if applicable

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/packaging/archive.rb
    buildr/trunk/spec/packaging/archive_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=928148&r1=928147&r2=928148&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sat Mar 27 05:16:14 2010
@@ -27,8 +27,10 @@
 * Added:  BUILDR-375 Buildr now recognizes buildfile.rb and Buildfile.rb
           (Kerry Wilson)
 * Added:  BUILDR-390 Buildr::group() should accept :classifier argument
-* Added:  BUILDR-407: Exclude and include patterns should support lambdas or procs
-* Added:  BUILDR-408: Filter include() and exclude() should accept Rake tasks
+* Added:  BUILDR-407 Exclude and include patterns should support lambdas or procs
+* Added:  BUILDR-408 Filter include() and exclude() should accept Rake tasks
+* Added:  BUILDR-409 archive.include() should convert arguments to artifact
+          if applicable
 * Added:  ScalaTest now generates JUnit XML reports in addition to text files.
 * Change: Updated to Ant 1.8.0
 * Change: Updated to Groovy 1.7.1

Modified: buildr/trunk/lib/buildr/packaging/archive.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/archive.rb?rev=928148&r1=928147&r2=928148&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/archive.rb (original)
+++ buildr/trunk/lib/buildr/packaging/archive.rb Sat Mar 27 05:16:14 2010
@@ -61,7 +61,7 @@ module Buildr
       #   include(*files, :merge=>true) => self
       def include(*args)
         options = args.pop if Hash === args.last
-        files = args.flatten
+        files = to_artifacts(args)
         raise 'AchiveTask.include() values should not include nil' if files.include? nil
 
         if options.nil? || options.empty?
@@ -92,7 +92,7 @@ module Buildr
       # :call-seq:
       #   exclude(*files) => self
       def exclude(*files)
-        files = files.flatten.map(&:to_s)
+        files = to_artifacts(files)
         @excludes |= files
         @excludes |= files.reject { |f| f =~ /\*$/ }.map { |f| "#{f}/*" }
         self
@@ -103,7 +103,7 @@ module Buildr
       #   merge(*files, :path=>name) => Merge
       def merge(*args)
         options = Hash === args.last ? args.pop : {}
-        files = args.flatten
+        files = to_artifacts(args)
         rake_check_options options, :path
         raise ArgumentError, "Expected at least one file to merge" if files.empty?
         path = options[:path] || @path
@@ -174,6 +174,30 @@ module Buildr
 
     protected
 
+    # Convert objects to artifacts, where applicable
+    def to_artifacts(files)
+      files.flatten.inject([]) do |set, file|
+        case file
+        when ArtifactNamespace
+          set |= file.artifacts
+        when Symbol, Hash
+          set |= [artifact(file)]
+        when /([^:]+:){2,4}/ # A spec as opposed to a file name.
+          set |= [Buildr.artifact(file)]
+        when Project
+          set |= Buildr.artifacts(file.packages)
+        when Rake::Task
+          set |= [file]
+        when Struct
+          set |= Buildr.artifacts(file.values)
+        else
+          # non-artifacts passed as-is; in particular, String paths are
+          # unmodified since Rake FileTasks don't use absolute paths
+          set |= [file]
+        end
+      end
+    end
+
     def include_as(source, as)
         @sources << proc { source }
         @actions << proc do |file_map|

Modified: buildr/trunk/spec/packaging/archive_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/archive_spec.rb?rev=928148&r1=928147&r2=928148&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/archive_spec.rb (original)
+++ buildr/trunk/spec/packaging/archive_spec.rb Sat Mar 27 05:16:14 2010
@@ -88,6 +88,22 @@ describe 'ArchiveTask', :shared=>true do
     inspect_archive.keys.should include('included')
   end
 
+  it 'should archive artifacts' do
+    write 'library-1.0.txt', 'library-1.0'
+    artifact("org.example:library:txt:1.0").from 'library-1.0.txt'
+    archive(@archive).include("org.example:library:txt:1.0").invoke
+    inspect_archive.keys.should include('library-1.0.txt')
+  end
+
+  it 'should archive project artifacts' do
+    define 'p1' do
+      project.version = '1.0'
+      package(:zip)
+    end
+    archive(@archive).include(project('p1')).invoke
+    inspect_archive.keys.should include('p1-1.0.zip')
+  end
+
   it 'should include entry for directory' do
     archive(@archive).include(@dir).invoke
     inspect_archive { |archive| @files.each { |f| archive['test/' + File.basename(f)].should
eql(content_for(f)) } }



Mime
View raw message