buildr4osgi 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/buildr4osgi.gemspec +2 -2
- data/lib/buildr4osgi.rb +2 -0
- data/lib/buildr4osgi/compile.rb +2 -1
- data/lib/buildr4osgi/compile/compiler.rb +1 -3
- data/lib/buildr4osgi/compile/external.rb +71 -0
- data/lib/buildr4osgi/eclipse.rb +3 -1
- data/lib/buildr4osgi/eclipse/feature.rb +12 -7
- data/lib/buildr4osgi/eclipse/p2.rb +137 -0
- data/lib/buildr4osgi/eclipse/site.rb +207 -0
- data/lib/buildr4osgi/osgi/bundle.rb +17 -12
- data/lib/buildr4osgi/osgi/bundle_package.rb +35 -11
- data/lib/buildr4osgi/osgi/container.rb +1 -0
- data/lib/buildr4osgi/osgi/execution_environment.rb +199 -0
- data/lib/buildr4osgi/osgi/library_extension.rb +14 -1
- data/lib/buildr4osgi/osgi/packaging_sources.rb +4 -0
- data/lib/buildr4osgi/osgi/project_extension.rb +59 -20
- data/lib/buildr4osgi/osgi/registry.rb +23 -29
- data/lib/buildr4osgi/osgi/resolving_strategies.rb +1 -0
- data/lib/buildr4osgi/osgi/version.rb +1 -1
- data/rakelib/all-in-one.rake +84 -0
- data/rakelib/stage.rake +5 -4
- data/spec/compile/external_spec.rb +41 -0
- data/spec/eclipse/p2_spec.rb +65 -0
- data/spec/eclipse/site_spec.rb +94 -0
- data/spec/osgi/bundle_package_spec.rb +13 -1
- data/spec/osgi/bundle_spec.rb +2 -2
- data/spec/osgi/execution_environment_spec.rb +48 -0
- data/spec/osgi/library_extension_spec.rb +15 -2
- data/spec/osgi/project_extension_spec.rb +86 -18
- data/spec/osgi/registry_spec.rb +30 -20
- data/spec/osgi/resolving_strategies_spec.rb +2 -2
- data/spec/osgi/version_spec.rb +6 -0
- data/spec/spec_helpers.rb +12 -0
- metadata +12 -16
- 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
- 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
- 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 +0 -478
- data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8-sources.jar +0 -0
- data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.jar +0 -0
- data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.pom +0 -30
- data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8-sources.jar +0 -0
- data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar +0 -0
- data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.pom +0 -101
- data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8-sources.jar +0 -0
- data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar +0 -0
- data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.pom +0 -56
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.3'
|
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.8")
|
40
40
|
end
|
data/lib/buildr4osgi.rb
CHANGED
@@ -20,8 +20,10 @@ require 'buildr4osgi/compile'
|
|
20
20
|
# Methods defined in Buildr4OSGi are both instance methods (e.g. when included in Project)
|
21
21
|
# and class methods when invoked like Buildr4OSGi.project_library(SLF4J, "group", "foo", "1.0.0").
|
22
22
|
module Buildr4OSGi ; extend self ; end
|
23
|
+
module OSGi ; extend self ; end
|
23
24
|
# The Buildfile object (self) has access to all the Buildr4OSGi methods and constants.
|
24
25
|
class << self ; include Buildr4OSGi ; end
|
26
|
+
class << self ; include OSGi ; end
|
25
27
|
class Object #:nodoc:
|
26
28
|
Buildr4OSGi.constants.each do |name|
|
27
29
|
const = Buildr4OSGi.const_get(name)
|
data/lib/buildr4osgi/compile.rb
CHANGED
@@ -27,8 +27,6 @@ module Buildr4OSGi
|
|
27
27
|
def compile(sources, target, dependencies) #:nodoc:
|
28
28
|
check_options options, OPTIONS
|
29
29
|
cmd_args = []
|
30
|
-
# tools.jar contains the Java compiler.
|
31
|
-
dependencies << Java.tools_jar if Java.tools_jar
|
32
30
|
cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
|
33
31
|
source_paths = sources.select { |source| File.directory?(source) }
|
34
32
|
cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
|
@@ -36,7 +34,7 @@ module Buildr4OSGi
|
|
36
34
|
cmd_args += osgic_args
|
37
35
|
cmd_args += files_from_sources(sources)
|
38
36
|
unless Buildr.application.options.dryrun
|
39
|
-
trace((%w[
|
37
|
+
trace((%w[java -classpath org.eclipse.jdt.internal.compiler.batch.Main] + cmd_args).join(' '))
|
40
38
|
Java.load
|
41
39
|
Java.org.eclipse.jdt.internal.compiler.batch.Main.compile(cmd_args.join(" ")) or
|
42
40
|
fail 'Failed to compile, see errors above'
|
@@ -0,0 +1,71 @@
|
|
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
|
+
# We use an external compiler defined by ENV['EXTERNAL_COMPILER']
|
17
|
+
module Buildr4OSGi
|
18
|
+
module CompilerSupport
|
19
|
+
class ExternalC < Buildr::Compiler::Javac
|
20
|
+
|
21
|
+
OPTIONS = [:warnings, :debug, :deprecation, :source, :target, :lint, :other]
|
22
|
+
|
23
|
+
specify :language=>:java, :sources => 'java', :source_ext => 'java',
|
24
|
+
:target=>'classes', :target_ext=>'class', :packaging=>:jar
|
25
|
+
|
26
|
+
|
27
|
+
def compile(sources, target, dependencies) #:nodoc:
|
28
|
+
check_options options, OPTIONS
|
29
|
+
cmd_args = []
|
30
|
+
cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
|
31
|
+
source_paths = sources.select { |source| File.directory?(source) }
|
32
|
+
cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
|
33
|
+
cmd_args << '-d' << File.expand_path(target)
|
34
|
+
cmd_args += externalc_args
|
35
|
+
cmd_args += files_from_sources(sources)
|
36
|
+
unless Buildr.application.options.dryrun
|
37
|
+
fail "ENV['EXTERNAL_COMPILER'] is not defined" if ENV['EXTERNAL_COMPILER'].nil?
|
38
|
+
javac_path = "#{ENV['EXTERNAL_COMPILER']}#{File::SEPARATOR}bin#{File::SEPARATOR}java"
|
39
|
+
ecj_path = File.expand_path(File.join(File.dirname(__FILE__), "ecj-#{Buildr4OSGi::CompilerSupport::OSGiC::CURRENT_JDT_COMPILER}.jar"))
|
40
|
+
final_args = ([javac_path,"-classpath", ecj_path, "org.eclipse.jdt.internal.compiler.batch.Main"] + cmd_args).join(' ')
|
41
|
+
trace(final_args)
|
42
|
+
info %x[#{final_args}]
|
43
|
+
fail 'Failed to compile, see errors above' unless $?.success?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# 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
|
50
|
+
def externalc_args #:nodoc:
|
51
|
+
args = []
|
52
|
+
args << '-warn:none' unless options[:warnings]
|
53
|
+
args << '-verbose' if Buildr.application.options.trace
|
54
|
+
args << '-g' if options[:debug]
|
55
|
+
args << '-deprecation' if options[:deprecation]
|
56
|
+
args << '-source' << options[:source].to_s if options[:source]
|
57
|
+
args << '-target' << options[:target].to_s if options[:target]
|
58
|
+
case options[:lint]
|
59
|
+
when Array then args << "-Xlint:#{options[:lint].join(',')}"
|
60
|
+
when String then args << "-Xlint:#{options[:lint]}"
|
61
|
+
when true then args << '-Xlint'
|
62
|
+
end
|
63
|
+
args + Array(options[:other])
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Buildr::Compiler.compilers << Buildr4OSGi::CompilerSupport::ExternalC
|
data/lib/buildr4osgi/eclipse.rb
CHANGED
@@ -35,7 +35,7 @@ module Buildr4OSGi
|
|
35
35
|
# Writes an Eclipse feature with this format:
|
36
36
|
#<feature id="com.acme.MyFeature" label="%feature.name"
|
37
37
|
# version="5.0.100" provider-name="%provider.name"
|
38
|
-
# plugin="myPlugin.id">
|
38
|
+
# plugin="myPlugin.id" image="some_icon.gif">
|
39
39
|
#
|
40
40
|
# <description url="%changesURL">
|
41
41
|
# %description
|
@@ -69,7 +69,7 @@ module Buildr4OSGi
|
|
69
69
|
feature_properties = {"id" => feature_id, "label" => externalize_strings ? "%feature.name" : label,
|
70
70
|
"version" => version, "provider-name" => externalize_strings ? "%provider.name" : provider}
|
71
71
|
feature_properties.merge!("plugin" => branding_plugin) if branding_plugin
|
72
|
-
feature_properties.merge!("
|
72
|
+
feature_properties.merge!("image" => image) if image
|
73
73
|
x.feature(feature_properties) {
|
74
74
|
x.description( "%description", "url" => externalize_strings ? "%changesURL" : changesURL)
|
75
75
|
x.copyright(copyright)
|
@@ -371,21 +371,26 @@ PROPERTIES
|
|
371
371
|
|
372
372
|
def package_as_SDK_feature(file_name) #:nodoc:
|
373
373
|
return package_as_sources_before_SDK_feature(file_name) unless is_packaging_feature
|
374
|
-
|
374
|
+
|
375
375
|
sdkPackage = FeatureTask.define_task(file_name)
|
376
|
-
sdkPackage.enhance do |featureTask|
|
377
|
-
featureTask.generateFeature(project)
|
378
|
-
end
|
379
376
|
sdkPackage.extend FeatureWriter
|
380
377
|
sdkPackage.extend SDKFeatureEnabler
|
378
|
+
sdkPackage.enhance do |sdkTask|
|
379
|
+
featurePackage = packages.select {|package| package.is_a?(::Buildr4OSGi::FeaturePackaging)}.first
|
380
|
+
raise "Cannot use same feature.xml file for both binary and source features packaging" if (!featurePackage.feature_xml.nil?) && featurePackage.feature_xml == sdkTask.feature_xml
|
381
|
+
sdkTask.label += " - Sources" if featurePackage.label == sdkTask.label
|
382
|
+
sdkTask.description = "Sources for " + sdkTask.description if featurePackage.description == sdkTask.description
|
383
|
+
sdkTask.feature_id += ".sources" if featurePackage.feature_id == sdkTask.feature_id
|
384
|
+
sdkTask.generateFeature(project)
|
385
|
+
end
|
381
386
|
|
387
|
+
featurePackage = packages.select {|package| package.is_a?(::Buildr4OSGi::FeaturePackaging)}.first
|
382
388
|
FeatureWriter::VARS.each do |ivar|
|
383
389
|
value = featurePackage.instance_variable_get("@#{ivar}")
|
384
390
|
new_value = value.clone rescue value
|
385
391
|
sdkPackage.instance_variable_set("@#{ivar}", new_value)
|
386
392
|
end
|
387
393
|
|
388
|
-
sdkPackage.feature_id += ".sources"
|
389
394
|
sdkPackage
|
390
395
|
end
|
391
396
|
|
@@ -0,0 +1,137 @@
|
|
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 Buildr4OSGi
|
17
|
+
|
18
|
+
module P2
|
19
|
+
|
20
|
+
include Extension
|
21
|
+
|
22
|
+
def package_as_p2_from_site(file_name)
|
23
|
+
task = UpdateSitePublisherTask.define_task(file_name)
|
24
|
+
task.send :associate_with, self
|
25
|
+
return task
|
26
|
+
end
|
27
|
+
|
28
|
+
def package_as_p2_from_site_spec(spec)
|
29
|
+
spec.merge(:type => :zip, :classifier => "p2", :id => name.split(":").last)
|
30
|
+
end
|
31
|
+
|
32
|
+
class UpdateSitePublisherTask < ::Buildr::Packaging::Java::JarTask
|
33
|
+
|
34
|
+
attr_accessor :site
|
35
|
+
attr_reader :project
|
36
|
+
|
37
|
+
def initialize(*args) #:nodoc:
|
38
|
+
super
|
39
|
+
enhance do
|
40
|
+
# Buildr.ant('org.eclipse.equinox.p2.publisher.UpdateSitePublisher') do |ant|
|
41
|
+
# work_dir = File.join(project.base_dir, "target", "generated", "update-site")
|
42
|
+
# ant.java :fork => true, :failonerror => true, :classname=>'org.eclipse.equinox.p2.publisher.UpdateSitePublisher' do
|
43
|
+
# ant.arg :value => "metadataRepository"
|
44
|
+
# ant.arg :value => work_dir
|
45
|
+
# ant.arg :value => "artifactRepository"
|
46
|
+
# ant.arg :value => work_dir
|
47
|
+
# ant.arg :value => "compress"
|
48
|
+
# ant.arg :value => "publishArtifacts"
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
# http://wiki.eclipse.org/Equinox/p2/Publisher
|
52
|
+
#the p2.installer and the p2.agent don't work. currently debugging with a local eclipse sdk.
|
53
|
+
# download the app here: "org.eclipse.equinox.p2:installer:3.6M2-linux.gtk.x86:tgz"
|
54
|
+
# unzip it wherever it is.
|
55
|
+
# then invoke it on the cmd line `java -jar #{launcherLocation} -application ... -source #{siteLocation}`
|
56
|
+
#we need to give the ability to define an eclipse home that could be invoked as a replacement to this.
|
57
|
+
# p2installer = Buildr::artifact("org.eclipse.platform:eclipse-platform:tgz:3.6M3-linux-gtk")
|
58
|
+
# p2installer.invoke
|
59
|
+
# p2installerHome = File.join(project.base_dir, "target", "p2installer")
|
60
|
+
# Buildr::unzip(p2installerHome => p2installer).extract
|
61
|
+
# p2installerHome = File.join(p2installerHome, "eclipse")
|
62
|
+
|
63
|
+
#add the missing publisher plugin:
|
64
|
+
# p2publisher = Buildr::artifact("org.eclipse.equinox.p2:org.eclipse.equinox.p2.publisher:jar:1.1.0.v20090831")
|
65
|
+
# p2publisher.invoke
|
66
|
+
# cp p2publisher.to_s, File.join(p2installerHome, "plugins/#{p2publisher.id}_#{p2publisher.version}.jar")
|
67
|
+
|
68
|
+
siteWithoutP2 = project.package(:site)
|
69
|
+
siteWithoutP2.invoke
|
70
|
+
|
71
|
+
targetDir = File.join(project.base_dir, "target")
|
72
|
+
targetP2Repo = File.join(project.base_dir, "target", "p2repository");
|
73
|
+
mkpath targetP2Repo
|
74
|
+
Buildr::unzip(targetP2Repo=>siteWithoutP2.to_s).extract
|
75
|
+
eclipseSDK = Buildr::artifact("org.eclipse:eclipse-SDK:zip:3.6M3-win32")
|
76
|
+
eclipseSDK.invoke
|
77
|
+
p2installerHome = File.dirname eclipseSDK.to_s#"~/proj/eclipses/eclipse-SDK-3.6M3"
|
78
|
+
Buildr::unzip( p2installerHome => eclipseSDK.to_s ).extract
|
79
|
+
p2installerHome += "/eclipse"
|
80
|
+
launcherPlugin = Dir.glob("#{p2installerHome}/plugins/org.eclipse.equinox.launcher_*")[0]
|
81
|
+
|
82
|
+
application = "org.eclipse.equinox.p2.publisher.UpdateSitePublisher"
|
83
|
+
#this is where the artifacts are published.
|
84
|
+
metadataRepository_url = "file:#{targetP2Repo}"
|
85
|
+
artifactRepository_url = metadataRepository_url
|
86
|
+
metadataRepository_name = project.id + "_" + project.version
|
87
|
+
artifactRepository_name = project.id + "_" + project.version
|
88
|
+
source_absolutePath = targetP2Repo
|
89
|
+
|
90
|
+
cmdline = "java -jar #{launcherPlugin} -application #{application} \
|
91
|
+
-metadataRepository #{metadataRepository_url} \
|
92
|
+
-artifactRepository #{artifactRepository_url} \
|
93
|
+
-metadataRepositoryName #{metadataRepository_name} \
|
94
|
+
-artifactRepositoryName #{artifactRepository_name} \
|
95
|
+
-source #{source_absolutePath} \
|
96
|
+
-configs gtk.linux.x86 \
|
97
|
+
-publishArtifacts \
|
98
|
+
-clean -consoleLog"
|
99
|
+
puts "Invoking P2's metadata generation: #{cmdline}"
|
100
|
+
result = `#{cmdline}`
|
101
|
+
puts result
|
102
|
+
|
103
|
+
include targetP2Repo, :as=>"."
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# :call-seq:
|
109
|
+
# with(options) => self
|
110
|
+
#
|
111
|
+
# Passes options to the task and returns self.
|
112
|
+
#
|
113
|
+
def with(options)
|
114
|
+
options.each do |key, value|
|
115
|
+
begin
|
116
|
+
send "#{key}=", value
|
117
|
+
rescue NoMethodError
|
118
|
+
raise ArgumentError, "#{self.class.name} does not support the option #{key}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
self
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def associate_with(project)
|
127
|
+
@project = project
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
class Buildr::Project
|
135
|
+
include Buildr4OSGi::P2
|
136
|
+
end
|
137
|
+
|
@@ -0,0 +1,207 @@
|
|
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 Buildr4OSGi
|
17
|
+
|
18
|
+
class Category
|
19
|
+
|
20
|
+
attr_accessor :features, :name, :label, :description
|
21
|
+
|
22
|
+
def initialize()
|
23
|
+
@features = []
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
module SiteWriter
|
29
|
+
|
30
|
+
attr_accessor :description, :description_url, :categories
|
31
|
+
|
32
|
+
# :nodoc:
|
33
|
+
# When this module extends an object
|
34
|
+
# the categories are initialized as empty arrays.
|
35
|
+
#
|
36
|
+
def SiteWriter.extend_object(obj)
|
37
|
+
super(obj)
|
38
|
+
obj.categories = []
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/update_sitemap.html
|
43
|
+
#
|
44
|
+
#<site pack200="false">
|
45
|
+
# <description url="http://www.example.com/DescriptionOfSite">Some description</description>
|
46
|
+
# <category-def name="some.id" label="Human readable label">
|
47
|
+
# <description>Some description</description>
|
48
|
+
# </category-def>
|
49
|
+
# <feature id="feature.id" version="2.0.3" url="features/myfeature.jar" patch="false">
|
50
|
+
# <category name="some.id"/>
|
51
|
+
# </feature>
|
52
|
+
#</site>
|
53
|
+
#
|
54
|
+
def writeSiteXml(feature_info)
|
55
|
+
x = Builder::XmlMarkup.new(:target => out = "", :indent => 1)
|
56
|
+
x.instruct!
|
57
|
+
x.site(:pack200 => "false") {
|
58
|
+
x.description(description, :url => description_url) if (description || description_url)
|
59
|
+
for category in categories
|
60
|
+
x.tag!("category-def", :name => category.name, :label => category.label) {
|
61
|
+
x.description category.description if category.description
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
f2c = feature_categories_map()
|
67
|
+
f2c.each_pair { |feature, categories|
|
68
|
+
info = feature_info[feature.to_s]
|
69
|
+
x.feature(:id => info[:id], :version => info[:version], :url => "features/#{info[:id]}_#{info[:version]}.jar", :patch => false) {
|
70
|
+
for category in categories
|
71
|
+
x.category(:name => category.name)
|
72
|
+
end
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def feature_categories_map()
|
79
|
+
f2c = {}
|
80
|
+
categories.each do |category|
|
81
|
+
category.features.collect {|f| adapt_feature(f)}.flatten.each do |f|
|
82
|
+
f2c[f] ||= []
|
83
|
+
f2c[f] << category
|
84
|
+
end
|
85
|
+
end
|
86
|
+
f2c
|
87
|
+
end
|
88
|
+
|
89
|
+
def adapt_feature(obj)
|
90
|
+
artifact = case
|
91
|
+
when obj.is_a?(String)
|
92
|
+
Buildr::artifact(obj)
|
93
|
+
when obj.is_a?(Buildr::Project)
|
94
|
+
[Buildr::artifact(obj.package(:feature)), Buildr::artifact(obj.package(:sources))]
|
95
|
+
else
|
96
|
+
obj
|
97
|
+
end
|
98
|
+
artifact
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
#Marker module common to all sites packaging tasks.
|
104
|
+
#Tasks including this module are recognized internally as tasks packaging sites.
|
105
|
+
module SitePackaging
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
class SiteTask < ::Buildr::Packaging::Java::JarTask
|
110
|
+
include SitePackaging
|
111
|
+
|
112
|
+
attr_accessor :site_xml
|
113
|
+
|
114
|
+
def initialize(*args) #:nodoc:
|
115
|
+
super
|
116
|
+
end
|
117
|
+
|
118
|
+
def generateSite(project)
|
119
|
+
mkpath File.join(project.base_dir, 'target')
|
120
|
+
feature_files = find_feature_files()
|
121
|
+
info = {}
|
122
|
+
for feature in feature_files
|
123
|
+
dir = File.join(project.base_dir, 'target', File.basename(feature.to_s, ".*"))
|
124
|
+
|
125
|
+
feature_xml = nil
|
126
|
+
feature_info = {}
|
127
|
+
info[feature.to_s] = feature_info
|
128
|
+
Zip::ZipFile.open(feature.to_s) do |zip|
|
129
|
+
|
130
|
+
feature_xml = zip.read(zip.entries.select {|entry| entry.name.to_s.match(".*/feature\.xml")}.first)
|
131
|
+
doc = REXML::Document.new(feature_xml)
|
132
|
+
feature_info[:id] = REXML::XPath.first(doc, "/feature/@id")
|
133
|
+
feature_info[:version] = REXML::XPath.first(doc, "/feature/@version")
|
134
|
+
end
|
135
|
+
unzip = Buildr::unzip(dir => feature.to_s)
|
136
|
+
|
137
|
+
unzip.target.invoke
|
138
|
+
include(File.join(dir, "eclipse", "plugins", "*"), :path => "plugins")
|
139
|
+
|
140
|
+
Dir.glob(File.join(dir, "eclipse", "features", "*")).each do |feature_dir|
|
141
|
+
Buildr::zip(File.join(dir, "features", "#{File.basename(feature_dir)}.jar")).include(File.join(feature_dir, "*")).invoke
|
142
|
+
path("features").include File.join(dir, "features", "#{File.basename(feature_dir)}.jar")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
if site_xml
|
146
|
+
path("").include site_xml
|
147
|
+
else
|
148
|
+
File.open(File.join(project.base_dir, 'target', 'site.xml'), 'w') do |f|
|
149
|
+
f.write(writeSiteXml(info))
|
150
|
+
end
|
151
|
+
path("").include File.join(project.base_dir, 'target', 'site.xml')
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
protected
|
157
|
+
|
158
|
+
def find_feature_files
|
159
|
+
feature_files = []
|
160
|
+
unless @categories.nil? || @categories.empty?
|
161
|
+
feature_categories_map.keys.uniq.each do |feature|
|
162
|
+
[adapt_feature(feature)].flatten.each do |artifact|
|
163
|
+
artifact.invoke
|
164
|
+
feature_files << artifact
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
feature_files
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
# Methods added to project to package a project as a site
|
174
|
+
#
|
175
|
+
module ActAsSite
|
176
|
+
include Extension
|
177
|
+
|
178
|
+
protected
|
179
|
+
|
180
|
+
# returns true if the project defines at least one site packaging.
|
181
|
+
# We keep this method protected and we will call it using send.
|
182
|
+
def is_packaging_site()
|
183
|
+
packages.each {|package| return true if package.is_a?(::Buildr4OSGi::SitePackaging)}
|
184
|
+
false
|
185
|
+
end
|
186
|
+
|
187
|
+
def package_as_site(file_name)
|
188
|
+
task = SiteTask.define_task(file_name)
|
189
|
+
task.extend SiteWriter
|
190
|
+
task.enhance do |siteTask|
|
191
|
+
siteTask.generateSite(project)
|
192
|
+
end
|
193
|
+
task
|
194
|
+
end
|
195
|
+
|
196
|
+
def package_as_site_spec(spec) #:nodoc:
|
197
|
+
spec.merge(:type=>:zip, :id => name.split(":").last)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
module Buildr #:nodoc:
|
203
|
+
class Project #:nodoc:
|
204
|
+
include Buildr4OSGi::ActAsSite
|
205
|
+
|
206
|
+
end
|
207
|
+
end
|