buildr4osgi 0.9.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/buildr4osgi.gemspec +2 -2
  2. data/lib/buildr4osgi/compile/compiler.rb +23 -5
  3. data/lib/buildr4osgi/compile.rb +1 -1
  4. data/lib/buildr4osgi/eclipse/feature.rb +206 -65
  5. data/lib/buildr4osgi/osgi/bundle.rb +5 -7
  6. data/lib/buildr4osgi/osgi/bundle_package.rb +2 -2
  7. data/lib/buildr4osgi/osgi/container.rb +5 -0
  8. data/lib/buildr4osgi/osgi/dependencies.rb +91 -0
  9. data/lib/buildr4osgi/osgi/library_extension.rb +6 -4
  10. data/lib/buildr4osgi/osgi/packaging.rb +78 -6
  11. data/lib/buildr4osgi/osgi/packaging_sources.rb +86 -0
  12. data/lib/buildr4osgi/osgi/project_extension.rb +9 -115
  13. data/lib/buildr4osgi/osgi/registry.rb +71 -1
  14. data/lib/buildr4osgi/osgi/resolving_strategies.rb +4 -2
  15. data/lib/buildr4osgi/osgi.rb +2 -0
  16. data/lib/buildr4osgi.rb +0 -1
  17. data/rakelib/release.rake +3 -0
  18. data/rakelib/rspec.rake +3 -3
  19. data/rakelib/stage.rake +7 -0
  20. data/spec/compile/compiler_spec.rb +40 -8
  21. data/spec/eclipse/feature_spec.rb +103 -6
  22. data/spec/osgi/bundle_spec.rb +2 -2
  23. data/spec/osgi/dependencies_spec.rb +91 -0
  24. data/spec/osgi/library_extension_spec.rb +17 -0
  25. data/spec/osgi/packaging_sources_spec.rb +71 -0
  26. data/spec/osgi/packaging_spec.rb +11 -1
  27. data/spec/osgi/project_extension_spec.rb +31 -21
  28. data/spec/osgi/registry_spec.rb +31 -0
  29. data/spec/osgi/resolving_strategies_spec.rb +116 -0
  30. data/spec/spec_helpers.rb +2 -2
  31. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.jar +0 -0
  32. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.pom +478 -0
  33. metadata +10 -13
  34. data/lib/buildr4osgi/nature/eclipse.rb +0 -80
  35. data/lib/buildr4osgi/nature/java.rb +0 -32
  36. data/lib/buildr4osgi/nature/nature.rb +0 -156
  37. data/lib/buildr4osgi/nature/osgi.rb +0 -32
  38. data/lib/buildr4osgi/nature/scala.rb +0 -32
  39. data/spec/nature/eclipse_spec.rb +0 -46
  40. data/spec/nature/java_spec.rb +0 -45
  41. data/spec/nature/osgi_spec.rb +0 -63
  42. data/spec/nature/scala_spec.rb +0 -45
  43. data/spec/nature_spec.rb +0 -144
@@ -25,7 +25,74 @@ module OSGi
25
25
  module BundlePackaging
26
26
 
27
27
  end
