buildr4osgi 0.9.0

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 (71) hide show
  1. data/LICENSE +176 -0
  2. data/NOTICE +6 -0
  3. data/README.rdoc +50 -0
  4. data/Rakefile +45 -0
  5. data/buildr4osgi.gemspec +40 -0
  6. data/lib/buildr4osgi/compile/compiler.rb +54 -0
  7. data/lib/buildr4osgi/compile/ecj-3.4.1.jar +0 -0
  8. data/lib/buildr4osgi/compile.rb +16 -0
  9. data/lib/buildr4osgi/eclipse/feature.rb +271 -0
  10. data/lib/buildr4osgi/eclipse/plugin.rb +22 -0
  11. data/lib/buildr4osgi/eclipse.rb +17 -0
  12. data/lib/buildr4osgi/nature/eclipse.rb +80 -0
  13. data/lib/buildr4osgi/nature/java.rb +32 -0
  14. data/lib/buildr4osgi/nature/nature.rb +156 -0
  15. data/lib/buildr4osgi/nature/osgi.rb +32 -0
  16. data/lib/buildr4osgi/nature/scala.rb +32 -0
  17. data/lib/buildr4osgi/nature.rb +23 -0
  18. data/lib/buildr4osgi/osgi/bundle.rb +275 -0
  19. data/lib/buildr4osgi/osgi/bundle_package.rb +80 -0
  20. data/lib/buildr4osgi/osgi/container.rb +140 -0
  21. data/lib/buildr4osgi/osgi/library_extension.rb +174 -0
  22. data/lib/buildr4osgi/osgi/packaging.rb +129 -0
  23. data/lib/buildr4osgi/osgi/project_extension.rb +324 -0
  24. data/lib/buildr4osgi/osgi/registry.rb +61 -0
  25. data/lib/buildr4osgi/osgi/resolving_strategies.rb +104 -0
  26. data/lib/buildr4osgi/osgi/version.rb +131 -0
  27. data/lib/buildr4osgi/osgi.rb +24 -0
  28. data/lib/buildr4osgi.rb +37 -0
  29. data/rakelib/checks.rake +57 -0
  30. data/rakelib/doc.rake +92 -0
  31. data/rakelib/jekylltask.rb +120 -0
  32. data/rakelib/package.rake +73 -0
  33. data/rakelib/release.rake +149 -0
  34. data/rakelib/rspec.rake +73 -0
  35. data/rakelib/setup.rake +54 -0
  36. data/rakelib/stage.rake +206 -0
  37. data/spec/compile/compiler_spec.rb +30 -0
  38. data/spec/eclipse/feature_spec.rb +295 -0
  39. data/spec/nature/eclipse_spec.rb +46 -0
  40. data/spec/nature/java_spec.rb +45 -0
  41. data/spec/nature/osgi_spec.rb +63 -0
  42. data/spec/nature/scala_spec.rb +45 -0
  43. data/spec/nature_spec.rb +144 -0
  44. data/spec/osgi/bundle_package_spec.rb +32 -0
  45. data/spec/osgi/bundle_spec.rb +202 -0
  46. data/spec/osgi/container_spec.rb +93 -0
  47. data/spec/osgi/library_extension_spec.rb +142 -0
  48. data/spec/osgi/packaging_spec.rb +340 -0
  49. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/ECLIPSEF.RSA +0 -0
  50. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/ECLIPSEF.SF +20 -0
  51. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/MANIFEST.MF +28 -0
  52. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/eclipse.inf +3 -0
  53. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/about.html +28 -0
  54. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/fragment.properties +12 -0
  55. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/runtime_registry_compatibility.jar +0 -0
  56. data/spec/osgi/project_extension_spec.rb +662 -0
  57. data/spec/osgi/registry_spec.rb +50 -0
  58. data/spec/osgi/version_spec.rb +127 -0
  59. data/spec/spec_helpers.rb +85 -0
  60. 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
  61. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.pom +82 -0
  62. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8-sources.jar +0 -0
  63. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.jar +0 -0
  64. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.pom +30 -0
  65. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8-sources.jar +0 -0
  66. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar +0 -0
  67. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.pom +101 -0
  68. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8-sources.jar +0 -0
  69. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar +0 -0
  70. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.pom +56 -0
  71. metadata +142 -0
