# File lib/buildr/packaging/ziptask.rb, line 144
    def extract
      # If no paths specified, then no include/exclude patterns
      # specified. Nothing will happen unless we include all files.
      if @paths.empty?
        @paths[nil] = FromPath.new(self, nil)
      end

      # Otherwise, empty unzip creates target as a file when touching.
      mkpath target.to_s
      if zip_file.to_s.match /\.t?gz$/
        #un-tar.gz
        Zlib::GzipReader.open(zip_file.to_s) { |tar|
          Archive::Tar::Minitar::Input.open(tar) do |inp|
            inp.each do |tar_entry|
              @paths.each do |path, patterns|
                patterns.map([tar_entry]).each do |dest, entry|
                  next if entry.directory?
                  dest = File.expand_path(dest, target.to_s)
                  trace "Extracting #{dest}"
                  mkpath File.dirname(dest) rescue nil
                  #entry.restore_permissions = true
                  File.open(dest, 'wb') {|f| f.write entry.read}
                end
              end
            end
          end
        }
      else
        Zip::ZipFile.open(zip_file.to_s) do |zip|
          entries = zip.collect
          @paths.each do |path, patterns|
            patterns.map(entries).each do |dest, entry|
              next if entry.directory?
              dest = File.expand_path(dest, target.to_s)
              trace "Extracting #{dest}"
              mkpath File.dirname(dest) rescue nil
              entry.restore_permissions = true
              entry.extract(dest) { true }
            end
          end
        end
      end
      # Let other tasks know we updated the target directory.
      touch target.to_s
    end