buildr4osgi 0.9.2 → 0.9.3

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.
Files changed (47) hide show
  1. data/buildr4osgi.gemspec +2 -2
  2. data/lib/buildr4osgi.rb +2 -0
  3. data/lib/buildr4osgi/compile.rb +2 -1
  4. data/lib/buildr4osgi/compile/compiler.rb +1 -3
  5. data/lib/buildr4osgi/compile/external.rb +71 -0
  6. data/lib/buildr4osgi/eclipse.rb +3 -1
  7. data/lib/buildr4osgi/eclipse/feature.rb +12 -7
  8. data/lib/buildr4osgi/eclipse/p2.rb +137 -0
  9. data/lib/buildr4osgi/eclipse/site.rb +207 -0
  10. data/lib/buildr4osgi/osgi/bundle.rb +17 -12
  11. data/lib/buildr4osgi/osgi/bundle_package.rb +35 -11
  12. data/lib/buildr4osgi/osgi/container.rb +1 -0
  13. data/lib/buildr4osgi/osgi/execution_environment.rb +199 -0
  14. data/lib/buildr4osgi/osgi/library_extension.rb +14 -1
  15. data/lib/buildr4osgi/osgi/packaging_sources.rb +4 -0
  16. data/lib/buildr4osgi/osgi/project_extension.rb +59 -20
  17. data/lib/buildr4osgi/osgi/registry.rb +23 -29
  18. data/lib/buildr4osgi/osgi/resolving_strategies.rb +1 -0
  19. data/lib/buildr4osgi/osgi/version.rb +1 -1
  20. data/rakelib/all-in-one.rake +84 -0
  21. data/rakelib/stage.rake +5 -4
  22. data/spec/compile/external_spec.rb +41 -0
  23. data/spec/eclipse/p2_spec.rb +65 -0
  24. data/spec/eclipse/site_spec.rb +94 -0
  25. data/spec/osgi/bundle_package_spec.rb +13 -1
  26. data/spec/osgi/bundle_spec.rb +2 -2
  27. data/spec/osgi/execution_environment_spec.rb +48 -0
  28. data/spec/osgi/library_extension_spec.rb +15 -2
  29. data/spec/osgi/project_extension_spec.rb +86 -18
  30. data/spec/osgi/registry_spec.rb +30 -20
  31. data/spec/osgi/resolving_strategies_spec.rb +2 -2
  32. data/spec/osgi/version_spec.rb +6 -0
  33. data/spec/spec_helpers.rb +12 -0
  34. metadata +12 -16
  35. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.jar +0 -0
  36. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.pom +0 -82
  37. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.jar +0 -0
  38. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.pom +0 -478
  39. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8-sources.jar +0 -0
  40. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.jar +0 -0
  41. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.pom +0 -30
  42. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8-sources.jar +0 -0
  43. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar +0 -0
  44. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.pom +0 -101
  45. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8-sources.jar +0 -0
  46. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar +0 -0
  47. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.pom +0 -56
@@ -13,6 +13,8 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
+ require File.join(File.dirname(__FILE__), 'execution_environment')
17
+
16
18
  module OSGi
17
19
 
18
20
  OSGI_GROUP_ID = "osgi"
@@ -61,6 +63,10 @@ module OSGi
61
63
  @containers = [Buildr.settings.user, Buildr.settings.build].inject([]) { |repos, hash|
62
64
  repos | Array(hash['osgi'] && hash['osgi']['containers'])
63
65
  }
66
+ if ENV['OSGI'] && !ENV['OSGi']
67
+ warn "The correct constant to define for the OSGi containers is named OSGi"
68
+ ENV['OSGi'] = ENV['OSGI']
69
+ end
64
70
  if ENV['OSGi']
65
71
  @containers |= ENV['OSGi'].split(';')
66
72
  end
@@ -80,19 +86,6 @@ module OSGi
80
86
  end
81
87
  end
82
88
 
83
- class OSGi #:nodoc:
84
-
85
- attr_reader :options, :registry
86
-
87
- def initialize(project)
88
- if (project.parent)
89
- @options = project.parent.osgi.options.dup
90
- @registry = project.parent.osgi.registry.dup
91
- end
92
- @options ||= Options.new
93
- @registry ||= ::OSGi::Registry.new
94
- end
95
-
96
89
  # The options for the osgi.options method
97
90
  # package_resolving_strategy:
98
91
  # The package resolving strategy, it should be a symbol representing a module function in the OSGi::PackageResolvingStrategies module.
@@ -102,30 +95,31 @@ module OSGi
102
95
  # A set of Proc objects to match a bundle to a groupId for maven.
103
96
  # The array is examined with the latest added Procs first.
104
97
  # The first proc to return a non-nil answer is used, otherwise the OGSGI_GROUP_ID constant is used.
