buildr4osgi 0.9.0 → 0.9.2
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/buildr4osgi.gemspec +2 -2
- data/lib/buildr4osgi/compile/compiler.rb +23 -5
- data/lib/buildr4osgi/compile.rb +1 -1
- data/lib/buildr4osgi/eclipse/feature.rb +206 -65
- data/lib/buildr4osgi/osgi/bundle.rb +5 -7
- data/lib/buildr4osgi/osgi/bundle_package.rb +2 -2
- data/lib/buildr4osgi/osgi/container.rb +5 -0
- data/lib/buildr4osgi/osgi/dependencies.rb +91 -0
- data/lib/buildr4osgi/osgi/library_extension.rb +6 -4
- data/lib/buildr4osgi/osgi/packaging.rb +78 -6
- data/lib/buildr4osgi/osgi/packaging_sources.rb +86 -0
- data/lib/buildr4osgi/osgi/project_extension.rb +9 -115
- data/lib/buildr4osgi/osgi/registry.rb +71 -1
- data/lib/buildr4osgi/osgi/resolving_strategies.rb +4 -2
- data/lib/buildr4osgi/osgi.rb +2 -0
- data/lib/buildr4osgi.rb +0 -1
- data/rakelib/release.rake +3 -0
- data/rakelib/rspec.rake +3 -3
- data/rakelib/stage.rake +7 -0
- data/spec/compile/compiler_spec.rb +40 -8
- data/spec/eclipse/feature_spec.rb +103 -6
- data/spec/osgi/bundle_spec.rb +2 -2
- data/spec/osgi/dependencies_spec.rb +91 -0
- data/spec/osgi/library_extension_spec.rb +17 -0
- data/spec/osgi/packaging_sources_spec.rb +71 -0
- data/spec/osgi/packaging_spec.rb +11 -1
- data/spec/osgi/project_extension_spec.rb +31 -21
- data/spec/osgi/registry_spec.rb +31 -0
- data/spec/osgi/resolving_strategies_spec.rb +116 -0
- data/spec/spec_helpers.rb +2 -2
- data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.jar +0 -0
- data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.pom +478 -0
- metadata +10 -13
- data/lib/buildr4osgi/nature/eclipse.rb +0 -80
- data/lib/buildr4osgi/nature/java.rb +0 -32
- data/lib/buildr4osgi/nature/nature.rb +0 -156
- data/lib/buildr4osgi/nature/osgi.rb +0 -32
- data/lib/buildr4osgi/nature/scala.rb +0 -32
- data/spec/nature/eclipse_spec.rb +0 -46
- data/spec/nature/java_spec.rb +0 -45
- data/spec/nature/osgi_spec.rb +0 -63
- data/spec/nature/scala_spec.rb +0 -45
- data/spec/nature_spec.rb +0 -144
data/buildr4osgi.gemspec
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
Gem::Specification.new do |spec|
|
18
18
|
spec.name = 'buildr4osgi'
|
19
|
-
spec.version = '0.9.
|
19
|
+
spec.version = '0.9.2'
|
20
20
|
spec.author = 'Antoine Toulme'
|
21
21
|
spec.email = "atoulme@intalio.com"
|
22
22
|
spec.homepage = "http://buildr.apache.org/"
|
@@ -36,5 +36,5 @@ TEXT
|
|
36
36
|
spec.rdoc_options = '--title', 'Buildr4osgi', '--main', 'README.rdoc',
|
37
37
|
'--webcvs', 'http://github.com/intalio/buildr4osgi'
|
38
38
|
spec.post_install_message = "To get started run buildr --help"
|
39
|
-
spec.add_dependency("manifest", "= 0.0.
|
39
|
+
spec.add_dependency("manifest", "= 0.0.7")
|
40
40
|
end
|
@@ -21,7 +21,7 @@ module Buildr4OSGi
|
|
21
21
|
OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
|
22
22
|
|
23
23
|
specify :language=>:java, :sources => 'java', :source_ext => 'java',
|
24
|
-
:target=>'classes', :target_ext=>'class', :packaging=>:
|
24
|
+
:target=>'classes', :target_ext=>'class', :packaging=>:jar
|
25
25
|
|
26
26
|
|
27
27
|
def compile(sources, target, dependencies) #:nodoc:
|
@@ -33,16 +33,34 @@ module Buildr4OSGi
|
|
33
33
|
source_paths = sources.select { |source| File.directory?(source) }
|
34
34
|
cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
|
35
35
|
cmd_args << '-d' << File.expand_path(target)
|
36
|
-
cmd_args +=
|
36
|
+
cmd_args += osgic_args
|
37
37
|
cmd_args += files_from_sources(sources)
|
38
38
|
unless Buildr.application.options.dryrun
|
39
39
|
trace((%w[javac -classpath org.eclipse.jdt.internal.compiler.batch.Main] + cmd_args).join(' '))
|
40
40
|
Java.load
|
41
|
-
Java.org.eclipse.jdt.internal.compiler.batch.Main.
|
42
|
-
|
41
|
+
Java.org.eclipse.jdt.internal.compiler.batch.Main.compile(cmd_args.join(" ")) or
|
42
|
+
fail 'Failed to compile, see errors above'
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# See arg list here: http://publib.boulder.ibm.com/infocenter/rsahelp/v7r0m0/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm
|
49
|
+
def osgic_args #:nodoc:
|
50
|
+
args = []
|
51
|
+
args << '-warn:none' unless options[:warnings]
|
52
|
+
args << '-verbose' if Buildr.application.options.trace
|
53
|
+
args << '-g' if options[:debug]
|
54
|
+
args << '-deprecation' if options[:deprecation]
|
55
|
+
args << '-source' << options[:source].to_s if options[:source]
|
56
|
+
args << '-target' << options[:target].to_s if options[:target]
|
57
|
+
case options[:lint]
|
58
|
+
when Array then args << "-Xlint:#{options[:lint].join(',')}"
|
59
|
+
when String then args << "-Xlint:#{options[:lint]}"
|
60
|
+
when true then args << '-Xlint'
|
61
|
+
end
|
62
|
+
args + Array(options[:other])
|
63
|
+
end
|
46
64
|
|
47
65
|
end
|
48
66
|
|
data/lib/buildr4osgi/compile.rb
CHANGED
@@ -17,20 +17,9 @@ module Buildr4OSGi
|
|
17
17
|
|
18
18
|
module FeatureWriter
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
attr_accessor
|
23
|
-
attr_accessor :copyright
|
24
|
-
attr_accessor :image
|
25
|
-
attr_accessor :provider
|
26
|
-
attr_accessor :description
|
27
|
-
attr_accessor :changesURL
|
28
|
-
attr_accessor :license
|
29
|
-
attr_accessor :licenseURL
|
30
|
-
attr_accessor :branding_plugin
|
31
|
-
|
32
|
-
attr_accessor :update_sites
|
33
|
-
attr_accessor :discovery_sites
|
20
|
+
VARS = [:feature_id, :version, :label, :copyright, :image, :provider, :description, :changesURL, :license, :licenseURL, :branding_plugin, :update_sites, :discovery_sites]
|
21
|
+
|
22
|
+
eval(VARS.collect{|field| "attr_accessor :#{field}"}.join("\n"))
|
34
23
|
|
35
24
|
# :nodoc:
|
36
25
|
# When this module extends an object
|
@@ -120,61 +109,69 @@ PROPERTIES
|
|
120
109
|
|
121
110
|
end
|
122
111
|
|
123
|
-
|
112
|
+
#Marker module common to all feature packaging tasks.
|
113
|
+
#Tasks including this module are recognized internally as tasks packaging features.
|
114
|
+
module FeaturePackaging
|
115
|
+
|
116
|
+
end
|
124
117
|
|
125
118
|
class FeatureTask < ::Buildr::Packaging::Java::JarTask
|
126
|
-
|
119
|
+
include FeaturePackaging
|
127
120
|
attr_accessor :plugins
|
128
121
|
|
129
122
|
attr_accessor :feature_xml
|
130
123
|
attr_accessor :feature_properties
|
124
|
+
|
125
|
+
FeatureWriter::VARS << :plugins
|
126
|
+
FeatureWriter::VARS << :feature_xml
|
127
|
+
FeatureWriter::VARS << :feature_properties
|
128
|
+
FeatureWriter::VARS << :unjarred
|
131
129
|
|
132
130
|
def initialize(*args) #:nodoc:
|
133
131
|
super
|
134
132
|
@unjarred = {}
|
135
133
|
@plugins = ArrayAddWithOptions.new(@unjarred)
|
134
|
+
|
136
135
|
end
|
137
136
|
|
138
137
|
def generateFeature(project)
|
139
|
-
feature_id ||= project.id
|
140
|
-
version ||= project.version
|
141
|
-
|
142
138
|
mkpath File.join(project.base_dir, 'target')
|
143
|
-
resolved_plugins =
|
144
|
-
|
145
|
-
plugins.flatten.each do |plugin|
|
146
|
-
|
147
|
-
artifact = case
|
148
|
-
when plugin.is_a?(String)
|
149
|
-
Buildr::artifact(plugin)
|
150
|
-
when plugin.is_a?(Buildr::Project)
|
151
|
-
Buildr::artifact(plugin.package(:plugin))
|
152
|
-
else
|
153
|
-
plugin
|
154
|
-
end
|
155
|
-
info = adaptPlugin(artifact)
|
156
|
-
info[:unjarred] = @unjarred[plugin]
|
157
|
-
resolved_plugins[info] = artifact
|
158
|
-
end
|
159
|
-
end
|
139
|
+
resolved_plugins = create_resolved_plugins
|
140
|
+
enhance(resolved_plugins.values)
|
160
141
|
unless feature_xml
|
161
142
|
File.open(File.join(project.base_dir, 'target', 'feature.xml'), 'w') do |f|
|
162
143
|
f.write(writeFeatureXml(resolved_plugins.keys, feature_xml.nil? && feature_properties.nil? ))
|
163
144
|
end
|
164
|
-
path("eclipse/features/#{
|
145
|
+
path("eclipse/features/#{feature_id}_#{project.version}").include File.join(project.base_dir, 'target', 'feature.xml')
|
165
146
|
else
|
166
|
-
path("eclipse/features/#{
|
147
|
+
path("eclipse/features/#{feature_id}_#{project.version}").include feature_xml
|
167
148
|
end
|
168
149
|
unless feature_properties || feature_xml
|
169
150
|
File.open(File.join(project.base_dir, 'target', 'feature.properties'), 'w') do |f|
|
170
151
|
f.write(writeFeatureProperties())
|
171
152
|
end
|
172
|
-
path("eclipse/features/#{
|
153
|
+
path("eclipse/features/#{feature_id}_#{project.version}").include File.join(project.base_dir, 'target', 'feature.properties')
|
173
154
|
else
|
174
|
-
path("eclipse/features/#{
|
155
|
+
path("eclipse/features/#{feature_id}_#{project.version}").include feature_properties if feature_properties
|
175
156
|
end
|
176
157
|
|
177
|
-
resolved_plugins.each_pair do |info, plugin|
|
158
|
+
resolved_plugins.each_pair do |info, plugin|
|
159
|
+
unless info[:manifest].nil?
|
160
|
+
cp plugin.to_s, project.path_to("target/#{plugin.id}_#{plugin.version}.jar")
|
161
|
+
plugin = project.path_to("target/#{plugin.id}_#{plugin.version}.jar")
|
162
|
+
::Buildr::Packaging::Java::Manifest.update_manifest(plugin) {|manifest|
|
163
|
+
#applies to sources bundles only: if it was the runtime manifest, then remove it altogether:
|
164
|
+
unless manifest.main["Bundle-SymbolicName"].nil?
|
165
|
+
#there was a symbolic name: assume this manifest was the runtime one.
|
166
|
+
#we don't want OSGi to confuse the runtime jar with the sources.
|
167
|
+
#ideally we would want keep an archive of the original
|
168
|
+
#runtime manifest as for example MANIFEST.MF.source
|
169
|
+
manifest.main.clear
|
170
|
+
end
|
171
|
+
manifest.main.merge! info[:manifest]
|
172
|
+
}
|
173
|
+
end
|
174
|
+
|
178
175
|
if info[:unjarred]
|
179
176
|
merge(plugin, :path => "eclipse/plugins/#{info[:id]}_#{info[:version]}")
|
180
177
|
else
|
@@ -185,49 +182,75 @@ PROPERTIES
|
|
185
182
|
|
186
183
|
protected
|
187
184
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
185
|
+
def create_resolved_plugins
|
186
|
+
resolved_plugins = {}
|
187
|
+
unless @plugins.nil? || @plugins.empty?
|
188
|
+
plugins.flatten.each do |plugin|
|
189
|
+
|
190
|
+
artifact = case
|
191
|
+
when plugin.is_a?(String)
|
192
|
+
Buildr::artifact(plugin)
|
193
|
+
when plugin.is_a?(Buildr::Project)
|
194
|
+
Buildr::artifact(plugin.package(:plugin))
|
195
|
+
else
|
196
|
+
plugin
|
197
|
+
end
|
198
|
+
info = adapt_plugin(artifact)
|
199
|
+
info[:unjarred] = @unjarred[plugin][:unjarred] unless @unjarred[plugin].nil?
|
200
|
+
resolved_plugins[info] = artifact
|
201
|
+
end
|
197
202
|
end
|
198
|
-
|
199
|
-
alias :add :<<
|
200
|
-
alias :<< :add_with_options
|
201
|
-
|
203
|
+
resolved_plugins
|
202
204
|
end
|
203
205
|
|
204
|
-
def
|
206
|
+
def adapt_plugin(plugin)
|
205
207
|
name = nil
|
206
208
|
size = nil
|
207
209
|
version = nil
|
208
210
|
group = nil
|
211
|
+
repackage = nil
|
212
|
+
sourceBundle = nil
|
209
213
|
if plugin.is_a? Buildr::Project
|
210
|
-
plugin.package(:plugin).invoke #make sure it is present.
|
211
214
|
size = File.size(plugin.package(:plugin).to_s)
|
212
215
|
name = plugin.package(:plugin).manifest.main["Bundle-SymbolicName"]
|
213
216
|
version = plugin.package(:plugin).manifest.main["Bundle-Version"]
|
214
|
-
group = plugin.group
|
217
|
+
group = plugin.group
|
218
|
+
sourceBundle = plugin.package(:plugin).manifest.main["Eclipse-SourceBundle"]
|
215
219
|
else
|
216
220
|
plugin.invoke
|
221
|
+
if !File.exist?(plugin.to_s) and plugin.classifier.to_s == 'sources'
|
222
|
+
#make sure the artifact was downloaded.
|
223
|
+
#if the artifact is for the sources feature and it could not be located,
|
224
|
+
#don't crash. should we put something in the manifest?
|
225
|
+
return nil
|
226
|
+
end
|
217
227
|
Zip::ZipFile.open(plugin.to_s) do |zip|
|
218
228
|
entry = zip.find_entry("META-INF/MANIFEST.MF")
|
219
229
|
unless entry.nil?
|
220
230
|
manifest = Manifest.read(zip.read("META-INF/MANIFEST.MF"))
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
231
|
+
sourceBundle = manifest.first["Eclipse-SourceBundle"].keys.first.strip unless manifest.first["Eclipse-SourceBundle"].nil?
|
232
|
+
if !manifest.first["Bundle-SymbolicName"].nil?
|
233
|
+
bundle = ::OSGi::Bundle.fromManifest(manifest, plugin.to_s)
|
234
|
+
unless bundle.nil?
|
235
|
+
name = bundle.name
|
236
|
+
version = bundle.version
|
237
|
+
end
|
225
238
|
end
|
226
239
|
end
|
227
240
|
end
|
228
241
|
group = plugin.to_hash[:group]
|
229
242
|
size = File.size(plugin.to_s)
|
230
243
|
end
|
244
|
+
if plugin.classifier.to_s == 'sources' and (sourceBundle.nil? || name.nil? || version.nil?)
|
245
|
+
# Try, if possible, to get the name and the version from the original binaries then.
|
246
|
+
runtimeArtifact = Buildr::artifact(plugin.to_hash.merge(:classifier => nil, :type => :jar))
|
247
|
+
runtimeManifest = extraPackagedManifest(runtimeArtifact)
|
248
|
+
manifest = ::OSGi::create_source_bundle_manifest(runtimeManifest)
|
249
|
+
repackage = {}
|
250
|
+
manifest.main.each {|key,value| repackage[key] = value }
|
251
|
+
name = repackage["Bundle-SymbolicName"].split(';').first
|
252
|
+
version = repackage["Bundle-Version"]
|
253
|
+
end
|
231
254
|
if (name.nil? || version.nil?)
|
232
255
|
raise "The dependency #{plugin} is not an Eclipse plugin: make sure the headers " +
|
233
256
|
"Bundle-SymbolicName and Bundle-Version are present in the manifest"
|
@@ -237,9 +260,85 @@ PROPERTIES
|
|
237
260
|
size ||= 0
|
238
261
|
end
|
239
262
|
return {:id => name, :group => group, :version => version,
|
240
|
-
:"download-size" => size, :"install-size" => size, :unpack => false}
|
263
|
+
:"download-size" => size, :"install-size" => size, :unpack => false, :manifest => repackage}
|
241
264
|
end
|
265
|
+
|
266
|
+
#returns the META-INF/MANIFEST.MF file for something that
|
267
|
+
#is either an artifact either a the package(:jar) of a buildr project.
|
268
|
+
def extraPackagedManifest(plugin)
|
269
|
+
if plugin.is_a? Buildr::Project
|
270
|
+
return plugin.package(:plugin).manifest
|
271
|
+
else #an artifact
|
272
|
+
plugin.invoke
|
273
|
+
javaManifest = ::Buildr::Packaging::Java::Manifest.from_zip(plugin.to_s)
|
274
|
+
hash = {} #need to make it a hash:
|
275
|
+
javaManifest.main.each {|key,value| hash[key] = value }
|
276
|
+
return hash
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
242
280
|
end
|
281
|
+
|
282
|
+
class ArrayAddWithOptions < Array
|
283
|
+
|
284
|
+
def initialize(options_hash)
|
285
|
+
@options_hash = options_hash
|
286
|
+
end
|
287
|
+
|
288
|
+
def add_with_options(*args)
|
289
|
+
plugin = args.shift
|
290
|
+
options = {}
|
291
|
+
while(!args.empty?)
|
292
|
+
option = args.shift
|
293
|
+
case
|
294
|
+
when option.is_a?(Hash)
|
295
|
+
options.merge!(option)
|
296
|
+
when option.is_a?(Symbol)
|
297
|
+
options.merge!({option => true})
|
298
|
+
else
|
299
|
+
raise "Impossible to find what this option means: #{option}"
|
300
|
+
end
|
301
|
+
end
|
302
|
+
add(plugin)
|
303
|
+
@options_hash[plugin] = options
|
304
|
+
end
|
305
|
+
|
306
|
+
alias :add :<<
|
307
|
+
alias :<< :add_with_options
|
308
|
+
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
module SDKFeatureEnabler
|
313
|
+
|
314
|
+
def create_resolved_plugins
|
315
|
+
resolved_plugins = {}
|
316
|
+
unless @plugins.nil? || @plugins.empty?
|
317
|
+
plugins.flatten.each do |plugin|
|
318
|
+
|
319
|
+
artifact = case
|
320
|
+
when plugin.is_a?(String)
|
321
|
+
Buildr::artifact(plugin)
|
322
|
+
when plugin.is_a?(Buildr::Project)
|
323
|
+
Buildr::artifact(plugin.package(:sources))
|
324
|
+
else
|
325
|
+
plugin
|
326
|
+
end
|
327
|
+
artifact = Buildr::artifact(artifact.to_hash.merge(:classifier => "sources")) if artifact.is_a?(Buildr::Artifact)
|
328
|
+
info = adapt_plugin(artifact)
|
329
|
+
if !info.nil?
|
330
|
+
info[:unjarred] = @unjarred[plugin][:unjarred] unless @unjarred[plugin].nil?
|
331
|
+
resolved_plugins[info] = artifact
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
resolved_plugins
|
336
|
+
end
|
337
|
+
|
338
|
+
|
339
|
+
end
|
340
|
+
|
341
|
+
|
243
342
|
|
244
343
|
# Methods added to project to package a project as a feature
|
245
344
|
#
|
@@ -247,17 +346,53 @@ PROPERTIES
|
|
247
346
|
include Extension
|
248
347
|
|
249
348
|
protected
|
349
|
+
|
350
|
+
# returns true if the project defines at least one feature packaging.
|
351
|
+
# We keep this method protected and we will call it using send.
|
352
|
+
def is_packaging_feature()
|
353
|
+
packages.each {|package| return true if package.is_a?(::Buildr4OSGi::FeaturePackaging)}
|
354
|
+
false
|
355
|
+
end
|
250
356
|
|
251
357
|
def package_as_feature(file_name)
|
252
358
|
task = FeatureTask.define_task(file_name)
|
253
359
|
task.extend FeatureWriter
|
254
|
-
task.
|
255
|
-
|
360
|
+
task.feature_id ||= project.id
|
361
|
+
task.version ||= project.version
|
362
|
+
task.enhance do |featureTask|
|
363
|
+
featureTask.generateFeature(project)
|
256
364
|
end
|
365
|
+
task
|
257
366
|
end
|
258
367
|
|
259
368
|
def package_as_feature_spec(spec) #:nodoc:
|
260
|
-
spec.merge(:type=>:
|
369
|
+
spec.merge(:type=>:zip, :id => name.split(":").last)
|
370
|
+
end
|
371
|
+
|
372
|
+
def package_as_SDK_feature(file_name) #:nodoc:
|
373
|
+
return package_as_sources_before_SDK_feature(file_name) unless is_packaging_feature
|
374
|
+
featurePackage = packages.select {|package| package.is_a?(::Buildr4OSGi::FeaturePackaging)}.first.dup
|
375
|
+
sdkPackage = FeatureTask.define_task(file_name)
|
376
|
+
sdkPackage.enhance do |featureTask|
|
377
|
+
featureTask.generateFeature(project)
|
378
|
+
end
|
379
|
+
sdkPackage.extend FeatureWriter
|
380
|
+
sdkPackage.extend SDKFeatureEnabler
|
381
|
+
|
382
|
+
FeatureWriter::VARS.each do |ivar|
|
383
|
+
value = featurePackage.instance_variable_get("@#{ivar}")
|
384
|
+
new_value = value.clone rescue value
|
385
|
+
sdkPackage.instance_variable_set("@#{ivar}", new_value)
|
386
|
+
end
|
387
|
+
|
388
|
+
sdkPackage.feature_id += ".sources"
|
389
|
+
sdkPackage
|
390
|
+
end
|
391
|
+
|
392
|
+
def package_as_SDK_feature_spec(spec) #:nodoc:
|
393
|
+
spec = package_as_sources_spec_before_SDK_feature(spec)
|
394
|
+
spec.merge!(:type=>:zip, :id => name.split(":").last, :classifier => "sources") if is_packaging_feature
|
395
|
+
spec
|
261
396
|
end
|
262
397
|
end
|
263
398
|
|
@@ -267,5 +402,11 @@ end
|
|
267
402
|
module Buildr #:nodoc:
|
268
403
|
class Project #:nodoc:
|
269
404
|
include Buildr4OSGi::ActAsFeature
|
405
|
+
|
406
|
+
alias :package_as_sources_before_SDK_feature :package_as_sources
|
407
|
+
alias :package_as_sources :package_as_SDK_feature
|
408
|
+
|
409
|
+
alias :package_as_sources_spec_before_SDK_feature :package_as_sources_spec
|
410
|
+
alias :package_as_sources_spec :package_as_SDK_feature_spec
|
270
411
|
end
|
271
412
|
end
|
@@ -14,8 +14,6 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
module OSGi #:nodoc:
|
17
|
-
|
18
|
-
OSGI_GROUP_ID = "osgi"
|
19
17
|
|
20
18
|
# :nodoc:
|
21
19
|
# Module extending projects
|
@@ -31,7 +29,7 @@ module OSGi #:nodoc:
|
|
31
29
|
#
|
32
30
|
def matches(criteria = {:name => "", :version => "", :exports_package => "", :fragment_for => ""})
|
33
31
|
if File.exists?(File.join(base_dir, "META-INF", "MANIFEST.MF"))
|
34
|
-
manifest = ::Buildr::Packaging::Java::Manifest.new(File.join(base_dir, "META-INF", "MANIFEST.MF"))
|
32
|
+
manifest = ::Buildr::Packaging::Java::Manifest.new(File.read(File.join(base_dir, "META-INF", "MANIFEST.MF")))
|
35
33
|
end
|
36
34
|
manifest ||= ::Buildr::Packaging::Java::Manifest.new()
|
37
35
|
project.packages.select {|package| package.is_a? ::OSGi::BundlePackaging}.each {|p|
|
@@ -92,7 +90,7 @@ module OSGi #:nodoc:
|
|
92
90
|
# Creates a bundle out of a project, using the manifest defined in its bundle package
|
93
91
|
# and the MANIFEST.MF file present in the project if any.
|
94
92
|
def self.fromProject(project)
|
95
|
-
packaging = project.packages.select {|package| package.is_a?(
|
93
|
+
packaging = project.packages.select {|package| package.is_a?(BundlePackaging)}
|
96
94
|
raise "More than one bundle packaging is defined over the project #{project.id}, see BOSGI-16." if packaging.size > 1
|
97
95
|
return nil if packaging.empty?
|
98
96
|
manifest = ::Buildr::Packaging::Java::Manifest.new(File.exists?("META-INF/MANIFEST.MF") ? File.read("META-INF/MANIFEST.MF") : nil)
|
@@ -172,7 +170,7 @@ module OSGi #:nodoc:
|
|
172
170
|
@optional = args[:optional]
|
173
171
|
@start_level = 4
|
174
172
|
@type = "jar" #it's always a jar, even if it is a directory: we will jar it for Maven.
|
175
|
-
@group =
|
173
|
+
@group = GroupMatcher.instance.group(name)
|
176
174
|
end
|
177
175
|
|
178
176
|
|
@@ -183,7 +181,7 @@ module OSGi #:nodoc:
|
|
183
181
|
# Collect the bundle projects, duplicate them so no changes can be applied to them
|
184
182
|
# and extend them with the BundleProjectMatcher module
|
185
183
|
|
186
|
-
b_projects =
|
184
|
+
b_projects = BundleProjects::bundle_projects.select {|p|
|
187
185
|
unless p == project
|
188
186
|
p.extend BundleProjectMatcher
|
189
187
|
p.matches(:name => name, :version => version)
|
@@ -227,7 +225,7 @@ module OSGi #:nodoc:
|
|
227
225
|
when 0 then nil
|
228
226
|
when 1 then bundles.first
|
229
227
|
else
|
230
|
-
|
228
|
+
BundleResolvingStrategies.send(project.osgi.options.bundle_resolving_strategy, bundles)
|
231
229
|
end
|
232
230
|
if bundle.nil?
|
233
231
|
warn "Could not resolve bundle for #{self.to_s}"
|
@@ -35,9 +35,9 @@ module OSGi #:nodoc:
|
|
35
35
|
def resolve_matching_artifacts(project)
|
36
36
|
# Collect the bundle projects
|
37
37
|
# and extend them with the BundleProjectMatcher module
|
38
|
-
b_projects =
|
38
|
+
b_projects = BundleProjects::bundle_projects.select {|p|
|
39
39
|
unless p == project
|
40
|
-
p.extend
|
40
|
+
p.extend BundleProjectMatcher
|
41
41
|
p.matches(:exports_package => name, :version => version)
|
42
42
|
end
|
43
43
|
}
|
@@ -0,0 +1,91 @@
|
|
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
|
+
# A class to read dependencies.yml, and get a flat array of projects and dependencies for a project.
|
19
|
+
#
|
20
|
+
class Dependencies
|
21
|
+
|
22
|
+
attr_accessor :dependencies, :projects
|
23
|
+
|
24
|
+
def initialize(project = nil)
|
25
|
+
@project = project
|
26
|
+
end
|
27
|
+
|
28
|
+
def read()
|
29
|
+
base_dir = find_root(@project).base_dir
|
30
|
+
@dependencies = []
|
31
|
+
@projects = []
|
32
|
+
@deps_yml = {}
|
33
|
+
return unless File.exists? File.join(base_dir, "dependencies.yml")
|
34
|
+
@deps_yml =YAML.load(File.read(File.join(base_dir, "dependencies.yml")))
|
35
|
+
return if @deps_yml[@project.name].nil? || @deps_yml[@project.name]["dependencies"].nil?
|
36
|
+
_read(@project, false)
|
37
|
+
@dependencies = @dependencies.flatten.compact.uniq
|
38
|
+
return @dependencies, @projects
|
39
|
+
end
|
40
|
+
|
41
|
+
def write(projects)
|
42
|
+
base_dir = find_root(@project).base_dir
|
43
|
+
written_dependencies = YAML.load(File.read(File.join(base_dir, "dependencies.yml"))) if File.exists? File.join(base_dir, "dependencies.yml")
|
44
|
+
written_dependencies ||= {}
|
45
|
+
written_dependencies.extend SortedHash
|
46
|
+
projects.each {|p|
|
47
|
+
p = p.name if p.is_a?(Project)
|
48
|
+
written_dependencies[p] ||= {}
|
49
|
+
written_dependencies[p].extend SortedHash
|
50
|
+
written_dependencies[p]["dependencies"] ||= []
|
51
|
+
written_dependencies[p]["projects"] ||= []
|
52
|
+
yield written_dependencies, p
|
53
|
+
written_dependencies[p]["dependencies"].sort!
|
54
|
+
written_dependencies[p]["projects"].sort!
|
55
|
+
}
|
56
|
+
Buildr::write File.join(base_dir, "dependencies.yml"), written_dependencies.to_yaml
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def _read(project, add_project = true)
|
62
|
+
projects << project if add_project
|
63
|
+
return unless @deps_yml[project.name] && @deps_yml[project.name]["dependencies"]
|
64
|
+
@dependencies |= @deps_yml[project.name]["dependencies"]
|
65
|
+
@deps_yml[project.name]["projects"].each {|p| subp = Buildr::project(p) ; _read(subp) unless (projects.include?(subp) || subp == @project)}
|
66
|
+
end
|
67
|
+
|
68
|
+
def find_root(project)
|
69
|
+
project.parent.nil? ? project : find_root(project.parent)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Copy/pasted from here: http://snippets.dzone.com/posts/show/5811
|
73
|
+
# no author information though.
|
74
|
+
module SortedHash
|
75
|
+
|
76
|
+
# Replacing the to_yaml function so it'll serialize hashes sorted (by their keys)
|
77
|
+
#
|
78
|
+
# Original function is in /usr/lib/ruby/1.8/yaml/rubytypes.rb
|
79
|
+
def to_yaml( opts = {} )
|
80
|
+
YAML::quick_emit( object_id, opts ) do |out|
|
81
|
+
out.map( taguri, to_yaml_style ) do |map|
|
82
|
+
sort.each do |k, v| # <-- here's my addition (the 'sort')
|
83
|
+
map.add( k, v )
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -53,7 +53,7 @@ module Buildr4OSGi #:nodoc:
|
|
53
53
|
manifest = project.manifest.merge(read_m)
|
54
54
|
end
|
55
55
|
manifest["Bundle-Version"] = project.version # the version of the bundle packaged is ALWAYS the version of the project.
|
56
|
-
manifest["Bundle-SymbolicName"] ||= project.id # if it was resetted to nil, we force the id to be added back.
|
56
|
+
manifest["Bundle-SymbolicName"] ||= project.id.split(":").last # if it was resetted to nil, we force the id to be added back.
|
57
57
|
|
58
58
|
plugin.with :manifest=> manifest, :meta_inf=>meta_inf
|
59
59
|
plugin.with [compile.target, resources.target].compact
|
@@ -136,13 +136,15 @@ module Buildr4OSGi #:nodoc:
|
|
136
136
|
lib.invoke # make sure the artifact is present.
|
137
137
|
Zip::ZipFile.foreach(lib.to_s) {|entry| entries << entry.name.sub(/(.*)\\/.*.class$/, '\\1').gsub(/\\//, '.') if /.*\\.class$/.match(entry.name)}
|
138
138
|
}
|
139
|
-
|
140
|
-
"Export-Package" => entries.uniq.sort.join(","),
|
139
|
+
lib_manifest = {
|
141
140
|
"Bundle-Version" => "#{version}",
|
142
141
|
"Bundle-SymbolicName" => project.name,
|
143
142
|
"Bundle-Name" => names.join(", "),
|
144
143
|
"Bundle-Vendor" => "Intalio, Inc."
|
145
|
-
}
|
144
|
+
}
|
145
|
+
lib_manifest["Export-Package"] = entries.uniq.sort.join(",") unless entries.empty?
|
146
|
+
lib_manifest["Bundle-ManifestVersion"] = "2"
|
147
|
+
jar.with :manifest => lib_manifest.merge(#{options[:manifest].inspect})
|
146
148
|
|
147
149
|
|
148
150
|
}
|