Repository: buildr Updated Branches: refs/heads/master 63120eeec -> 00f02b727
BUILDR-732 - Support bnd version 2.1.0 or more. Submitted By Eric Bruneton. Project: http://git-wip-us.apache.org/repos/asf/buildr/repo Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/00f02b72 Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/00f02b72 Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/00f02b72 Branch: refs/heads/master Commit: 00f02b7277e5984f320107d506689a8434cfc106 Parents: 63120ee Author: Peter Donald <[email protected]> Authored: Sat Sep 9 21:03:33 2017 +1000 Committer: Peter Donald <[email protected]> Committed: Sat Sep 9 21:03:33 2017 +1000 ---------------------------------------------------------------------- CHANGELOG | 1 + addon/buildr/bnd.rb | 10 ++++- spec/addon/bnd_spec.rb | 100 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 89 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/buildr/blob/00f02b72/CHANGELOG ---------------------------------------------------------------------- diff --git a/CHANGELOG b/CHANGELOG index 0a80ac3..5a11d7e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 1.5.4 (Pending) +* Added: BUILDR-732 - Support bnd version 2.1.0 or more. Submitted By Eric Bruneton. * Added: Support to compiling Kotlin * Fixed: Remove section on development builds in the Contributing section. * Added: New way to concatenate file contents when merging several archives together. http://git-wip-us.apache.org/repos/asf/buildr/blob/00f02b72/addon/buildr/bnd.rb ---------------------------------------------------------------------- diff --git a/addon/buildr/bnd.rb b/addon/buildr/bnd.rb index 03ec68a..db0be34 100644 --- a/addon/buildr/bnd.rb +++ b/addon/buildr/bnd.rb @@ -27,7 +27,13 @@ module Buildr # The specs for requirements def dependencies - ["biz.aQute:bnd:jar:#{version}"] + if Gem::Version.new(version) <= Gem::Version.new('1.50.0') + ["biz.aQute:bnd:jar:#{version}"] + elsif Gem::Version.new(version) <= Gem::Version.new('2.4.0') + ["biz.aQute.bnd:bnd:jar:#{version}"] + else + ["biz.aQute.bnd:biz.aQute.bnd:jar:#{version}"] + end end def bnd_main(*args) @@ -110,7 +116,7 @@ module Buildr Buildr::Bnd.bnd_main( bnd_filename ) begin - Buildr::Bnd.bnd_main('print', '-verify', filename ) + Buildr::Bnd.bnd_main('print', '-v', filename ) rescue => e rm filename raise e http://git-wip-us.apache.org/repos/asf/buildr/blob/00f02b72/spec/addon/bnd_spec.rb ---------------------------------------------------------------------- diff --git a/spec/addon/bnd_spec.rb b/spec/addon/bnd_spec.rb index eff5ef3..0b35928 100644 --- a/spec/addon/bnd_spec.rb +++ b/spec/addon/bnd_spec.rb @@ -55,35 +55,95 @@ package com.biz.bar; public class Bar {} SRC - @foo = define "foo" do - project.version = "2.1.3" - project.group = "mygroup" - manifest["Magic-Food"] = "Chocolate" - manifest["Magic-Drink"] = "Wine" + @foo = define "foo" do + project.version = "2.1.3" + project.group = "mygroup" + manifest["Magic-Food"] = "Chocolate" + manifest["Magic-Drink"] = "Wine" + package(:bundle).tap do |bnd| + bnd["Export-Package"] = "com.*" + end + + define "bar" do + project.version = "2.2" package(:bundle).tap do |bnd| + bnd["Magic-Food"] = "Cheese" bnd["Export-Package"] = "com.*" end + end + end + task('package').invoke + end - define "bar" do - project.version = "2.2" - package(:bundle).tap do |bnd| - bnd["Magic-Food"] = "Cheese" - bnd["Export-Package"] = "com.*" - end - end + it "version 0.0.384 does not export the version and wrong import-package" do + open_main_manifest_section do |attribs| + attribs['Bundle-Name'].should eql('foo') + attribs['Bundle-Version'].should eql('2.1.3') + attribs['Bundle-SymbolicName'].should eql('mygroup.foo') + attribs['Export-Package'].should eql('com.biz') + attribs['Import-Package'].should eql('com.biz') + end + end + end + + describe "project.bnd version 2.4.0 (assure forwward compatibility)" do + after do + STDERR.puts("forward compatibility: used #{Buildr::Bnd.version} restoring #{@savedVersion}") + Buildr::Bnd.version = @savedVersion + end + + before do + @savedVersion = Buildr::Bnd.version + Buildr::Bnd.version = '2.4.0' + write "src/main/java/com/biz/Foo.java", <<SRC +package com.biz; +public class Foo {} +SRC + + @foo = define "foo" do + project.version = "2.1.3" + project.group = "mygroup" + package(:bundle).tap do |bnd| + bnd["Export-Package"] = "com.*" end - task('package').invoke end + task('package').invoke + end - it "version 0.0.384 does not export the version and wrong import-package" do - open_main_manifest_section do |attribs| - attribs['Bundle-Name'].should eql('foo') - attribs['Bundle-Version'].should eql('2.1.3') - attribs['Bundle-SymbolicName'].should eql('mygroup.foo') - attribs['Export-Package'].should eql('com.biz') - attribs['Import-Package'].should eql('com.biz') + it "produces a .bnd and a .jar in the correct location for root project" do + File.should be_exist(@foo._("target/foo-2.1.3.bnd")) + File.should be_exist(@foo._("target/foo-2.1.3.jar")) + end + end + + describe "project.bnd version 3.4.0 (assure forward compatibility)" do + after do + STDERR.puts("forward compatibility: used #{Buildr::Bnd.version} restoring #{@savedVersion}") + Buildr::Bnd.version = @savedVersion + end + + before do + @savedVersion = Buildr::Bnd.version + Buildr::Bnd.version = '3.4.0' + write "src/main/java/com/biz/Foo.java", <<SRC +package com.biz; +public class Foo {} +SRC + + @foo = define "foo" do + project.version = "2.1.3" + project.group = "mygroup" + package(:bundle).tap do |bnd| + bnd["Export-Package"] = "com.*" end end + task('package').invoke + end + + it "produces a .bnd and a .jar in the correct location for root project" do + File.should be_exist(@foo._("target/foo-2.1.3.bnd")) + File.should be_exist(@foo._("target/foo-2.1.3.jar")) + end end describe "package :bundle" do