105
- class Options
98
+ class Options < ::OSGi::ExecutionEnvironmentConfiguration
106
99
  attr_accessor :package_resolving_strategy, :bundle_resolving_strategy
107
100
 
108
101
  def initialize
102
+ super
109
103
  @package_resolving_strategy = :all
110
104
  @bundle_resolving_strategy = :latest
111
105
  end
112
-
113
106
  end
114
- end
115
-
116
- module OSGiOptions
117
- include Extension
118
107
 
119
- # Makes a osgi instance available to the project.
120
- # The osgi object may be used to access OSGi containers
121
- # or set options, currently the resolving strategies.
122
- def osgi
123
- @osgi ||= OSGi.new(self)
124
- @osgi
108
+ # Calls to this method return true if the package name passed as argument
109
+ # is either part of the packages of the framework given by the execution environment
110
+ # or part of the extra packages specified by the user.
111
+ #
112
+ def is_framework_package?(name)
113
+ options.current_execution_environment.packages.include?(name) || options.extra_packages.include?(name)
125
114
  end
115
+
116
+
117
+ def options
118
+ @options ||= Options.new
126
119
  end
127
- end
128
-
129
- class Buildr::Project
130
- include OSGi::OSGiOptions
120
+
121
+ def registry
122
+ @registry ||= ::OSGi::Registry.new
123
+ end
124
+
131
125
  end
@@ -51,6 +51,7 @@ module OSGi #:nodoc:
51
51
  # This is the default function.
52
52
  #
53
53
  def all(package, bundles)
54
+ warn "*** SPLIT PACKAGE: #{package} is exported by <#{bundles.join(", ")}>"
54
55
  return bundles
55
56
  end
56
57
 
@@ -91,7 +91,7 @@ module OSGi #:nodoc:
91
91
  #
92
92
  def self.parse(string, max_infinite = false)
93
93
  return string if string.is_a?(VersionRange) || string.is_a?(Version)
94
- if !string.nil? && (match = string.match /\s*([\[|\(])([0-9|\.]*),([0-9|\.]*)([\]|\)])/)
94
+ if !string.nil? && (match = string.match /\s*([\[|\(])([0-9|A-z|\.]*)\s*,\s*([0-9|A-z|\.]*)([\]|\)])/)
95
95
  range = VersionRange.new
96
96
  range.min = Version.new(match[2])
97
97
  range.max = Version.new(match[3])
@@ -0,0 +1,84 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ desc "Create JRuby all-in-one distribution"
17
+ task "all-in-one" => :gem do
18
+ version = "1.4.0"
19
+ jruby_distro = "jruby-bin-#{version}.tar.gz"
20
+ url = "http://jruby.kenai.com/downloads/#{version}/#{jruby_distro}"
21
+ dir = "jruby-#{version}"
22
+
23
+ mkpath '_all-in-one'
24
+ cd '_all-in-one'
25
+
26
+ # Download and extract JRuby
27
+ lambda do
28
+ unless File.exist? jruby_distro
29
+ puts "Downloading JRuby from #{url} ..."
30
+ sh 'wget', url
31
+ puts "[X] Downloaded JRuby"
32
+ end
33
+
34
+ rm_rf dir if File.exist? dir
35
+
36
+ puts "Extracting JRuby to #{dir} ..."
37
+ sh 'tar', 'xzf', jruby_distro
38
+ puts "[X] Extracted JRuby"
39
+ cd dir
40
+ end.call
41
+
42
+ # Cleanup JRuby distribution
43
+ lambda do
44
+ rm_rf 'docs'
45
+ mkpath 'jruby-docs'
46
+ mv Dir["COPYING*"], 'jruby-docs'
47
+ mv Dir["LICENSE*"], 'jruby-docs'
48
+ mv 'README', 'jruby-docs'
49
+ rm_rf 'lib/ruby/1.9'
50
+ rm_rf 'lib/ruby/gems/1.8/doc'
51
+ rm_rf 'samples'
52
+ rm_rf 'share'
53
+ end.call
54
+
55
+ # Install Buildr gem and dependencies
56
+ lambda do
57
+ puts "Install Buildr gem ..."
58
+ sh "bin/jruby", '-S', 'gem', 'install', FileList['../../pkg/*-java.gem'].first, FileList['../../../buildr4osgi*.gem'].first,
59
+ '--no-rdoc', '--no-ri'
60
+ puts "[X] Install Buildr gem"
61
+ end.call
62
+
63
+ # Add Buildr executables/scripts
64
+ lambda do
65
+ cp 'bin/jruby.exe', 'bin/_buildr.exe'
66
+ cp Dir["../../all-in-one/*"], 'bin'
67
+ end.call
68
+
69
+ # Package distribution
70
+ lambda do
71
+ puts "Zipping distribution ..."
72
+ cd '..'
73
+ new_dir = "#{spec.name}-#{spec.version}-#{dir}"
74
+ mv dir, new_dir
75
+ zip = "#{new_dir}.zip"
76
+ rm zip if File.exist? zip
77
+ sh 'zip', '-q', '-r', zip, new_dir
78
+ puts "[X] Zipped distribution"
79
+ rm_rf new_dir
80
+ end.call
81
+
82
+ end
83
+
84
+ task(:clobber) { rm_rf '_all-in-one' }
data/rakelib/stage.rake CHANGED
@@ -113,7 +113,7 @@ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
113
113
  File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