@@ -0,0 +1,206 @@
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 'digest/md5'
18
+ require 'digest/sha1'
19
+
20
+ begin # Releases upload Gems to RubyForge.
21
+ require 'rubyforge'
22
+ rescue LoadError
23
+ task(:setup) { install_gem 'rubyforge' }
24
+ end
25
+
26
+
27
+ task :prepare do |task, args|
28
+ # Make sure we're doing a release from checked code.
29
+ lambda do
30
+ puts "Checking there are no local changes ... "
31
+ svn = `svn status`
32
+ fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
33
+ git = `git status`
34
+ fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^#\t/]
35
+ puts "[X] There are no local changes, everything is in source control"
36
+ end.call
37
+
38
+ # Make sure we have a valid CHANGELOG entry for this release.
39
+ lambda do
40
+ puts "Checking that CHANGELOG indicates most recent version and today's date ... "
41
+ expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
42
+ header = File.readlines('CHANGELOG').first.chomp
43
+ fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
44
+ puts "[x] CHANGELOG indicates most recent version and today's date"
45
+ end.call
46
+
47
+ # Need GPG to sign the packages.
48
+ lambda do
49
+ args.gpg or fail "Please run with gpg=<argument for gpg --local-user>"
50
+ fail "No GPG user #{args.gpg}" if `gpg2 --list-keys #{args.gpg}`.empty?
51
+ end.call
52
+
53
+ task(:license).invoke
54
+ task(:dependency).invoke
55
+
56
+ # Need JRuby, Scala and Groovy installed to run all the specs.
57
+ lambda do
58
+ puts "Checking that we have JRuby, Scala and Groovy available ... "
59
+ sh 'jruby --version'
60
+ sh 'scala -version'
61
+ sh 'groovy -version'
62
+ puts "[X] We have JRuby, Scala and Groovy"
63
+ end.call
64
+
65
+ # Need RubyForge to upload new release files.
66
+ lambda do
67
+ puts "[!] Make sure you have admin privileges to make a release on RubyForge"
68
+ rubyforge = RubyForge.new.configure
69
+ rubyforge.login
70
+ rubyforge.scrape_project(spec.name)
71
+ end.call
72
+
73
+ # We will be speccing in one platform, so also spec the other one.
74
+ task(RUBY_PLATFORM =~ /java/ ? 'spec:ruby' : 'spec:jruby').invoke # Test the *other* platform
75
+ end
76
+
77
+
78
+ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
79
+ mkpath '_staged'
80
+
81
+ # Start by figuring out what has changed.
82
+ lambda do
83
+ puts "Looking for changes between this release and previous one ..."
84
+ pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
85
+ changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
86
+ current = changes[spec.version.to_s]
87
+ fail "No changeset found for version #{spec.version}" unless current
88
+ File.open '_staged/CHANGES', 'w' do |file|
89
+ file.write "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})\n"
90
+ file.write current
91
+ end
92
+ puts "[X] Listed most recent changed in _staged/CHANGES"
93
+ end.call
94
+
95
+ # Create the packages (gem, tarball) and sign them. This requires user
96
+ # intervention so the earlier we do it the better.
97
+ lambda do
98
+ puts "Creating and signing release packages ..."
99
+ task(:package).invoke
100
+ mkpath '_staged/dist'
101
+ FileList['pkg/*.{gem,zip,tgz}'].each do |source|
102
+ pkg = source.pathmap('_staged/dist/%n%x')
103
+ cp source, pkg
104
+ bytes = File.open(pkg, 'rb') { |file| file.read }
105
+ File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
106
+ File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
107
+ sh 'gpg2', '--local-user', args.gpg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
108
+ end
109
+ cp 'etc/KEYS', '_staged'
110
+ puts "[X] Created and signed release packages in _staged/dist"
111
+ end.call
112
+
113
+ # The download page should link to the new binaries/sources, and we
114
+ # want to do that before generating the site/documentation.
115
+ lambda do
116
+ puts "Updating download page with links to release packages ... "
117
+ url = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
118
+ rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
119
+ name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
120
+ %{| "#{name}":#{url}/#{name} | "#{md5}":#{url}/#{name}.md5 | "Sig":#{url}/#{name}.asc |}
121
+ }
122
+ textile = <<-TEXTILE
123
+ h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
124
+
125
+ |_. Package |_. MD5 Checksum |_. PGP |
126
+ #{rows.join("\n")}
127
+
128
+ p>. ("Release signing keys":#{url}/KEYS)
129
+ TEXTILE
130
+ file_name = 'doc/download.textile'
131
+ print "Adding download links to #{file_name} ... "
132
+ modified = File.read(file_name).sub(/^h2\(#dist\).*$/) { |header| "#{header}\n\n#{textile}" }
133
+ File.open file_name, 'w' do |file|
134
+ file.write modified
135
+ end
136
+ puts "[X] Updated #{file_name}"
137
+ end.call
138
+
139
+
140
+ # Now we can create the Web site, this includes running specs, coverage report, etc.
141
+ # This will take a while, so we want to do it as last step before upload.
142
+ lambda do
143
+ puts "Creating new Web site"
144
+ task(:site).invoke
145
+ cp_r '_site', '_staged/site'
146
+ puts "[X] Created new Web site in _staged/site"
147
+ end.call
148
+
149
+
150
+ # Move everything over to people.apache.org so we can vote on it.
151
+ lambda do
152
+ url = "people.apache.org:~/public_html/#{spec.name}/#{spec.version}"
153
+ puts "Uploading _staged directory to #{url} ..."
154
+ sh 'rsync', '--progress', '--recursive', '_staged/', url
155
+ puts "[X] Uploaded _staged directory to #{url}"
156
+ end.call
157
+
158
+
159
+ # Prepare a release vote email. In the distant future this will also send the
160
+ # email for you and vote on it.
161
+ lambda do
162
+ # Need to know who you are on Apache, local user may be different (see .ssh/config).
163
+ whoami = `ssh people.apache.org whoami`.strip
164
+ base_url = "http://people.apache.org/~#{whoami}/buildr/#{spec.version}"
165
+ # Need changes for this release only.
166
+ changelog = File.read('CHANGELOG').scan(/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/)
167
+ changes = changelog[0][2]
168
+ previous_version = changelog[1][1]
169
+
170
+ email = <<-EMAIL
171
+ To: dev@buildr.apache.org
172
+ Subject: [VOTE] Buildr #{spec.version} release
173
+
174
+ We're voting on the source distributions available here:
175
+ #{base_url}/dist/
176
+
177
+ Specifically:
178
+ #{base_url}/dist/buildr-#{spec.version}.tgz
179
+ #{base_url}/dist/buildr-#{spec.version}.zip
180
+
181
+ The documentation generated for this release is available here:
182
+ #{base_url}/site/
183
+ #{base_url}/site/buildr.pdf
184
+
185
+ The official specification against which this release was tested:
186
+ #{base_url}/site/specs.html
187
+
188
+ Test coverage report:
189
+ #{base_url}/site/coverage/index.html
190
+
191
+
192
+ The following changes were made since #{previous_version}:
193
+
194
+ #{changes.gsub(/^/, ' ')}
195
+ EMAIL
196
+ File.open 'vote-email.txt', 'w' do |file|
197
+ file.write email
198
+ end
199
+ puts "[X] Created release vote email template in 'vote-email.txt'"
200
+ puts email
201
+ end.call
202
+
203
+ end
204
+
205
+
206
+ task(:clobber) { rm_rf '_staged' }
@@ -0,0 +1,30 @@
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
+ =begin
17
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+ describe Buildr4OSGi::CompilerSupport::OSGiC do
20
+ it "should compile a Java project just in the same way javac does" do
21
+
22
+ end
23
+
24
+ javac_spec = File.read(File.join(File.dirname(__FILE__), "..", "..", "buildr", "spec", "java", "compiler_spec.rb"))
25
+ javac_spec = javac_spec.match(Regexp.escape("require File.join(File.dirname(__FILE__), '../spec_helpers')\n")).post_match
26
+ javac_spec.gsub!("javac", "osgic")
27
+ #eval(javac_spec)
28
+ end
29
+
30
+ =end
@@ -0,0 +1,295 @@
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::FeatureWriter do
19
+
20
+ before(:all) do
21
+ class FeatureWriterTester
22
+
23
+ end
24
+ @f_w = FeatureWriterTester.new
25
+ @f_w.extend Buildr4OSGi::FeatureWriter
26
+ end
27
+ it 'should write a valid feature.xml' do
28
+
29
+ @f_w.feature_id = "myId"
30
+ @f_w.version = "1.0.0.012"
31
+ @f_w.branding_plugin = "myPlugin.id"
32
+ @f_w.copyright = "Copyright (C) 1899-1908, Acme Inc."
33
+ @f_w.update_sites = [{:url => "http://example.com/update1", :name => "Update site 1"},
34
+ {:url => "http://example.com/update2", :name => "Update site 2"}]
35
+ @f_w.discovery_sites = [{:url => "http://example.com/discovery1", :name => "Discovery site 1"},
36
+ {:url => "http://example.com/discovery2", :name => "Discovery site 2"},
37
+ {:url => "http://example.com/discovery3", :name => "Discovery site 3"}]
38
+ feature_xml = @f_w.writeFeatureXml(
39
+ [{:id => "myPlugin.id", :version => "2.3.4", :"download-size" => "2", :"install-size" => "3", :unpack => false},
40
+ {:id => "myOtherPlugin.id", :version => "2.3.5", :"download-size" => "25", :"install-size" => "30", :unpack => false},
41
+ {:id => "myBigPlugin.id", :version => "1.2.3.4", :"download-size" => "2", :"install-size" => "300", :unpack => true}],
42
+ true)
43
+ feature_xml.should == <<-FEATURE
44
+ <?xml version="1.0" encoding="UTF-8"?>
45
+ <feature plugin="myPlugin.id" id="myId" version="1.0.0.012" provider-name="%provider.name" label="%feature.name">
46
+ <description url="%changesURL">%description</description>
47
+ <copyright>Copyright (C) 1899-1908, Acme Inc.</copyright>
48
+ <license url="%licenseURL">%license</license>
49
+ <url>
50
+ <update url="http://example.com/update1" label="%updatesite.name0"/>
51
+ <update url="http://example.com/update2" label="%updatesite.name1"/>
52
+ <discovery url="http://example.com/discovery1" label="%discoverysite.name0"/>
53
+ <discovery url="http://example.com/discovery2" label="%discoverysite.name1"/>
54
+ <discovery url="http://example.com/discovery3" label="%discoverysite.name2"/>
55
+ </url>
56
+ <plugin unpack="false" id="myPlugin.id" version="2.3.4" download-size="2" install-size="3"/>
57
+ <plugin unpack="false" id="myOtherPlugin.id" version="2.3.5" download-size="25" install-size="30"/>
58
+ <plugin unpack="true" id="myBigPlugin.id" version="1.2.3.4" download-size="2" install-size="300"/>
59
+ </feature>
60
+ FEATURE
61
+ end
62
+
63
+ it 'should not complain nor write an invalid feature.xml if the plugin argument is nil' do
64
+ @f_w.feature_id = "myId"
65
+ @f_w.version = "1.0.0.012"
66
+ @f_w.branding_plugin = nil
67
+ @f_w.copyright = "Copyright (C) 1899-1908, Acme Inc."
68
+ @f_w.update_sites = [{:url => "http://example.com/update1", :name => "Update site 1"},
69
+ {:url => "http://example.com/update2", :name => "Update site 2"}]
70
+ @f_w.discovery_sites = [{:url => "http://example.com/discovery1", :name => "Discovery site 1"},
71
+ {:url => "http://example.com/discovery2", :name => "Discovery site 2"},
72
+ {:url => "http://example.com/discovery3", :name => "Discovery site 3"}]
73
+ feature_xml = @f_w.writeFeatureXml(
74
+ [{:id => "myPlugin.id", :version => "2.3.4", :"download-size" => "2", :"install-size" => "3", :unpack => false},
75
+ {:id => "myOtherPlugin.id", :version => "2.3.5", :"download-size" => "25", :"install-size" => "30", :unpack => false},
76
+ {:id => "myBigPlugin.id", :version => "1.2.3.4", :"download-size" => "2", :"install-size" => "300", :unpack => true}],
77
+ true)
78
+ feature_xml = nil
79
+ lambda { feature_xml = @f_w.writeFeatureXml(
80
+ [{:id => "myPlugin.id", :version => "2.3.4", :"download-size" => "2", :"install-size" => "3", :unpack => false},
81
+ {:id => "myOtherPlugin.id", :version => "2.3.5", :"download-size" => "25", :"install-size" => "30", :unpack => false},
82
+ {:id => "myBigPlugin.id", :version => "1.2.3.4", :"download-size" => "2", :"install-size" => "300", :unpack => true}]) }.should_not raise_error
83
+ feature_xml.should_not match(/plugin="nil"/)
84
+ feature_xml.should_not match(/plugin=""/)
85
+ end
86
+
87
+ it "should write a valid feature.properties" do
88
+ @f_w.label = "my Feature"
89
+ @f_w.provider = "Acme Inc."
90
+ @f_w.changesURL = "http://example.com/changes"
91
+ @f_w.description = "Best feature ever"
92
+ @f_w.licenseURL = "http://www.example.com/license"
93
+ @f_w.license = "This license is an example."
94
+ @f_w.update_sites = [{:url => "http://example.com/update1", :name => "Update site 1"},
95
+ {:url => "http://example.com/update2", :name => "Update site 2"}]
96
+ @f_w.discovery_sites = [{:url => "http://example.com/discovery1", :name => "Discovery site 1"},
97
+ {:url => "http://example.com/discovery2", :name => "Discovery site 2"},
98
+ {:url => "http://example.com/discovery3", :name => "Discovery site 3"}]
99
+ feature_properties = @f_w.writeFeatureProperties()
100
+ feature_properties.should == <<-PROPERTIES
101
+ # Built by Buildr4OSGi
102
+
103
+ feature.name=my Feature
104
+ provider.name=Acme Inc.
105
+ changesURL=http://example.com/changes
106
+ description=Best feature ever
107
+ licenseURL=http://www.example.com/license
108
+ license=This license is an example.
109
+
110
+ PROPERTIES
111
+ end
112
+
113
+ end
114
+
115
+
116
+ describe Buildr4OSGi::FeatureTask, "configuration" do
117
+
118
+ it "should accept the feature parameters" do
119
+ foo = define("foo", :version => "1.0.0")
120
+ f = foo.package(:feature)
121
+ lambda {
122
+ f.plugins << "com.my:plugin:1.0:jar"
123
+ f.label = "My feature"
124
+ f.provider = "Acme Inc"
125
+ f.copyright = "Copyright 1089-2345 Acme Inc"
126
+ f.description = "The best feature ever"
127
+ f.changesURL = "http://example.com/changes"
128
+ f.license = "The license is too long to explain"
129
+ f.licenseURL = "http://example.com/license"
130
+ f.branding_plugin = "com.musal.ui"
131
+ f.update_sites << {:url => "http://example.com/update", :name => "My update site"}
132
+ f.discovery_sites = [{:url => "http://example.com/update2", :name => "My update site2"},
133
+ {:url => "http://example.com/upup", :name => "My update site in case"}]
134
+ }.should_not raise_error
135
+ end
136
+
137
+ it "should accept using an existing feature.xml without a feature.properties" do
138
+ featurexml = <<-FEATURE
139
+ <feature/>
140
+ FEATURE
141
+ Buildr::write "feature.xml", featurexml
142
+ foo = define("foo", :version => "1.0.0")
143
+ foo.package(:feature).feature_xml = "feature.xml"
144
+
145
+ foo.package(:feature).invoke
146
+ feature_file = File.join(foo.base_dir, "target", "foo-1.0.0-feature.jar")
147
+ Zip::ZipFile.open(feature_file) do |zip|
148
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil
149
+ zip.read("eclipse/features/foo_1.0.0/feature.xml").should == featurexml
150
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should be_nil
151
+ end
152
+ end
153
+
154
+ it "should accept using an existing feature.xml, and an optional feature.properties" do
155
+ featurexml = <<-FEATURE
156
+ <feature/>
157
+ FEATURE
158
+ featurep = <<-PROPS
159
+ key=value
160
+ PROPS
161
+ Buildr::write "feature.xml", featurexml
162
+ Buildr::write "feature.properties", featurep
163
+ foo = define("foo", :version => "1.0.0")
164
+ foo.package(:feature).feature_xml = "feature.xml"
165
+ foo.package(:feature).feature_properties = "feature.properties"
166
+ foo.package(:feature).invoke
167
+ feature_file = File.join(foo.base_dir, "target", "foo-1.0.0-feature.jar")
168
+ Zip::ZipFile.open(feature_file) do |zip|
169
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil
170
+ zip.read("eclipse/features/foo_1.0.0/feature.xml").should == featurexml
171
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should_not be_nil
172
+ zip.read("eclipse/features/foo_1.0.0/feature.properties").should == featurep
173
+ end
174
+ end
175
+
176
+ it "should generate feature.xml without externalizing strings when passed an existing feature.properties" do
177
+ featurep = <<-PROPS
178
+ provider.0=My own provider
179
+ PROPS
180
+ Buildr::write "feature.properties", featurep
181
+ foo = define("foo", :version => "1.0.0")
182
+ f = foo.package(:feature)
183
+ f.feature_properties = "feature.properties"
184
+ f.plugins << DEBUG_UI
185
+ f.label = "My feature"
186
+ f.provider = "%provider.0"
187
+ f.copyright = "Copyright 1089-2345 Acme Inc"
188
+ f.description = "The best feature ever"
189
+ f.changesURL = "http://example.com/changes"
190
+ f.license = "The license is too long to explain"
191
+ f.licenseURL = "http://example.com/license"
192
+ foo.package(:feature).invoke
193
+ feature_file = File.join(foo.base_dir, "target", "foo-1.0.0-feature.jar")
194
+ Zip::ZipFile.open(feature_file) do |zip|
195
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil
196
+ feature_xml = zip.read("eclipse/features/foo_1.0.0/feature.xml")
197
+ feature_xml.should_not match(/%label/)
198
+ feature_xml.should match(/%provider\.0/)
199
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should_not be_nil
200
+ zip.read("eclipse/features/foo_1.0.0/feature.properties").should == featurep
201
+ end
202
+ end
203
+ end
204
+
205
+ describe Buildr4OSGi::FeatureTask, " when running" do
206
+
207
+ before do
208
+ @foo = define("foo", :version => "1.0.0")
209
+ f = @foo.package(:feature)
210
+ f.plugins << DEBUG_UI
211
+ f.label = "My feature"
212
+ f.provider = "Acme Inc"
213
+ f.description = "The best feature ever"
214
+ f.changesURL = "http://example.com/changes"
215
+ f.license = "The license is too long to explain"
216
+ f.licenseURL = "http://example.com/license"
217
+ f.branding_plugin = "com.musal.ui"
218
+ f.update_sites << {:url => "http://example.com/update", :name => "My update site"}
219
+ f.discovery_sites = [{:url => "http://example.com/update2", :name => "My update site2"},
220
+ {:url => "http://example.com/upup", :name => "My update site in case"}]
221
+ end
222
+
223
+ it "should create a jar file with a eclipse/plugins and a eclipse/features structure" do
224
+ @foo.package(:feature).invoke
225
+ feature_file = File.join(@foo.base_dir, "target", "foo-1.0.0-feature.jar")
226
+ File.exists?(feature_file).should be_true
227
+ Zip::ZipFile.open(feature_file) do |zip|
228
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil
229
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should_not be_nil
230
+ zip.find_entry("eclipse/plugins/org.eclipse.debug.ui_3.4.1.v20080811_r341.jar").should_not be_nil
231
+ end
232
+ end
233
+
234
+ it 'should complain if one of the dependencies is not a plugin' do
235
+ @foo.package(:feature).plugins << SLF4J
236
+ lambda { @foo.package(:feature).invoke}.should raise_error(
237
+ /The dependency .* is not an Eclipse plugin: make sure the headers Bundle-SymbolicName and Bundle-Version are present in the manifest/)
238
+ end
239
+
240
+ it "should let the user tell which plugins should be unjarred" do
241
+ f = @foo.package(:feature)
242
+ f.plugins.clear
243
+ @bar = define("bar", :version => "1.0.0") do
244
+ package(:jar).with :manifest => {"Bundle-SymbolicName" => "bar", "Bundle-Version" => "1.0.0"}
245
+ end
246
+ f.plugins.<< DEBUG_UI, :unjarred => true
247
+ f.plugins.<< @bar, :unjarred => true
248
+ @foo.package(:feature).invoke
249
+ feature_file = @foo.package(:feature).to_s
250
+ File.exists?(feature_file).should be_true
251
+ Zip::ZipFile.open(feature_file) do |zip|
252
+ zip.find_entry("eclipse/plugins/org.eclipse.debug.ui_3.4.1.v20080811_r341/META-INF/MANIFEST.MF").should_not be_nil
253
+ zip.find_entry("eclipse/plugins/bar_1.0.0/META-INF/MANIFEST.MF").should_not be_nil
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ describe Buildr4OSGi::FeatureTask, " package subprojects" do
260
+
261
+ before do
262
+ @container = define("container") do
263
+ @bar = define("bar", :version => "1.0.0") do
264
+ package(:jar).with :manifest => {"Bundle-SymbolicName" => "bar", "Bundle-Version" => "1.0.0"}
265
+ end
266
+ end
267
+ @foo = define("foo", :version => "1.0.0")
268
+ f = @foo.package(:feature)
269
+ f.plugins << project("container:bar")
270
+ f.label = "My feature"
271
+ f.provider = "Acme Inc"
272
+ f.description = "The best feature ever"
273
+ f.changesURL = "http://example.com/changes"
274
+ f.license = "The license is too long to explain"
275
+ f.licenseURL = "http://example.com/license"
276
+ f.branding_plugin = "com.musal.ui"
277
+ f.update_sites << {:url => "http://example.com/update", :name => "My update site"}
278
+ f.discovery_sites = [{:url => "http://example.com/update2", :name => "My update site2"},
279
+ {:url => "http://example.com/upup", :name => "My update site in case"}]
280
+ end
281
+
282
+ it "should create a jar file with the subproject packaged as a jar inside it" do
283
+ @foo.package(:feature).invoke
284
+ feature_file = @foo.package(:feature).to_s
285
+ File.exists?(feature_file).should be_true
286
+ Zip::ZipFile.open(feature_file) do |zip|
287
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.xml").should_not be_nil
288
+ zip.find_entry("eclipse/features/foo_1.0.0/feature.properties").should_not be_nil
289
+ zip.find_entry("eclipse/plugins/bar_1.0.0.jar").should_not be_nil
290
+ zip.find_entry("eclipse/plugins/bar_1.0.0.jar").directory?.should be_false
291
+ end
292
+ end
293
+
294
+
295
+ end
@@ -0,0 +1,46 @@
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 Buildr::Nature::Eclipse do
19
+ after :all do
20
+ #empty the registry.
21
+ module Buildr
22
+ module Nature
23
+ module Registry
24
+ @registered_natures = DEFAULT.dup
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ it 'should replace the default Eclipse object' do
31
+ define('foo').eclipse.should be_instance_of(Buildr::Nature::Eclipse::Eclipse)
32
+ end
33
+
34
+ it 'should use project natures to define Eclipse options' do
35
+ class DummyNature < Buildr::DefaultNature
36
+ def initialize()
37
+ super(:dummy)
38
+ eclipse.natures = 'MyNature'
39
+ end
40
+ end
41
+ Buildr::Nature::Registry.add_nature(DummyNature.new)
42
+ define('foo', :natures => :dummy).eclipse.options.natures.should == ['MyNature']
43
+ end
44
+
45
+
46
+ end
@@ -0,0 +1,45 @@
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 'Buildr::JavaNature' do
19
+
20
+ it 'should be registered as :java' do
21
+ Buildr::Nature::Registry.get(:java).should_not be_nil
22
+ end
23
+
24
+ it 'should define some Eclipse options' do
25
+ java = Buildr::Nature::Registry.get(:java)
26
+ java.eclipse.natures.should include("org.eclipse.jdt.core.javanature")
27
+ java.eclipse.builders.should include("org.eclipse.jdt.core.javabuilder")
28
+ java.eclipse.classpath_containers.should include("org.eclipse.jdt.launching.JRE_CONTAINER")
29
+ end
30
+
31
+ it 'should apply when a java source folder is present' do
32
+ foo = define('foo') {write('src/main/java')}
33
+ java = Buildr::Nature::Registry.get(:java)
34
+ java.applies(foo).should be_true
35
+ foo.applicable_natures.should include(java)
36
+ end
37
+
38
+ it 'should not apply when no java source folder is present' do
39
+ bar = define('bar') {write('src/main/c++')}
40
+ java = Buildr::Nature::Registry.get(:java)
41
+ java.applies(bar).should_not be_true
42
+ bar.applicable_natures.should_not include(java)
43
+ end
44
+
45
+ end