From a607a6e82d528d20a7555645e2672276f94762f1 Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Thu, 6 May 2010 10:07:51 -0500 Subject: [PATCH] Don't overwrite existing manifest --- lib/warbler/war.rb | 10 ++++++---- spec/warbler/war_spec.rb | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/warbler/war.rb b/lib/warbler/war.rb index af031946..5b42004e 100644 --- a/lib/warbler/war.rb +++ b/lib/warbler/war.rb @@ -57,10 +57,12 @@ def add_webxml(config) # Add a manifest file either from config or by making a default manifest. def add_manifest(config) - if config.manifest_file - @files['META-INF/MANIFEST.MF'] = config.manifest_file - else - @files['META-INF/MANIFEST.MF'] = StringIO.new(%{Manifest-Version: 1.0\nCreated-By: Warbler #{VERSION}\n\n}) + unless @files.keys.detect{|k| k =~ /^META-INF\/MANIFEST\.MF$/i} + if config.manifest_file + @files['META-INF/MANIFEST.MF'] = config.manifest_file + else + @files['META-INF/MANIFEST.MF'] = StringIO.new(%{Manifest-Version: 1.0\nCreated-By: Warbler #{VERSION}\n\n}) + end end end diff --git a/spec/warbler/war_spec.rb b/spec/warbler/war_spec.rb index 951415bb..a1eda926 100644 --- a/spec/warbler/war_spec.rb +++ b/spec/warbler/war_spec.rb @@ -158,6 +158,12 @@ def expand_webxml @war.files['META-INF/MANIFEST.MF'].should == "manifest" end + it "should not add a manifest if one already exists" do + @war.files['META-INF/MANIFEST.MF'] = 'manifest' + @war.add_manifest(@config) + @war.files['META-INF/MANIFEST.MF'].should == "manifest" + end + it "should be able to exclude files from the .war" do @config.excludes += FileList['lib/tasks/utils.rake'] @war.apply(@config)