114
114
  sh 'gpg2', '--local-user', args.gpg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
115
115
  end
116
- cp 'etc/KEYS', '_staged'
116
+ cp 'etc/KEYS', '_staged/dist'
117
117
  puts "[X] Created and signed release packages in _staged/dist"
118
118
  end.call
119
119
 
@@ -121,10 +121,11 @@ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
121
121
  # want to do that before generating the site/documentation.
122
122
  lambda do
123
123
  puts "Updating download page with links to release packages ... "
124
- url = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
124
+ mirror = "http://www.apache.org/dyn/closer.cgi/#{spec.name}/#{spec.version}"
125
+ official = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
125
126
  rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
126
127
  name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
127
- %{| "#{name}":#{url}/#{name} | "#{md5}":#{url}/#{name}.md5 | "Sig":#{url}/#{name}.asc |}
128
+ %{| "#{name}":#{mirror}/#{name} | "#{md5}":#{official}/#{name}.md5 | "Sig":#{official}/#{name}.asc |}
128
129
  }
129
130
  textile = <<-TEXTILE
130
131
  h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
@@ -132,7 +133,7 @@ h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
132
133
  |_. Package |_. MD5 Checksum |_. PGP |
133
134
  #{rows.join("\n")}
134
135
 
135
- p>. ("Release signing keys":#{url}/KEYS)
136
+ p>. ("Release signing keys":#{official}/KEYS)
136
137
  TEXTILE
137
138
  file_name = 'doc/download.textile'
138
139
  print "Adding download links to #{file_name} ... "
@@ -0,0 +1,41 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+ describe Buildr4OSGi::CompilerSupport::ExternalC do
20
+
21
+ before :all do
22
+ Buildr::Compiler.compilers.delete Buildr::Compiler::Javac
23
+ Buildr::Compiler.compilers.delete Buildr4OSGi::CompilerSupport::OSGiC
24
+ end
25
+
26
+ describe "should compile a Java project just in the same way javac does" do
27
+ javac_spec = File.read(File.join(File.dirname(__FILE__), "..", "..", "buildr", "spec", "java", "compiler_spec.rb"))
28
+ javac_spec = javac_spec.match(Regexp.escape("require File.join(File.dirname(__FILE__), '../spec_helpers')\n")).post_match
29
+ javac_spec.gsub!("javac", "externalc")
30
+ javac_spec.gsub!("nowarn", "warn:none")
31
+ eval(javac_spec)
32
+ end
33
+
34
+ after :all do
35
+ Buildr::Compiler.compilers << Buildr::Compiler::Javac
36
+ Buildr::Compiler.compilers.unshift Buildr4OSGi::CompilerSupport::OSGiC
37
+ end
38
+
39
+ end
40
+
41
+
@@ -0,0 +1,65 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe Buildr4OSGi::P2 do
19
+
20
+ before(:each) do
21
+ Buildr::write "bar/src/main/java/Hello.java", "public class Hello {}"
22
+ @container = define("container") do
23
+ project.group = "grp"
24
+ @bar = define("bar", :version => "1.0.0") do
25
+ package(:bundle)
26
+ package(:sources)
27
+ end
28
+ end
29
+ @foo = define("foo", :version => "1.0.0") do
30
+ f = package(:feature)
31
+ f.plugins << project("container:bar")
32
+ f.label = "My feature"
33
+ f.provider = "Acme Inc"
34
+ f.description = "The best feature ever"
35
+ f.changesURL = "http://example.com/changes"
36
+ f.license = "The license is too long to explain"
37
+ f.licenseURL = "http://example.com/license"
38
+ f.branding_plugin = "com.musal.ui"
39
+ f.update_sites << {:url => "http://example.com/update", :name => "My update site"}
40
+ f.discovery_sites = [{:url => "http://example.com/update2", :name => "My update site2"},
41
+ {:url => "http://example.com/upup", :name => "My update site in case"}]
42
+ #package(:sources)
43
+ end
44
+
45
+ @bar = define("bar", :version => "1.0")
46
+ site = @bar.package(:site)
47
+ category = Buildr4OSGi::Category.new
48
+ category.name = "category.id"
49
+ category.label = "Some Label"
50
+ category.description = "The category is described here"
51
+ category.features<< @foo
52
+ site.categories << category
53
+ site
54
+
55
+ end
56
+
57
+ it "should generate a p2 site" do
58
+ @p2 = project("foo") do
59
+ package(:p2_from_site).with :site => @bar
60
+ end
61
+ @p2.package(:p2_from_site).invoke
62
+
63
+
64
+ end
65
+ end
@@ -0,0 +1,94 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe Buildr4OSGi::SiteWriter do
19
+
20
+ before(:each) do
21
+ class SiteWriterTester
22
+
23
+ end
24
+ @f_w = SiteWriterTester.new
25
+ @f_w.extend Buildr4OSGi::SiteWriter
26
+ Buildr::write "bar/src/main/java/Hello.java", "public class Hello {}"
27
+ @container = define("container") do
28
+ project.group = "grp"
29
+ @bar = define("bar", :version => "1.0.0") do
30
+ package(:bundle)
31
+ package(:sources)
32
+ end
33
+ end
34
+ @foo = define("foo", :version => "1.0.0") do
35
+ f = package(:feature)
36
+ f.plugins << project("container:bar")
37
+ f.label = "My feature"
38
+ f.provider = "Acme Inc"
39
+ f.description = "The best feature ever"
40
+ f.changesURL = "http://example.com/changes"
41
+ f.license = "The license is too long to explain"
42
+ f.licenseURL = "http://example.com/license"
43
+ f.branding_plugin = "com.musal.ui"
44
+ f.update_sites << {:url => "http://example.com/update", :name => "My update site"}
45
+ f.discovery_sites = [{:url => "http://example.com/update2", :name => "My update site2"},
46
+ {:url => "http://example.com/upup", :name => "My update site in case"}]
47
+ #package(:sources)
48
+ end
49
+ end
50
+
51
+ it "should write a valid site.xml" do
52
+ @f_w.description = "Description"
53
+ @f_w.description_url = "http://www.example.com/description"
54
+ category = Buildr4OSGi::Category.new
55
+ category.name = "category.id"
56
+ category.label = "Some Label"
57
+ category.description = "The category is described here"
58
+ category.features<< @foo
59
+ @f_w.categories << category
60
+ @f_w.writeSiteXml({@foo.package(:feature).to_s => {:id => "foo", :version => "1.0.0"}}).should == <<-SITE_XML
61
+ <?xml version="1.0" encoding="UTF-8"?>
62
+ <site pack200="false">
63
+ <description url="http://www.example.com/description">Description</description>
64
+ <category-def name="category.id" label="Some Label">
65
+ <description>The category is described here</description>
66
+ </category-def>
67
+ <feature url="features/foo_1.0.0.jar" version="1.0.0" patch="false" id="foo">
68
+ <category name="category.id"/>
69
+ </feature>
70
+ </site>
71
+ SITE_XML
72
+ end
73
+
74
+ it "should create a zip file containing site.xml at its root" do
75
+ @bar = define("bar", :version => "1.0")
76
+ site = @bar.package(:site)
77
+ category = Buildr4OSGi::Category.new
78
+ category.name = "category.id"
79
+ category.label = "Some Label"
80
+ category.description = "The category is described here"
81
+ category.features<< @foo
82
+ site.categories << category
83
+ site.invoke
84
+ File.should exist(site.to_s)
85
+ Zip::ZipFile.open(site.to_s) do |zip|
86
+ print zip.entries.join("\n")
87
+ print zip.read("site.xml")
88
+ zip.find_entry("plugins").should_not be_nil
89
+ zip.find_entry("features").should_not be_nil
90
+ end
91
+ end
92
+
93
+
94
+ end
@@ -27,6 +27,18 @@ describe OSGi::BundlePackage do
27
27
  it 'should be able to know if it equals another bundle package' do
28
28
  package = OSGi::BundlePackage.new("my.package", "1.0.0")
29
29
  package2 = OSGi::BundlePackage.new("my.package", "1.0.0")
30
- package.eql?(package2).should be_true
30
+ package.should == package2
31
+ end
32
+
33
+ it 'should be able to know if it equals another bundle package with version range' do
34
+ package = OSGi::BundlePackage.new("javax.servlet", "[2.4.0,3.0.0)")
35
+ package2 = OSGi::BundlePackage.new("javax.servlet", "[2.4.0,3.0.0)")
36
+ package.should == package2
37
+ end
38
+
39
+ it 'should define the same hash when bundles are equal' do
40
+ package = OSGi::BundlePackage.new("my.package", "1.0.0")
41
+ package2 = OSGi::BundlePackage.new("my.package", "1.0.0")
42
+ package.hash.should == package2.hash
31
43
  end
32
44
  end