28
+
29
+ #monkey patch the Unzip task to support unzipping tgz
30
+ #TODO: find out how to apply the patterns (include/exclude) and move this to buildr eventually
31
+ class Buildr::Unzip
32
+ def extract
33
+ # If no paths specified, then no include/exclude patterns
34
+ # specified. Nothing will happen unless we include all files.
35
+ if @paths.empty?
36
+ @paths[nil] = FromPath.new(self, nil)
37
+ end
38
+
39
+ # Otherwise, empty unzip creates target as a file when touching.
40
+ mkpath target.to_s
41
+ zip_file_path = zip_file.to_s
42
+ if zip_file_path.match /\.[t?]gz$/ or zip_file_path.match /\.tar\.gz$/
43
+ #un-tar.gz
44
+ @paths.each do |path, patterns|
45
+ patterns.include = ['*'] if patterns.include.nil?
46
+ patterns.exclude = [] if patterns.exclude.nil?
47
+ end
48
+ Zlib::GzipReader.open(zip_file_path) { |tar|
49
+ Archive::Tar::Minitar::Input.open(tar) do |inp|
50
+ inp.each do |entry|
51
+ if included?(entry.full_name)
52
+ trace "Extracting #{entry.full_name}"
53
+ inp.extract_entry(target.to_s, entry)
54
+ end
55
+ end
56
+ end
57
+ }
58
+ else
59
+ Zip::ZipFile.open(zip_file.to_s) do |zip|
60
+ entries = zip.collect
61
+ @paths.each do |path, patterns|
62
+ patterns.map(entries).each do |dest, entry|
63
+ next if entry.directory?
64
+ dest = File.expand_path(dest, target.to_s)
65
+ trace "Extracting #{dest}"
66
+ mkpath File.dirname(dest) rescue nil
67
+ entry.restore_permissions = true
68
+ entry.extract(dest) { true }
69
+ end
70
+ end
71
+ end
72
+ end
73
+ # Let other tasks know we updated the target directory.
74
+ touch target.to_s
75
+ end
28
76
 
77
+ #reads the includes/excludes and apply them to the entry_name
78
+ def included?(entry_name)
79
+ @paths.each do |path, patterns|
80
+ return true if path.nil?
81
+ if entry_name =~ /^#{path}/
82
+ short = entry_name.sub(path, '')
83
+ if patterns.include.any? { |pattern| File.fnmatch(pattern, entry_name) } &&
84
+ !patterns.exclude.any? { |pattern| File.fnmatch(pattern, entry_name) }
85
+ # trace "tar_entry.full_name " + entry_name + " is included"
86
+ return true
87
+ end
88
+ end
89
+ end
90
+ # trace "tar_entry.full_name " + entry_name + " is excluded"
91
+ return false
92
+ end
93
+
94
+ end
95
+
29
96
 
30
97
  #
31
98
  # The task to package a project
@@ -61,7 +128,7 @@ module OSGi
61
128
  def is_packaging_osgi_bundle()
62
129
  packages.each {|package| return true if package.is_a?(::OSGi::BundlePackaging)}
63
130
  return false
64
- end
131
+ end
65
132
 
66
133
  def package_as_bundle(file_name)
67
134
  task = BundleTask.define_task(file_name).tap do |plugin|
@@ -78,6 +145,12 @@ module OSGi
78
145
  p_r.exclude("bin").exclude("bin/**")
79
146
  p_r.exclude("target/**").exclude("target")
80
147
 
148
+
149
+ properties = ResourcesTask.define_task
150
+ properties.send :associate_with, project, :main
151
+ properties.from(File.join(project.base_dir, project.layout[:source, :main, :java])).
152
+ exclude("**/.*").exclude("**/*.java") if File.exists? File.join(project.base_dir, project.layout[:source, :main, :java])
153
+
81
154
  manifest_location = File.join(project.base_dir, "META-INF", "MANIFEST.MF")
82
155
  manifest = project.manifest
83
156
  if File.exists?(manifest_location)
@@ -85,19 +158,18 @@ module OSGi
85
158
  manifest = project.manifest.merge(read_m)
86
159
  end
87
160
  manifest["Bundle-Version"] = project.version # the version of the bundle packaged is ALWAYS the version of the project.
88
- manifest["Bundle-SymbolicName"] ||= project.id # if it was resetted to nil, we force the id to be added back.
89
-
161
+ manifest["Bundle-SymbolicName"] ||= project.name.split(":").last # if it was resetted to nil, we force the id to be added back.
90
162
  plugin.with :manifest=> manifest, :meta_inf=>meta_inf
91
- plugin.with [compile.target, resources.target, p_r.target].compact
163
+ plugin.with [compile.target, resources.target, p_r.target, properties.target].compact
92
164
  end
93
165
  end
94
166
 
95
167
  def package_as_bundle_spec(spec) #:nodoc:
96
- spec.merge(:type=>:jar)
168
+ spec.merge(:type=>:jar, :id => name.split(":").last)
97
169
  end
98
170
 
99
171
  before_define do |project|
