buildr-bnd 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +25 -21
- data/LICENSE +176 -176
- data/README.rdoc +230 -230
- data/Rakefile +41 -24
- data/buildr-bnd.gemspec +20 -20
- data/lib/buildr/bnd/bundle_task.rb +82 -81
- data/lib/buildr/bnd/core.rb +26 -26
- data/lib/buildr/bnd/project_extension.rb +35 -35
- data/lib/buildr/bnd/version.rb +10 -10
- data/lib/buildr_bnd.rb +4 -4
- data/spec/buildr/bnd/bundle_package_spec.rb +223 -223
- data/spec/buildr/bnd/defaults_spec.rb +78 -74
- data/spec/buildr/bnd/project_extension_spec.rb +11 -11
- data/spec/spec_helper.rb +39 -32
- metadata +7 -8
- data/spec/spec.opts +0 -1
data/Rakefile
CHANGED
@@ -1,24 +1,41 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/rdoctask'
|
3
|
-
require 'rake/gempackagetask'
|
4
|
-
require 'spec/rake/spectask'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'ci_reporter'
|
9
|
+
require 'ci/reporter/rake/rspec'
|
10
|
+
ENV["CI_REPORTS"] = 'tmp/reports'
|
11
|
+
rescue LoadError => e
|
12
|
+
#puts "The ci_reporter gem is not available. Reports will not be generated."
|
13
|
+
end
|
14
|
+
|
15
|
+
gem_spec = Gem::Specification.load(File.expand_path('buildr-bnd.gemspec', File.dirname(__FILE__)))
|
16
|
+
|
17
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
18
|
+
spec.libs << 'lib' << 'spec'
|
19
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
20
|
+
end
|
21
|
+
|
22
|
+
task :default => :spec
|
23
|
+
|
24
|
+
desc "Generate RDoc documentation in rdoc/"
|
25
|
+
Rake::RDocTask.new :rdoc do |rdoc|
|
26
|
+
rdoc.rdoc_dir = 'rdoc'
|
27
|
+
rdoc.title = gem_spec.name
|
28
|
+
rdoc.options = gem_spec.rdoc_options.clone
|
29
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
30
|
+
rdoc.rdoc_files.include gem_spec.extra_rdoc_files
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(gem_spec).define
|
34
|
+
|
35
|
+
namespace :deploy do
|
36
|
+
desc "Tag release with current version"
|
37
|
+
task :tag do
|
38
|
+
system("git tag -a #{gem_spec.version} -m 'Released #{gem_spec.version}'")
|
39
|
+
puts "Tagged locally. `git push --tags` if you're sure."
|
40
|
+
end
|
41
|
+
end
|
data/buildr-bnd.gemspec
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/lib/buildr/bnd/version')
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = 'buildr-bnd'
|
5
|
-
spec.version = Buildr::Bnd::Version::STRING
|
6
|
-
spec.authors = ['Peter Donald']
|
7
|
-
spec.email = ["peter@realityforge.org"]
|
8
|
-
spec.homepage = "http://github.com/realityforge/buildr-bnd"
|
9
|
-
spec.summary = "Buildr extension for packaging OSGi bundles using bnd"
|
10
|
-
spec.description = <<-TEXT
|
11
|
-
This is a buildr extension for packaging OSGi bundles using Bnd.
|
12
|
-
TEXT
|
13
|
-
spec.files = Dir['{lib,spec}/**/*', '*.gemspec'] +
|
14
|
-
['LICENSE', 'README.rdoc', 'CHANGELOG', 'Rakefile']
|
15
|
-
spec.require_paths = ['lib']
|
16
|
-
|
17
|
-
spec.has_rdoc = true
|
18
|
-
spec.extra_rdoc_files = 'README.rdoc', 'LICENSE', 'CHANGELOG'
|
19
|
-
spec.rdoc_options = '--title', "#{spec.name} #{spec.version}", '--main', 'README.rdoc'
|
20
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/buildr/bnd/version')
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'buildr-bnd'
|
5
|
+
spec.version = Buildr::Bnd::Version::STRING
|
6
|
+
spec.authors = ['Peter Donald']
|
7
|
+
spec.email = ["peter@realityforge.org"]
|
8
|
+
spec.homepage = "http://github.com/realityforge/buildr-bnd"
|
9
|
+
spec.summary = "Buildr extension for packaging OSGi bundles using bnd"
|
10
|
+
spec.description = <<-TEXT
|
11
|
+
This is a buildr extension for packaging OSGi bundles using Bnd.
|
12
|
+
TEXT
|
13
|
+
spec.files = Dir['{lib,spec}/**/*', '*.gemspec'] +
|
14
|
+
['LICENSE', 'README.rdoc', 'CHANGELOG', 'Rakefile']
|
15
|
+
spec.require_paths = ['lib']
|
16
|
+
|
17
|
+
spec.has_rdoc = true
|
18
|
+
spec.extra_rdoc_files = 'README.rdoc', 'LICENSE', 'CHANGELOG'
|
19
|
+
spec.rdoc_options = '--title', "#{spec.name} #{spec.version}", '--main', 'README.rdoc'
|
20
|
+
end
|
@@ -1,81 +1,82 @@
|
|
1
|
-
module Buildr
|
2
|
-
module Bnd
|
3
|
-
class BundleTask < Rake::FileTask
|
4
|
-
attr_reader :project
|
5
|
-
attr_accessor :classpath
|
6
|
-
|
7
|
-
def [](key)
|
8
|
-
@params[key]
|
9
|
-
end
|
10
|
-
|
11
|
-
def []=(key, value)
|
12
|
-
@params[key] = value
|
13
|
-
end
|
14
|
-
|
15
|
-
def classpath_element(dependencies)
|
16
|
-
artifacts = Buildr.artifacts([dependencies])
|
17
|
-
self.prerequisites << artifacts
|
18
|
-
artifacts.each do |dependency|
|
19
|
-
self.classpath << dependency.to_s
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_params
|
24
|
-
params = self.project.manifest.merge(@params).reject { |k, v| v.nil? }
|
25
|
-
params["-classpath"] ||= self.classpath.collect(&:to_s).join(", ")
|
26
|
-
params['Bundle-SymbolicName'] ||= [self.project.group, self.project.name.gsub(':', '.')].join('.')
|
27
|
-
params['Bundle-Name'] ||= self.project.comment || self.project.name
|
28
|
-
params['Bundle-Description'] ||= self.project.comment
|
29
|
-
params['Bundle-Version'] ||= self.project.version
|
30
|
-
if params["Include-Resource"].nil? && !project.resources.target.nil?
|
31
|
-
params["Include-Resource"] = "#{project.resources.target}/"
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
params
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
1
|
+
module Buildr
|
2
|
+
module Bnd
|
3
|
+
class BundleTask < Rake::FileTask
|
4
|
+
attr_reader :project
|
5
|
+
attr_accessor :classpath
|
6
|
+
|
7
|
+
def [](key)
|
8
|
+
@params[key]
|
9
|
+
end
|
10
|
+
|
11
|
+
def []=(key, value)
|
12
|
+
@params[key] = value
|
13
|
+
end
|
14
|
+
|
15
|
+
def classpath_element(dependencies)
|
16
|
+
artifacts = Buildr.artifacts([dependencies])
|
17
|
+
self.prerequisites << artifacts
|
18
|
+
artifacts.each do |dependency|
|
19
|
+
self.classpath << dependency.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_params
|
24
|
+
params = self.project.manifest.merge(@params).reject { |k, v| v.nil? }
|
25
|
+
params["-classpath"] ||= self.classpath.collect(&:to_s).join(", ")
|
26
|
+
params['Bundle-SymbolicName'] ||= [self.project.group, self.project.name.gsub(':', '.')].join('.')
|
27
|
+
params['Bundle-Name'] ||= self.project.comment || self.project.name
|
28
|
+
params['Bundle-Description'] ||= self.project.comment
|
29
|
+
params['Bundle-Version'] ||= self.project.version
|
30
|
+
if params["Include-Resource"].nil? && !project.resources.target.nil?
|
31
|
+
params["Include-Resource"] = "#{project.resources.target}/"
|
32
|
+
end
|
33
|
+
params['-removeheaders'] ||= "Include-Resource,Bnd-LastModified,Created-By,Implementation-Title,Tool"
|
34
|
+
|
35
|
+
params
|
36
|
+
end
|
37
|
+
|
38
|
+
def project=(project)
|
39
|
+
@project = project
|
40
|
+
end
|
41
|
+
|
42
|
+
def classpath=(classpath)
|
43
|
+
@classpath = []
|
44
|
+
Buildr.artifacts([classpath.flatten.compact]).each do |dependency|
|
45
|
+
self.prerequisites << dependency
|
46
|
+
@classpath << dependency.to_s
|
47
|
+
end
|
48
|
+
@classpath
|
49
|
+
end
|
50
|
+
|
51
|
+
def classpath
|
52
|
+
@classpath ||= ([project.compile.target] + project.compile.dependencies).flatten.compact
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def initialize(*args) #:nodoc:
|
58
|
+
super
|
59
|
+
@params = {}
|
60
|
+
enhance do
|
61
|
+
filename = self.name
|
62
|
+
# Generate BND file with same name as target jar but different extension
|
63
|
+
bnd_filename = filename.sub /(\.jar)?$/, '.bnd'
|
64
|
+
|
65
|
+
params = self.to_params
|
66
|
+
params["-output"] = filename
|
67
|
+
File.open(bnd_filename, 'w') do |f|
|
68
|
+
f.print params.collect { |k, v| "#{k}=#{v}" }.join("\n")
|
69
|
+
end
|
70
|
+
|
71
|
+
Buildr::Bnd.bnd_main( "build", "-noeclipse", bnd_filename )
|
72
|
+
begin
|
73
|
+
Buildr::Bnd.bnd_main( "print", "-verify", filename )
|
74
|
+
rescue => e
|
75
|
+
rm filename
|
76
|
+
raise e
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/buildr/bnd/core.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
module Buildr
|
2
|
-
module Bnd
|
3
|
-
class << self
|
4
|
-
# The specs for requirements
|
5
|
-
def requires
|
6
|
-
["biz.aQute:bnd:jar:0.0.384"]
|
7
|
-
end
|
8
|
-
|
9
|
-
# Repositories containing the requirements
|
10
|
-
def remote_repositories
|
11
|
-
puts "Buildr::Bnd.remote_repositories is deprecated. Please use Buildr::Bnd.remote_repository instead."
|
12
|
-
[remote_repository]
|
13
|
-
end
|
14
|
-
|
15
|
-
# Repositories containing the requirements
|
16
|
-
def remote_repository
|
17
|
-
"http://www.aQute.biz/repo"
|
18
|
-
end
|
19
|
-
|
20
|
-
def bnd_main(*args)
|
21
|
-
cp = Buildr.artifacts(self.requires).each(&:invoke).map(&:to_s)
|
22
|
-
Java::Commands.java 'aQute.bnd.main.bnd', *(args + [{ :classpath => cp }])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Buildr
|
2
|
+
module Bnd
|
3
|
+
class << self
|
4
|
+
# The specs for requirements
|
5
|
+
def requires
|
6
|
+
["biz.aQute:bnd:jar:0.0.384"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# Repositories containing the requirements
|
10
|
+
def remote_repositories
|
11
|
+
puts "Buildr::Bnd.remote_repositories is deprecated. Please use Buildr::Bnd.remote_repository instead."
|
12
|
+
[remote_repository]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Repositories containing the requirements
|
16
|
+
def remote_repository
|
17
|
+
"http://www.aQute.biz/repo"
|
18
|
+
end
|
19
|
+
|
20
|
+
def bnd_main(*args)
|
21
|
+
cp = Buildr.artifacts(self.requires).each(&:invoke).map(&:to_s)
|
22
|
+
Java::Commands.java 'aQute.bnd.main.bnd', *(args + [{ :classpath => cp }])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
module Buildr
|
2
|
-
module Bnd
|
3
|
-
module ProjectExtension
|
4
|
-
include Extension
|
5
|
-
|
6
|
-
first_time do
|
7
|
-
desc "Does `bnd print` on the packaged bundle and stdouts the output for inspection"
|
8
|
-
Project.local_task("bnd:print")
|
9
|
-
end
|
10
|
-
|
11
|
-
def package_as_bundle(filename)
|
12
|
-
project.task('bnd:print' => [filename]) do |task|
|
13
|
-
Buildr::Bnd.bnd_main("print", filename)
|
14
|
-
end
|
15
|
-
|
16
|
-
dirname = File.dirname(filename)
|
17
|
-
directory(dirname)
|
18
|
-
|
19
|
-
# Add Buildr.application.buildfile so it will rebuild if we change settings
|
20
|
-
task = BundleTask.define_task(filename => [Buildr.application.buildfile, dirname])
|
21
|
-
task.project = self
|
22
|
-
# the last task is the task considered the packaging task
|
23
|
-
task
|
24
|
-
end
|
25
|
-
|
26
|
-
# Change the bundle package to .jar extension
|
27
|
-
def package_as_bundle_spec(spec)
|
28
|
-
spec.merge(:type => :jar)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class Buildr::Project
|
35
|
-
include Buildr::Bnd::ProjectExtension
|
1
|
+
module Buildr
|
2
|
+
module Bnd
|
3
|
+
module ProjectExtension
|
4
|
+
include Extension
|
5
|
+
|
6
|
+
first_time do
|
7
|
+
desc "Does `bnd print` on the packaged bundle and stdouts the output for inspection"
|
8
|
+
Project.local_task("bnd:print")
|
9
|
+
end
|
10
|
+
|
11
|
+
def package_as_bundle(filename)
|
12
|
+
project.task('bnd:print' => [filename]) do |task|
|
13
|
+
Buildr::Bnd.bnd_main("print", filename)
|
14
|
+
end
|
15
|
+
|
16
|
+
dirname = File.dirname(filename)
|
17
|
+
directory(dirname)
|
18
|
+
|
19
|
+
# Add Buildr.application.buildfile so it will rebuild if we change settings
|
20
|
+
task = BundleTask.define_task(filename => [Buildr.application.buildfile, dirname])
|
21
|
+
task.project = self
|
22
|
+
# the last task is the task considered the packaging task
|
23
|
+
task
|
24
|
+
end
|
25
|
+
|
26
|
+
# Change the bundle package to .jar extension
|
27
|
+
def package_as_bundle_spec(spec)
|
28
|
+
spec.merge(:type => :jar)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Buildr::Project
|
35
|
+
include Buildr::Bnd::ProjectExtension
|
36
36
|
end
|
data/lib/buildr/bnd/version.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
module Buildr
|
2
|
-
module Bnd
|
3
|
-
class Version
|
4
|
-
MAJOR = "0"
|
5
|
-
MINOR = "0"
|
6
|
-
MICRO = "
|
7
|
-
|
8
|
-
STRING = "#{MAJOR}.#{MINOR}.#{MICRO}"
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module Buildr
|
2
|
+
module Bnd
|
3
|
+
class Version
|
4
|
+
MAJOR = "0"
|
5
|
+
MINOR = "0"
|
6
|
+
MICRO = "6"
|
7
|
+
|
8
|
+
STRING = "#{MAJOR}.#{MINOR}.#{MICRO}"
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
data/lib/buildr_bnd.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'buildr/bnd/version'
|
2
|
-
require 'buildr/bnd/core'
|
3
|
-
require 'buildr/bnd/bundle_task'
|
4
|
-
require 'buildr/bnd/project_extension'
|
1
|
+
require 'buildr/bnd/version'
|
2
|
+
require 'buildr/bnd/core'
|
3
|
+
require 'buildr/bnd/bundle_task'
|
4
|
+
require 'buildr/bnd/project_extension'
|
@@ -1,223 +1,223 @@
|
|
1
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
def open_zip_file(file = 'target/foo-2.1.3.jar')
|
4
|
-
jar_filename = @foo._(file)
|
5
|
-
File.should be_exist(jar_filename)
|
6
|
-
Zip::ZipFile.open(jar_filename) do |zip|
|
7
|
-
yield zip
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def open_main_manifest_section(file = 'target/foo-2.1.3.jar')
|
12
|
-
jar_filename = @foo._(file)
|
13
|
-
File.should be_exist(jar_filename)
|
14
|
-
yield Buildr::Packaging::Java::Manifest.from_zip(jar_filename).main
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "package :bundle" do
|
18
|
-
describe "with a valid bundle" do
|
19
|
-
before do
|
20
|
-
write "src/main/java/com/biz/Foo.java", <<SRC
|
21
|
-
package com.biz;
|
22
|
-
public class Foo {}
|
23
|
-
SRC
|
24
|
-
write "src/main/resources/IRIS-INF/iris.config", <<SRC
|
25
|
-
some=setting
|
26
|
-
SRC
|
27
|
-
write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
|
28
|
-
package com.biz.bar;
|
29
|
-
public class Bar {}
|
30
|
-
SRC
|
31
|
-
@foo = define "foo" do
|
32
|
-
project.version = "2.1.3"
|
33
|
-
project.group = "mygroup"
|
34
|
-
manifest["Magic-Food"] = "Chocolate"
|
35
|
-
manifest["Magic-Drink"] = "Wine"
|
36
|
-
package(:bundle).tap do |bnd|
|
37
|
-
bnd["Export-Package"] = "com.*"
|
38
|
-
end
|
39
|
-
|
40
|
-
define "bar" do
|
41
|
-
project.version = "2.2"
|
42
|
-
package(:bundle).tap do |bnd|
|
43
|
-
bnd["Magic-Food"] = "Cheese"
|
44
|
-
bnd["Export-Package"] = "com.*"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
task('package').invoke
|
49
|
-
end
|
50
|
-
|
51
|
-
it "produces a .bnd in the correct location for root project" do
|
52
|
-
File.should be_exist(@foo._("target/foo-2.1.3.bnd"))
|
53
|
-
end
|
54
|
-
|
55
|
-
it "produces a .jar in the correct location for root project" do
|
56
|
-
File.should be_exist(@foo._("target/foo-2.1.3.jar"))
|
57
|
-
end
|
58
|
-
|
59
|
-
it "produces a .jar containing correct .class files for root project" do
|
60
|
-
open_zip_file do |zip|
|
61
|
-
zip.file.exist?('com/biz/Foo.class').should be_true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "produces a .jar containing resoruces from resource directory root project" do
|
66
|
-
open_zip_file do |zip|
|
67
|
-
zip.file.exist?('IRIS-INF/iris.config').should be_true
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
it "produces a .jar containing expected manifest entries derived from project.bnd for root project" do
|
72
|
-
open_main_manifest_section do |attribs|
|
73
|
-
attribs['Bundle-Name'].should eql('foo')
|
74
|
-
attribs['Bundle-Version'].should eql('2.1.3')
|
75
|
-
attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
|
76
|
-
attribs['Export-Package'].should eql('com.biz')
|
77
|
-
attribs['Import-Package'].should eql('com.biz')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it "produces a .jar containing expected manifest entries derived from project.manifest root project" do
|
82
|
-
open_main_manifest_section do |attribs|
|
83
|
-
attribs['Magic-Drink'].should eql('Wine')
|
84
|
-
attribs['Magic-Food'].should eql('Chocolate')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it "produces a .bnd in the correct location for subproject project" do
|
89
|
-
File.should be_exist(@foo._("bar/target/foo-bar-2.2.bnd"))
|
90
|
-
end
|
91
|
-
|
92
|
-
it "produces a .jar in the correct location for subproject project" do
|
93
|
-
File.should be_exist(@foo._("bar/target/foo-bar-2.2.jar"))
|
94
|
-
end
|
95
|
-
|
96
|
-
it "produces a .jar containing correct .class files for subproject project" do
|
97
|
-
open_zip_file('bar/target/foo-bar-2.2.jar') do |zip|
|
98
|
-
zip.file.exist?('com/biz/bar/Bar.class').should be_true
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
it "produces a .jar containing expected manifest entries derived from project.bnd for subproject project" do
|
103
|
-
open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
|
104
|
-
attribs['Bundle-Name'].should eql('foo:bar')
|
105
|
-
attribs['Bundle-Version'].should eql('2.2')
|
106
|
-
attribs['Bundle-SymbolicName'].should eql('mygroup.foo.bar')
|
107
|
-
attribs['Export-Package'].should eql('com.biz.bar')
|
108
|
-
attribs['Import-Package'].should eql('com.biz.bar')
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
it "produces a .jar containing expected manifest entries derived from project.manifest subproject project" do
|
113
|
-
open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
|
114
|
-
attribs['Magic-Drink'].should eql('Wine')
|
115
|
-
attribs['Magic-Food'].should eql('Cheese')
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "with an invalid bundle" do
|
121
|
-
before do
|
122
|
-
# bundle invalid as no source
|
123
|
-
@foo = define "foo" do
|
124
|
-
project.version = "2.1.3"
|
125
|
-
project.group = "mygroup"
|
126
|
-
package(:bundle).tap do |bnd|
|
127
|
-
bnd["Export-Package"] = "*"
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
it "raise an error if unable to build a valid bundle" do
|
133
|
-
lambda { task('package').invoke }.should raise_error
|
134
|
-
end
|
135
|
-
|
136
|
-
it "raise not produce an invalid jar file" do
|
137
|
-
lambda { task('package').invoke }.should raise_error
|
138
|
-
File.should_not be_exist(@foo._("target/foo-2.1.3.jar"))
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "using classpath_element to specify dependency" do
|
143
|
-
before do
|
144
|
-
@foo = define "foo" do
|
145
|
-
project.version = "2.1.3"
|
146
|
-
project.group = "mygroup"
|
147
|
-
package(:bundle).tap do |bnd|
|
148
|
-
bnd['Export-Package'] = 'org.apache.tools.zip.*'
|
149
|
-
Buildr::Ant.dependencies.each do |d|
|
150
|
-
bnd.classpath_element d
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should not raise an error during packaging" do
|
157
|
-
lambda { task('package').invoke }.should_not raise_error
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should generate package with files exported from dependency" do
|
161
|
-
task('package').invoke
|
162
|
-
open_main_manifest_section do |attribs|
|
163
|
-
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "using classpath to specify dependencies" do
|
169
|
-
before do
|
170
|
-
write "src/main/java/com/biz/Foo.java", <<SRC
|
171
|
-
package com.biz;
|
172
|
-
public class Foo {}
|
173
|
-
SRC
|
174
|
-
write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
|
175
|
-
package com.biz.bar;
|
176
|
-
public class Bar {}
|
177
|
-
SRC
|
178
|
-
@foo = define "foo" do
|
179
|
-
project.version = "2.1.3"
|
180
|
-
project.group = "mygroup"
|
181
|
-
package(:bundle).tap do |bnd|
|
182
|
-
bnd['Export-Package'] = 'org.apache.tools.zip.*'
|
183
|
-
bnd.classpath = bnd.classpath + Buildr::Ant.dependencies
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should not raise an error during packaging" do
|
189
|
-
lambda { task('package').invoke }.should_not raise_error
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should generate package with files exported from dependency" do
|
193
|
-
task('package').invoke
|
194
|
-
open_main_manifest_section do |attribs|
|
195
|
-
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
describe "using compile dependencies to specify dependency" do
|
201
|
-
before do
|
202
|
-
@foo = define "foo" do
|
203
|
-
project.version = "2.1.3"
|
204
|
-
project.group = "mygroup"
|
205
|
-
compile.with Buildr::Ant.dependencies
|
206
|
-
package(:bundle).tap do |bnd|
|
207
|
-
bnd['Export-Package'] = 'org.apache.tools.zip.*'
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
it "should not raise an error during packaging" do
|
213
|
-
lambda { task('package').invoke }.should_not raise_error
|
214
|
-
end
|
215
|
-
|
216
|
-
it "should generate package with files exported from dependency" do
|
217
|
-
task('package').invoke
|
218
|
-
open_main_manifest_section do |attribs|
|
219
|
-
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
def open_zip_file(file = 'target/foo-2.1.3.jar')
|
4
|
+
jar_filename = @foo._(file)
|
5
|
+
File.should be_exist(jar_filename)
|
6
|
+
Zip::ZipFile.open(jar_filename) do |zip|
|
7
|
+
yield zip
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def open_main_manifest_section(file = 'target/foo-2.1.3.jar')
|
12
|
+
jar_filename = @foo._(file)
|
13
|
+
File.should be_exist(jar_filename)
|
14
|
+
yield Buildr::Packaging::Java::Manifest.from_zip(jar_filename).main
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "package :bundle" do
|
18
|
+
describe "with a valid bundle" do
|
19
|
+
before do
|
20
|
+
write "src/main/java/com/biz/Foo.java", <<SRC
|
21
|
+
package com.biz;
|
22
|
+
public class Foo {}
|
23
|
+
SRC
|
24
|
+
write "src/main/resources/IRIS-INF/iris.config", <<SRC
|
25
|
+
some=setting
|
26
|
+
SRC
|
27
|
+
write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
|
28
|
+
package com.biz.bar;
|
29
|
+
public class Bar {}
|
30
|
+
SRC
|
31
|
+
@foo = define "foo" do
|
32
|
+
project.version = "2.1.3"
|
33
|
+
project.group = "mygroup"
|
34
|
+
manifest["Magic-Food"] = "Chocolate"
|
35
|
+
manifest["Magic-Drink"] = "Wine"
|
36
|
+
package(:bundle).tap do |bnd|
|
37
|
+
bnd["Export-Package"] = "com.*"
|
38
|
+
end
|
39
|
+
|
40
|
+
define "bar" do
|
41
|
+
project.version = "2.2"
|
42
|
+
package(:bundle).tap do |bnd|
|
43
|
+
bnd["Magic-Food"] = "Cheese"
|
44
|
+
bnd["Export-Package"] = "com.*"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
task('package').invoke
|
49
|
+
end
|
50
|
+
|
51
|
+
it "produces a .bnd in the correct location for root project" do
|
52
|
+
File.should be_exist(@foo._("target/foo-2.1.3.bnd"))
|
53
|
+
end
|
54
|
+
|
55
|
+
it "produces a .jar in the correct location for root project" do
|
56
|
+
File.should be_exist(@foo._("target/foo-2.1.3.jar"))
|
57
|
+
end
|
58
|
+
|
59
|
+
it "produces a .jar containing correct .class files for root project" do
|
60
|
+
open_zip_file do |zip|
|
61
|
+
zip.file.exist?('com/biz/Foo.class').should be_true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "produces a .jar containing resoruces from resource directory root project" do
|
66
|
+
open_zip_file do |zip|
|
67
|
+
zip.file.exist?('IRIS-INF/iris.config').should be_true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "produces a .jar containing expected manifest entries derived from project.bnd for root project" do
|
72
|
+
open_main_manifest_section do |attribs|
|
73
|
+
attribs['Bundle-Name'].should eql('foo')
|
74
|
+
attribs['Bundle-Version'].should eql('2.1.3')
|
75
|
+
attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
|
76
|
+
attribs['Export-Package'].should eql('com.biz')
|
77
|
+
attribs['Import-Package'].should eql('com.biz')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it "produces a .jar containing expected manifest entries derived from project.manifest root project" do
|
82
|
+
open_main_manifest_section do |attribs|
|
83
|
+
attribs['Magic-Drink'].should eql('Wine')
|
84
|
+
attribs['Magic-Food'].should eql('Chocolate')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "produces a .bnd in the correct location for subproject project" do
|
89
|
+
File.should be_exist(@foo._("bar/target/foo-bar-2.2.bnd"))
|
90
|
+
end
|
91
|
+
|
92
|
+
it "produces a .jar in the correct location for subproject project" do
|
93
|
+
File.should be_exist(@foo._("bar/target/foo-bar-2.2.jar"))
|
94
|
+
end
|
95
|
+
|
96
|
+
it "produces a .jar containing correct .class files for subproject project" do
|
97
|
+
open_zip_file('bar/target/foo-bar-2.2.jar') do |zip|
|
98
|
+
zip.file.exist?('com/biz/bar/Bar.class').should be_true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it "produces a .jar containing expected manifest entries derived from project.bnd for subproject project" do
|
103
|
+
open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
|
104
|
+
attribs['Bundle-Name'].should eql('foo:bar')
|
105
|
+
attribs['Bundle-Version'].should eql('2.2')
|
106
|
+
attribs['Bundle-SymbolicName'].should eql('mygroup.foo.bar')
|
107
|
+
attribs['Export-Package'].should eql('com.biz.bar')
|
108
|
+
attribs['Import-Package'].should eql('com.biz.bar')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it "produces a .jar containing expected manifest entries derived from project.manifest subproject project" do
|
113
|
+
open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
|
114
|
+
attribs['Magic-Drink'].should eql('Wine')
|
115
|
+
attribs['Magic-Food'].should eql('Cheese')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "with an invalid bundle" do
|
121
|
+
before do
|
122
|
+
# bundle invalid as no source
|
123
|
+
@foo = define "foo" do
|
124
|
+
project.version = "2.1.3"
|
125
|
+
project.group = "mygroup"
|
126
|
+
package(:bundle).tap do |bnd|
|
127
|
+
bnd["Export-Package"] = "*"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it "raise an error if unable to build a valid bundle" do
|
133
|
+
lambda { task('package').invoke }.should raise_error
|
134
|
+
end
|
135
|
+
|
136
|
+
it "raise not produce an invalid jar file" do
|
137
|
+
lambda { task('package').invoke }.should raise_error
|
138
|
+
File.should_not be_exist(@foo._("target/foo-2.1.3.jar"))
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "using classpath_element to specify dependency" do
|
143
|
+
before do
|
144
|
+
@foo = define "foo" do
|
145
|
+
project.version = "2.1.3"
|
146
|
+
project.group = "mygroup"
|
147
|
+
package(:bundle).tap do |bnd|
|
148
|
+
bnd['Export-Package'] = 'org.apache.tools.zip.*'
|
149
|
+
Buildr::Ant.dependencies.each do |d|
|
150
|
+
bnd.classpath_element d
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should not raise an error during packaging" do
|
157
|
+
lambda { task('package').invoke }.should_not raise_error
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should generate package with files exported from dependency" do
|
161
|
+
task('package').invoke
|
162
|
+
open_main_manifest_section do |attribs|
|
163
|
+
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "using classpath to specify dependencies" do
|
169
|
+
before do
|
170
|
+
write "src/main/java/com/biz/Foo.java", <<SRC
|
171
|
+
package com.biz;
|
172
|
+
public class Foo {}
|
173
|
+
SRC
|
174
|
+
write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
|
175
|
+
package com.biz.bar;
|
176
|
+
public class Bar {}
|
177
|
+
SRC
|
178
|
+
@foo = define "foo" do
|
179
|
+
project.version = "2.1.3"
|
180
|
+
project.group = "mygroup"
|
181
|
+
package(:bundle).tap do |bnd|
|
182
|
+
bnd['Export-Package'] = 'org.apache.tools.zip.*'
|
183
|
+
bnd.classpath = bnd.classpath + Buildr::Ant.dependencies
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should not raise an error during packaging" do
|
189
|
+
lambda { task('package').invoke }.should_not raise_error
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should generate package with files exported from dependency" do
|
193
|
+
task('package').invoke
|
194
|
+
open_main_manifest_section do |attribs|
|
195
|
+
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe "using compile dependencies to specify dependency" do
|
201
|
+
before do
|
202
|
+
@foo = define "foo" do
|
203
|
+
project.version = "2.1.3"
|
204
|
+
project.group = "mygroup"
|
205
|
+
compile.with Buildr::Ant.dependencies
|
206
|
+
package(:bundle).tap do |bnd|
|
207
|
+
bnd['Export-Package'] = 'org.apache.tools.zip.*'
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should not raise an error during packaging" do
|
213
|
+
lambda { task('package').invoke }.should_not raise_error
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should generate package with files exported from dependency" do
|
217
|
+
task('package').invoke
|
218
|
+
open_main_manifest_section do |attribs|
|
219
|
+
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|