spec/eclipse/feature_spec.rb in buildr4osgi-0.9.0 vs spec/eclipse/feature_spec.rb in buildr4osgi-0.9.2

- old
+ new

@@ -141,11 +141,11 @@ Buildr::write "feature.xml", featurexml foo = define("foo", :version => "1.0.0") foo.package(:feature).feature_xml = "feature.xml" foo.package(:feature).invoke - feature_file = File.join(foo.base_dir, "target", "foo-1.0.0-feature.jar") + feature_file = File.join(foo.base_dir, "target", "foo-1.0.0.zip") Zip::ZipFile.open(feature_file) do |zip| zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil zip.read("eclipse/features/foo_1.0.0/feature.xml").should == featurexml zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should be_nil end @@ -162,11 +162,11 @@ Buildr::write "feature.properties", featurep foo = define("foo", :version => "1.0.0") foo.package(:feature).feature_xml = "feature.xml" foo.package(:feature).feature_properties = "feature.properties" foo.package(:feature).invoke - feature_file = File.join(foo.base_dir, "target", "foo-1.0.0-feature.jar") + feature_file = File.join(foo.base_dir, "target", "foo-1.0.0.zip") Zip::ZipFile.open(feature_file) do |zip| zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil zip.read("eclipse/features/foo_1.0.0/feature.xml").should == featurexml zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should_not be_nil zip.read("eclipse/features/foo_1.0.0/feature.properties").should == featurep @@ -188,11 +188,11 @@ f.description = "The best feature ever" f.changesURL = "http://example.com/changes" f.license = "The license is too long to explain" f.licenseURL = "http://example.com/license" foo.package(:feature).invoke - feature_file = File.join(foo.base_dir, "target", "foo-1.0.0-feature.jar") + feature_file = File.join(foo.base_dir, "target", "foo-1.0.0.zip") Zip::ZipFile.open(feature_file) do |zip| zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil feature_xml = zip.read("eclipse/features/foo_1.0.0/feature.xml") feature_xml.should_not match(/%label/) feature_xml.should match(/%provider\.0/) @@ -220,21 +220,21 @@ {:url => "http://example.com/upup", :name => "My update site in case"}] end it "should create a jar file with a eclipse/plugins and a eclipse/features structure" do @foo.package(:feature).invoke - feature_file = File.join(@foo.base_dir, "target", "foo-1.0.0-feature.jar") + feature_file = File.join(@foo.base_dir, "target", "foo-1.0.0.zip") File.exists?(feature_file).should be_true Zip::ZipFile.open(feature_file) do |zip| zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should_not be_nil zip.find_entry("eclipse/plugins/org.eclipse.debug.ui_3.4.1.v20080811_r341.jar").should_not be_nil end end it 'should complain if one of the dependencies is not a plugin' do - @foo.package(:feature).plugins << SLF4J + @foo.package(:feature).plugins << LOG4J lambda { @foo.package(:feature).invoke}.should raise_error( /The dependency .* is not an Eclipse plugin: make sure the headers Bundle-SymbolicName and Bundle-Version are present in the manifest/) end it "should let the user tell which plugins should be unjarred" do @@ -257,13 +257,15 @@ end describe Buildr4OSGi::FeatureTask, " package subprojects" do before do + Buildr::write "bar/src/main/java/Hello.java", "public class Hello {}" @container = define("container") do @bar = define("bar", :version => "1.0.0") do - package(:jar).with :manifest => {"Bundle-SymbolicName" => "bar", "Bundle-Version" => "1.0.0"} + package(:bundle) + package(:sources) end end @foo = define("foo", :version => "1.0.0") f = @foo.package(:feature) f.plugins << project("container:bar") @@ -286,9 +288,104 @@ Zip::ZipFile.open(feature_file) do |zip| zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should_not be_nil zip.find_entry("eclipse/plugins/bar_1.0.0.jar").should_not be_nil zip.find_entry("eclipse/plugins/bar_1.0.0.jar").directory?.should be_false + + end + end + + +end + + +describe Buildr4OSGi::FeatureTask, "packaged as SDK" do + + before do + Buildr::write "bar/src/main/java/Hello.java", "public class Hello {}" + @container = define("container") do + project.group = "grp" + @bar = define("bar", :version => "1.0.0") do + package(:bundle) + package(:sources) + end + end + @foo = define("foo", :version => "1.0.0") do + + f = package(:feature) + f.plugins.<< project("container:bar"), :unjarred => true + f.label = "My feature" + f.provider = "Acme Inc" + f.description = "The best feature ever" + f.changesURL = "http://example.com/changes" + f.license = "The license is too long to explain" + f.licenseURL = "http://example.com/license" + f.branding_plugin = "com.musal.ui" + f.update_sites << {:url => "http://example.com/update", :name => "My update site"} + f.discovery_sites = [{:url => "http://example.com/update2", :name => "My update site2"}, + {:url => "http://example.com/upup", :name => "My update site in case"}] + package(:sources) + end + end + + it "should create a jar file with the subproject packaged as a jar inside it" do + @foo.package(:sources).invoke + feature_file = @foo.package(:sources).to_s + File.exists?(feature_file).should be_true + Zip::ZipFile.open(feature_file) do |zip| + zip.find_entry("eclipse/features/foo.sources_1.0.0/feature.xml").should_not be_nil + zip.find_entry("eclipse/features/foo.sources_1.0.0/feature.properties").should_not be_nil + zip.find_entry("eclipse/plugins/bar.sources_1.0.0.jar").should be_nil + zip.find_entry("eclipse/plugins/bar.sources_1.0.0").directory?.should be_true + zip.find_entry("eclipse/plugins/bar.sources_1.0.0/Hello.java").should_not be_nil + + end + end + + +end + +describe Buildr4OSGi::FeatureTask, "packaged as SDK, detecting the OSGi headers from the original build" do + + before do + Buildr::write "bar/src/main/java/Hello.java", "public class Hello {}" + @container = define("container") do + project.group = "grp" + @bar = define("bar", :version => "1.0.0") do + package(:jar).with :manifest => {"Bundle-SymbolicName" => "myName", "Bundle-Version" => "3.2.1"} + package(:sources) + end + end + @foo = define("foo", :version => "1.0.0") do + + f = package(:feature) + f.plugins.<< project("container:bar"), :unjarred => true + f.label = "My feature" + f.provider = "Acme Inc" + f.description = "The best feature ever" + f.changesURL = "http://example.com/changes" + f.license = "The license is too long to explain" + f.licenseURL = "http://example.com/license" + f.branding_plugin = "com.musal.ui" + f.update_sites << {:url => "http://example.com/update", :name => "My update site"} + f.discovery_sites = [{:url => "http://example.com/update2", :name => "My update site2"}, + {:url => "http://example.com/upup", :name => "My update site in case"}] + package(:sources) + end + end + + it "should create a jar file with the subproject packaged as a jar inside it" do + @foo.package(:sources).invoke + feature_file = @foo.package(:sources).to_s + File.exists?(feature_file).should be_true + Zip::ZipFile.open(feature_file) do |zip| + zip.find_entry("eclipse/features/foo.sources_1.0.0/feature.xml").should_not be_nil + zip.find_entry("eclipse/features/foo.sources_1.0.0/feature.properties").should_not be_nil + zip.find_entry("eclipse/plugins/myName.sources_3.2.1.jar").should be_nil + zip.find_entry("eclipse/plugins/myName.sources_3.2.1").directory?.should be_true + zip.find_entry("eclipse/plugins/myName.sources_3.2.1/Hello.java").should_not be_nil + zip.find_entry("eclipse/plugins/myName.sources_3.2.1/META-INF/MANIFEST.MF").should_not be_nil + zip.read("eclipse/plugins/myName.sources_3.2.1/META-INF/MANIFEST.MF").should match(/Bundle-SymbolicName: myName\.sources/) end end end \ No newline at end of file