100
- project.manifest["Bundle-SymbolicName"] = project.id
172
+ project.manifest["Bundle-SymbolicName"] = project.name.split(":").last
101
173
  project.manifest["Bundle-Name"] = project.comment || project.name
102
174
  project.manifest["Bundle-Version"] = project.version
103
175
  end
@@ -0,0 +1,86 @@
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
+ module OSGi
17
+
18
+ # generate an Eclipse-SourceBundle manifest from the manifest of a runtime plugin
19
+ # Assumes that there are no jars inside the runtime plugin.
20
+ def self.create_source_bundle_manifest(pluginManifest)
21
+ #remove the properties after the sym-name such as ';singleton=true'
22
+ bundleSymName = pluginManifest["Bundle-SymbolicName"].split(';').first
23
+ bundleVersion = pluginManifest["Bundle-Version"]
24
+ sourcesManifest = ::Buildr::Packaging::Java::Manifest.new(nil)
25
+ sourcesManifest.main["Bundle-ManifestVersion"] = "2"
26
+ sourcesManifest.main["Eclipse-SourceBundle"] = "#{bundleSymName};version=\"#{bundleVersion}\";roots:=\".\""
27
+ sourcesManifest.main["Bundle-SymbolicName"] = bundleSymName + ".sources"
28
+ sourcesManifest.main["Bundle-Name"] += " sources" if sourcesManifest.main["Bundle-Name"]
29
+ sourcesManifest.main["Bundle-Version"] = bundleVersion
30
+ sourcesManifest.main["Bundle-Vendor"] = pluginManifest["Bundle-Vendor"] unless pluginManifest["Bundle-Vendor"].nil?
31
+ #TODO: ability to define a different license for the sources.
32
+ sourcesManifest.main["Bundle-License"] = pluginManifest["Bundle-License"] unless pluginManifest["Bundle-License"].nil?
33
+ return sourcesManifest
34
+ end
35
+
36
+
37
+ #:nodoc:
38
+ # This module is used to identify the packaging task
39
+ # that represent a bundle packaging.
40
+ #
41
+ module PackagingAsSourcesExtension #:nodoc:
42
+ include Extension
43
+
44
+ # Change the zip classifier for the sources produced by
45
+ # a jar classifier unless we are packaking a feature right now.
46
+ def package_as_sources_spec_source_extension(spec) #:nodoc:
47
+ spec = package_as_sources_spec_before_source_extension(spec)
48
+ if is_packaging_osgi_bundle
49
+ spec.merge!(:type=>:jar, :id => name.split(":").last)
50
+ end
51
+ spec
52
+ end
53
+
54
+ # if the current packaging is a plugin or a bundle
55
+ # then call package_as_eclipse_source_feature
56
+ # if the current packaging is a feature
57
+ # then call package_as_eclipse_source_bundle
58
+ def package_as_osgi_pde_sources(file_name)
59
+ return package_as_eclipse_source_bundle(file_name) if project.send :is_packaging_osgi_bundle
60
+ package_as_sources_old(file_name)
61
+ end
62
+
63
+
64
+ # package as an OSGi bundle that contains the sources
65
+ # of the bundle. Specialized for eclipse-PDE version 3.4.0 and more recent
66
+ # http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.pde.doc.user/tasks/pde_individual_source.htm
67
+ # file_name
68
+ def package_as_eclipse_source_bundle(file_name)
69
+ pluginManifest = package(:plugin).manifest
70
+ sourcesManifest = ::OSGi::create_source_bundle_manifest(pluginManifest)
71
+ package_as_sources_old(file_name).with :manifest => sourcesManifest
72
+ end
73
+ end
74
+ end
75
+
76
+ module Buildr #:nodoc:
77
+ class Project #:nodoc:
78
+ include OSGi::PackagingAsSourcesExtension
79
+
80
+ protected
81
+ alias :package_as_sources_spec_before_source_extension :package_as_sources_spec
82
+ alias :package_as_sources_spec :package_as_sources_spec_source_extension
83
+ alias :package_as_sources_old :package_as_sources
84
+ alias :package_as_sources :package_as_osgi_pde_sources
85
+ end
86
+ end
@@ -76,35 +76,18 @@ module OSGi
76
76
  project.projects.each do |subp|
