spec/osgi/packaging_spec.rb in buildr4osgi-0.9.3 vs spec/osgi/packaging_spec.rb in buildr4osgi-0.9.4

- old
+ new

@@ -209,31 +209,75 @@ foo = define("foo", :version => "1.0.0") do package(:plugin).manifest["Bundle-Version"] = "2.0.0" Buildr::write "plugin.xml", "" mkpath "conf" Buildr::write "conf/log4j.properties", "" + # Note: it doesn't work if no sources are present. + # Adding a pending spec for support for it. + Buildr::write "src/main/java/Main.java", "public class Main { public static void main(String[] args) {}}" end foo.package(:plugin).invoke Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip| zip.find_entry("conf/log4j.properties").should_not be_nil end end + it 'should include all the resources present at the root of the plugin, and no sources are defined' do + pending "In progress for this: we don't really need that yet." + foo = define("foo", :version => "1.0.0") do + package(:plugin).manifest["Bundle-Version"] = "2.0.0" + Buildr::write "plugin.xml", "" + mkpath "conf" + Buildr::write "conf/log4j.properties", "" + end + + foo.package(:plugin).invoke + Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip| + zip.find_entry("conf/log4j.properties").should_not be_nil + end + end + + it 'should include resources present in the code tree' do + Buildr::write "org.apache.axis2.osgi-1.5.1-sources/Main.java", "public class Main { public static void main(String[] args) {}}" + Buildr::write "org.apache.axis2.osgi-1.5.1-sources/de/thing/HelloWorld.java", "package de.thing;public class HelloWorld {public static void main(String[] args) {}}" + Buildr::write "org.apache.axis2.osgi-1.5.1-sources/messages.properties", "" + Buildr::write "org.apache.axis2.osgi-1.5.1-sources/de/thing/messages.properties", "" + Buildr::write "org.apache.axis2.osgi-abpt-1.5.1-sources/de/hello/messages.properties", "" + Buildr::write "META-INF/MANIFEST.MF", "Bundle-SymbolicName: dev\nExport-Package: package1,\n package2\nBundle-Version: 1.0.0" + Buildr::write "plugin.xml", "" + foo = define("foo", :version => "1.0.0") do + compile.from(FileList["org.apache.axis2.osgi-1.5.1-sources/", + File.join(project.base_dir, "org.apache.axis2.osgi-abpt-1.5.1-sources")]).into("bin") + package(:bundle).use_bundle_version + + end + foo.package(:bundle).invoke + Zip::ZipFile.open(foo.package(:bundle).to_s) do |zip| + zip.find_entry("messages.properties").should_not be_nil + zip.find_entry("de/thing/messages.properties").should_not be_nil + zip.find_entry("de/hello/messages.properties").should_not be_nil + zip.find_entry("org.apache.axis2.osgi-1.5.1-sources").should be_nil + zip.find_entry("org.apache.axis2.osgi-abpt-1.5.1-sources").should be_nil + zip.find_entry("plugin.xml").should_not be_nil + end + end + it 'should not include java files or classes by mistake' do Buildr::write "plugin.xml", "" Buildr::write "src/main/java/Main.java", "public class Main { public static void main(String[] args) {}}" Buildr::write "src/main/java/de/thing/HelloWorld.java", "package de.thing;public class HelloWorld {public static void main(String[] args) {}}" Buildr::write "customsrc/main/java/org/thing/Hello.java", "" Buildr::write "bin/org/thing/Hello.class", "" foo = define("foo", :version => "1.0.0") do compile.options.source = "1.5" compile.options.target = "1.5" - + compile.from(_("src/main/java"), _("customsrc/main/java")).into(_("bin")) package(:plugin).manifest["Bundle-Version"] = "2.0.0" end foo.compile.invoke foo.package(:plugin).invoke + Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip| zip.find_entry("customsrc").should be_nil zip.find_entry("src").should be_nil zip.find_entry("src/main/java/de/thing/HelloWorld.java").should be_nil zip.find_entry("customsrc/main/java/org/thing/Hello.java").should be_nil @@ -319,9 +363,39 @@ foo.package(:plugin).invoke Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip| manifest =zip.read("META-INF/MANIFEST.MF") manifest.should match(/Bundle-Version: 6.0.1.003/) manifest.should match(/Bundle-SymbolicName: dev/) + end + + end + + it "should use the Bundle-Classpath entry whenever present to determine the classpath" do + Buildr::write "META-INF/MANIFEST.MF", "Bundle-SymbolicName: dev\nExport-Package: package1,\n package2\nBundle-Version: 1.0.0\nBundle-Classpath: WEB-INF/classes" + Buildr::write "src/main/java/Hello.java", "public class Hello {}" + + foo = define("foo", :version => "1.0.0.qualifier") do + package(:bundle) + end + + foo.package(:bundle).invoke + Zip::ZipFile.open(foo.package(:bundle).to_s) do |zip| + zip.find_entry("WEB-INF/classes/Hello.class").should_not be_nil + end + + end + + it "should use the _first_ Bundle-Classpath entry whenever present to determine the classpath" do + Buildr::write "META-INF/MANIFEST.MF", "Bundle-SymbolicName: dev\nExport-Package: package1,\n package2\nBundle-Version: 1.0.0\nBundle-Classpath: WEB-INF/classes,else" + Buildr::write "src/main/java/Hello.java", "public class Hello {}" + + foo = define("foo", :version => "1.0.0.qualifier") do + package(:bundle) + end + + foo.package(:bundle).invoke + Zip::ZipFile.open(foo.package(:bundle).to_s) do |zip| + zip.find_entry("WEB-INF/classes/Hello.class").should_not be_nil end end end \ No newline at end of file