lib/buildr/java/packaging.rb in vic-buildr-1.3.3 vs lib/buildr/java/packaging.rb in vic-buildr-1.3.4

- old
+ new

@@ -23,11 +23,11 @@ # Adds packaging for Java projects: JAR, WAR, AAR, EAR, Javadoc. module Java class Manifest - STANDARD_HEADER = "Manifest-Version: 1.0\nCreated-By: Buildr\n" + STANDARD_HEADER = { 'Manifest-Version'=>'1.0', 'Created-By'=>'Buildr' } LINE_SEPARATOR = /\r\n|\n|\r[^\n]/ #:nodoc: SECTION_SEPARATOR = /(#{LINE_SEPARATOR}){2}/ #:nodoc: class << self @@ -95,10 +95,14 @@ when String then @sections = Manifest.parse(arg).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 + # Add Manifest-Version and Created-By, if not specified. + STANDARD_HEADER.each do |name, value| + sections.first[name] ||= value + end end # The sections of this manifest. attr_reader :sections @@ -169,10 +173,10 @@ # Tempfiles gets deleted on garbage collection, so we're going to hold on to it # through instance variable not closure variable. @manifest_tmp = Tempfile.new('MANIFEST.MF') self.manifest = File.read(manifest.to_s) if String === manifest || Rake::Task === manifest self.manifest = Manifest.new(manifest) unless Manifest === manifest - @manifest_tmp.write Manifest::STANDARD_HEADER + #@manifest_tmp.write Manifest::STANDARD_HEADER @manifest_tmp.write manifest.to_s @manifest_tmp.write "\n" @manifest_tmp.rewind path('META-INF').include @manifest_tmp.path, :as=>'MANIFEST.MF' end