77
77
  collect(subp)
78
78
  _projects[subp.name] = projects.collect {|p| p.name}.uniq.sort
79
- _dependencies[subp.name] = bundles.sort
79
+ _dependencies[subp.name] = bundles.collect {|b| b.to_s }.uniq.sort
80
80
  end
81
81
 
82
82
  collect(project)
83
- _dependencies[project.name] = bundles.sort
83
+ _dependencies[project.name] = bundles.collect {|b| b.to_s }.uniq.sort
84
84
  _projects[project.name] = projects.collect {|p| p.name}.uniq.sort
85
85
 
86
- def find_root(project)
87
- project.parent.nil? ? project : project.parent
88
- end
89
-
90
- base_dir = find_root(project).base_dir
91
- written_dependencies = YAML.load(File.read(File.join(base_dir, "dependencies.yml"))) if File.exists? File.join(base_dir, "dependencies.yml")
92
- written_dependencies ||= {}
93
- written_dependencies.extend SortedHash
94
-
95
-
96
- _projects.keys.each {|p|
97
- written_dependencies[p] ||= {}
98
- written_dependencies[p].extend SortedHash
99
- written_dependencies[p]["dependencies"] ||= []
100
- written_dependencies[p]["projects"] ||= []
101
- written_dependencies[p]["dependencies"] |= _dependencies[p]
102
- written_dependencies[p]["projects"] |= _projects[p]
103
- written_dependencies[p]["dependencies"].sort!
104
- written_dependencies[p]["projects"].sort!
86
+ dependencies = ::OSGi::Dependencies.new(project)
87
+ dependencies.write(_projects.keys) {|hash, p|
88
+ hash[p]["dependencies"] |= _dependencies[p]
89
+ hash[p]["projects"] |= _projects[p]
105
90
  }
106
-
107
- Buildr::write File.join(base_dir, "dependencies.yml"), written_dependencies.to_yaml
108
91
  end
109
92
  end
110
93
  end
@@ -213,47 +196,9 @@ module OSGi
213
196
  # This method is used recursively, so beware of cyclic dependencies.
214
197
  #
215
198
  def dependencies(&block)
216
-
217
- deps = Dependencies.new
218
- deps.read(project)
219
- return deps.projects + deps.dependencies
220
- end
221
-
222
- class OSGi #:nodoc:
223
-
224
- attr_reader :options, :registry
225
-
226
- def initialize(project)
227
- if (project.parent)
228
- @options = project.parent.osgi.options.dup
229
- @registry = project.parent.osgi.registry.dup
230
- end
231
- @options ||= Options.new
232
- @registry ||= ::OSGi::Registry.new
233
- end
234
-
235
- # The options for the osgi.options method
236
- # package_resolving_strategy:
237
- # The package resolving strategy, it should be a symbol representing a module function in the OSGi::PackageResolvingStrategies module.
238
- # bundle_resolving_strategy:
239
- # The bundle resolving strategy, it should be a symbol representing a module function in the OSGi::BundleResolvingStrategies module.
240
- class Options
241
- attr_accessor :package_resolving_strategy, :bundle_resolving_strategy
242
-
243
- def initialize
244
- @package_resolving_strategy = :all
245
- @bundle_resolving_strategy = :latest
246
- end
247
-
248
- end
249
- end
250
-
251
- # Makes a osgi instance available to the project.
252
- # The osgi object may be used to access OSGi containers
253
- # or set options, currently the resolving strategies.
254
- def osgi
255
- @osgi ||= OSGi.new(self)
256
- @osgi
199
+ deps = ::OSGi::Dependencies.new(project)
200
+ deps.read
201
+ deps.dependencies + deps.projects
257
202
  end
258
203
 
259
204
  # returns an array of the dependencies of the plugin, read from the manifest.
@@ -264,57 +209,6 @@ module OSGi
264
209
 
265
210
  end
266
211
 
267
- private
268
-
269
- #
270
- # A class to read dependencies.yml, and get a flat array of projects and dependencies for a project.
271
- class Dependencies
272
-
273
- attr_accessor :dependencies, :projects
274
-
275
- def read(project)
276
- def find_root(project)
277
- project.parent.nil? ? project : project.parent
278
- end
279
-
280
- base_dir = find_root(project).base_dir
281
- @dependencies = []
282
- @projects = []
283
- @deps_yml = {}
284
- return unless File.exists? File.join(base_dir, "dependencies.yml")
285
- @deps_yml =YAML.load(File.read(File.join(base_dir, "dependencies.yml")))
286
- return if @deps_yml[project.name].nil? || @deps_yml[project.name]["dependencies"].nil?
287
- _read(project.name, false)
288
- @dependencies = @dependencies.flatten.compact.uniq
289
- return @dependencies, @projects
290
- end
291
-
292
- private
293
-
294
- def _read(project, add_project = true)
295
- @dependencies |= @deps_yml[project]["dependencies"]
296
- projects << Buildr::project(project) if add_project
297
- @deps_yml[project]["projects"].each {|p| _read(p) unless projects.include?(p)}
298
- end
299
- end
300
-
301
- # Copy/pasted from here: http://snippets.dzone.com/posts/show/5811
302
- # no author information though.
303
- module SortedHash
304
-
305
- # Replacing the to_yaml function so it'll serialize hashes sorted (by their keys)
306
- #
307
- # Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb
308
- def to_yaml( opts = {} )
309
- YAML::quick_emit( object_id, opts ) do |out|
310
- out.map( taguri, to_yaml_style ) do |map|
311
- sort.each do |k, v| # <-- here's my addition (the 'sort')
312
- map.add( k, v )
313
- end
314
- end
315
- end
316
- end
317
- end
318
212
  end
319
213
 
320
214
  module Buildr #:nodoc:
@@ -15,6 +15,28 @@
15
15
 
16
16
  module OSGi
17
17
 
18
+ OSGI_GROUP_ID = "osgi"
19
+
20
+ class GroupMatcher
21
+ include Singleton
22
+ attr_accessor :group_matchers
23
+
24
+ def initialize
25
+ @group_matchers = []
26
+ # Default rule for Eclipse artifacts.
27
+ @group_matchers << Proc.new {|n| "org.eclipse" if n.match(/org\.eclipse\..*/) }
28
+ end
29
+
30
+ def group(bundle)
31
+ return group(bundle.id) if bundle.is_a?(Bundle)
32
+ group_matchers.reverse.each do |group|
33
+ result = group.call(bundle)
34
+ return result unless result.nil?
35
+ end
36
+ OSGI_GROUP_ID
37
+
38
+ end
39
+ end
18
40
  #
19
41
  # A class to hold the registered containers. It is possible to add containers until resolved_containers is called,
20
42
  # after which it is not possible to modify the registry anymore.
@@ -53,9 +75,57 @@ module OSGi
53
75
  # Containers are resolved only once.
54
76
  #
55
77
  def resolved_containers
56
- @resolved_containers ||= containers.collect { |container| OSGi::Container.new(container) }
78
+ @resolved_containers ||= containers.collect { |container| Container.new(container) }
57
79
  @resolved_containers
58
80
  end
59
81
  end
60
82
 
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
+ # The options for the osgi.options method
97
+ # package_resolving_strategy:
98
+ # The package resolving strategy, it should be a symbol representing a module function in the OSGi::PackageResolvingStrategies module.
99
+ # bundle_resolving_strategy:
100
+ # The bundle resolving strategy, it should be a symbol representing a module function in the OSGi::BundleResolvingStrategies module.
101
+ # group_matchers:
102
+ # A set of Proc objects to match a bundle to a groupId for maven.
103
+ # The array is examined with the latest added Procs first.
104
+ # The first proc to return a non-nil answer is used, otherwise the OGSGI_GROUP_ID constant is used.
105
+ class Options
106
+ attr_accessor :package_resolving_strategy, :bundle_resolving_strategy
107
+
108
+ def initialize
109
+ @package_resolving_strategy = :all
110
+ @bundle_resolving_strategy = :latest
111
+ end
112
+
113
+ end
114
+ end
115
+
116
+ module OSGiOptions
117
+ include Extension
118
+
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
125
+ end
126
+ end
127
+ end
128
+
129
+ class Buildr::Project
130
+ include OSGi::OSGiOptions
61
131
  end
@@ -28,7 +28,7 @@ module OSGi #:nodoc:
28
28
  #
29
29
  def prompt(package, bundles)
30
30
  bundle = nil
31
- while (!bundle)
31
+ while (bundle.nil?)
32
32
  puts "This package #{package} is exported by all the bundles present.\n" +
33
33
  "Choose a bundle amongst those presented or press A to select them all:\n" + bundles.sort! {|a, b| a.version <=> b.version }.
34
34
  collect {|b| "\t#{bundles.index(b) +1}. #{b.name} #{b.version}"}.join("\n")
@@ -38,6 +38,7 @@ module OSGi #:nodoc:
38
38
  number = number.to_i
39
39
  number -= 1
40
40
  bundle = bundles[number] if number >= 0 # no negative indexing here.
41
+ puts "Invalid index" if number < 0
41
42
  rescue Exception => e
42
43
  puts "Invalid index"
43
44
  #do nothing
@@ -83,7 +84,7 @@ module OSGi #:nodoc:
83
84
  #
84
85
  def prompt(bundles)
85
86
  bundle = nil
86
- while (!bundle)
87
+ while (bundle.nil?)
87
88
  puts "Choose a bundle amongst those presented:\n" + bundles.sort! {|a, b| a.version <=> b.version }.
88
89
  collect {|b| "\t#{bundles.index(b) +1}. #{b.name} #{b.version}"}.join("\n")
89
90
  number = gets.chomp
@@ -91,6 +92,7 @@ module OSGi #:nodoc:
91
92
  number = number.to_i
92
93
  number -= 1
93
94
  bundle = bundles[number] if number >= 0 # no negative indexing here.
95
+ puts "Invalid index" if number < 0
94
96
  rescue Exception => e
95
97
  puts "Invalid index"
96
98
  #do nothing
@@ -15,10 +15,12 @@
15
15
 
16
16
  require 'buildr4osgi/osgi/version'
17
17
  require 'buildr4osgi/osgi/packaging'
18
+ require 'buildr4osgi/osgi/packaging_sources'
18
19
  require 'buildr4osgi/osgi/bundle'
19
20
  require 'buildr4osgi/osgi/bundle_package'
20
21
  require 'buildr4osgi/osgi/container'
21
22
  require 'buildr4osgi/osgi/registry'
22
23
  require 'buildr4osgi/osgi/resolving_strategies'
24
+ require 'buildr4osgi/osgi/dependencies'
23
25
  require 'buildr4osgi/osgi/project_extension'
24
26
  require 'buildr4osgi/osgi/library_extension'
data/lib/buildr4osgi.rb CHANGED
@@ -13,7 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- require 'buildr4osgi/nature'
17
16
  require 'buildr4osgi/osgi'
18
17
  require 'buildr4osgi/eclipse'
19
18
  require 'buildr4osgi/compile'
data/rakelib/release.rake CHANGED
@@ -45,6 +45,9 @@ task :release do
45
45
 
46
46
  # Upload binary and source packages to RubyForge.
47
47
  lambda do
48
+ sh 'rubyforge', 'login'
49
+ # update rubyforge projects, processors, etc. in local config
50
+ sh 'rubyforge', 'config'
48
51
  files = FileList["_release/#{spec.version}/dist/*.{gem,tgz,zip}"]
49
52
  puts "Uploading #{spec.version} to RubyForge ... "
50
53
  rubyforge = RubyForge.new.configure
data/rakelib/rspec.rake CHANGED
@@ -19,10 +19,10 @@ begin
19
19
  directory '_reports'
20
20
 
21
21
  desc "Run all specs"
22
- Spec::Rake::SpecTask.new :spec=>'_reports' do |task|
22
+ Spec::Rake::SpecTask.new :spec=>['_reports', :compile] do |task|
23
23
  task.spec_files = FileList['spec/**/*_spec.rb']
24
24
  task.spec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
25
- task.spec_opts = %w{--format specdoc --format failing_examples:failed --format html:_reports/specs.html --loadby mtime --backtrace}
25
+ task.spec_opts = %w{--format specdoc --format failing_examples:failed --format html:_reports/specs.html --backtrace}
26
26
  task.spec_opts << '--colour' if $stdout.isatty
27
27
  end
28
28
  file('_reports/specs.html') { task(:spec).invoke }
@@ -35,7 +35,7 @@ begin
35
35
  end
36
36
 
37
37
  desc 'Run RSpec and generate Spec and coverage reports (slow)'
38
- Spec::Rake::SpecTask.new :coverage=>'_reports' do |task|
38
+ Spec::Rake::SpecTask.new :coverage=>['_reports', :compile] do |task|
39
39
  task.spec_files = FileList['spec/**/*_spec.rb']
40
40
  task.spec_opts = %W{--format progress --format failing_examples:failed --format html:_reports/specs.html --backtrace}
41
41
  task.spec_opts << '--colour' if $stdout.isatty
data/rakelib/stage.rake CHANGED
@@ -62,6 +62,13 @@ task :prepare do |task, args|
62
62
  puts "[X] We have JRuby, Scala and Groovy"
63
63
  end.call
64
64
 
65
+ # Need Prince to generate PDF
66
+ lambda do
67
+ puts "Checking that we have prince available ... "
68
+ sh 'prince --version'
69
+ puts "[X] We have prince available"
70
+ end.call
71
+
65
72
  # Need RubyForge to upload new release files.
66
73
  lambda do
67
74
  puts "[!] Make sure you have admin privileges to make a release on RubyForge"
@@ -13,18 +13,50 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- =begin
16
+
17
17
  require File.join(File.dirname(__FILE__), '../spec_helpers')
18
18
 
19
19
  describe Buildr4OSGi::CompilerSupport::OSGiC do
20
- it "should compile a Java project just in the same way javac does" do
21
-
20
+ describe "should compile a Java project just in the same way javac does" do
21
+ javac_spec = File.read(File.join(File.dirname(__FILE__), "..", "..", "buildr", "spec", "java", "compiler_spec.rb"))
22
+ javac_spec = javac_spec.match(Regexp.escape("require File.join(File.dirname(__FILE__), '../spec_helpers')\n")).post_match
23
+ javac_spec.gsub!("javac", "osgic")
24
+ javac_spec.gsub!("nowarn", "warn:none")
25
+ eval(javac_spec)
26
+ end
27
+
28
+ # Redirect the java error ouput, yielding so you can do something while it is
29
+ # and returning the content of the error buffer.
30
+ #
31
+ def redirect_java_err
32
+ byteArray = Rjb::import('java.io.ByteArrayOutputStream')
33
+ printStream = Rjb::import('java.io.PrintStream')
34
+ err = byteArray.new()
35
+ Rjb::import('java.lang.System').err = printStream.new(err)
36
+ yield
37
+ err.toString
38
+ end
39
+
40
+ it "should not issue warnings for type casting when warnings are set to warn:none" do
41
+ write "src/main/java/Main.java", "import java.util.List; public class Main {public List get() {return null;}}"
42
+ foo = define("foo") {
43
+ compile.options.source = "1.5"
44
+ compile.options.target = "1.5"
45
+ }
46
+ redirect_java_err { foo.compile.invoke }.should_not match(/WARNING/)
22
47
  end
23
48
 
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)
49
+ it "should not issue warnings for type casting when warnings are set to warn:none" do
50
+ write "src/main/java/Main.java", "import java.util.List; public class Main {public List get() {return null;}}"
51
+ foo = define("foo") {
52
+ compile.options.source = "1.5"
53
+ compile.options.target = "1.5"
54
+ compile.options.warnings = true
55
+ }
56
+ redirect_java_err { foo.compile.invoke }.should match(/WARNING/)
57
+ end
58
+
59
+
28
60
  end
29
61
 
30
- =end
62
+