buildr-bnd 0.0.3 → 0.0.4
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/CHANGELOG +5 -0
- data/buildr-bnd.gemspec +3 -1
- data/lib/buildr/bnd/bundle_task.rb +91 -0
- data/lib/buildr/bnd/main.rb +26 -0
- data/lib/buildr/bnd/project_extension.rb +36 -0
- data/lib/buildr/bnd/version.rb +11 -0
- data/lib/buildr_bnd.rb +4 -147
- metadata +8 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.0.4 (July 5, 2010)
|
2
|
+
* Changed: Separated code into separate files, moved project extension code into a separate module and moved
|
3
|
+
the code into a hierarchy matching the module hierarchy.
|
4
|
+
* Added: Add class containing version information about the plugin.
|
5
|
+
|
1
6
|
0.0.3 (June 1, 2010)
|
2
7
|
* Added: Buildr::Bnd.remote_repository method to get remote repository for bnd dependency.
|
3
8
|
* Deprecated: Buildr::Bnd.remote_repositories method that returned an array of repositories for bnd dependency.
|
data/buildr-bnd.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/buildr/bnd/version')
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
4
|
spec.name = 'buildr-bnd'
|
3
|
-
spec.version =
|
5
|
+
spec.version = Buildr::Bnd::Version::STRING
|
4
6
|
spec.authors = ['Peter Donald']
|
5
7
|
spec.email = ["peter@realityforge.org"]
|
6
8
|
spec.homepage = "http://github.com/realityforge/buildr-bnd"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Bnd
|
3
|
+
class BundleTask < Rake::FileTask
|
4
|
+
attr_reader :project
|
5
|
+
|
6
|
+
def [](key)
|
7
|
+
@params[key]
|
8
|
+
end
|
9
|
+
|
10
|
+
def []=(key, value)
|
11
|
+
@params[key] = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def classpath_element(dependencies)
|
15
|
+
artifacts = self.class.to_artifacts([dependencies])
|
16
|
+
self.prerequisites << artifacts
|
17
|
+
artifacts.each do |dependency|
|
18
|
+
@classpath << dependency.to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_params
|
23
|
+
params = project.manifest.merge(@params).reject { |k, v| v.nil? }
|
24
|
+
params["-classpath"] ||= @classpath.collect(&:to_s).join(", ")
|
25
|
+
params['Bundle-SymbolicName'] ||= [project.group, project.name.gsub(':', '.')].join('.')
|
26
|
+
params['Bundle-Name'] ||= project.comment || project.name
|
27
|
+
params['Bundle-Description'] ||= project.comment
|
28
|
+
params['Bundle-Version'] ||= project.version
|
29
|
+
params['Import-Package'] ||= '*'
|
30
|
+
params['Export-Package'] ||= '*'
|
31
|
+
|
32
|
+
params
|
33
|
+
end
|
34
|
+
|
35
|
+
def project=(project)
|
36
|
+
@project = project
|
37
|
+
@classpath = [project.compile.target] + project.compile.dependencies
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
# Convert objects to artifacts, where applicable
|
43
|
+
def self.to_artifacts(files)
|
44
|
+
files.flatten.inject([]) do |set, file|
|
45
|
+
case file
|
46
|
+
when ArtifactNamespace
|
47
|
+
set |= file.artifacts
|
48
|
+
when Symbol, Hash
|
49
|
+
set |= [Buildr.artifact(file)]
|
50
|
+
when /([^:]+:){2,4}/ # A spec as opposed to a file name.
|
51
|
+
set |= [Buildr.artifact(file)]
|
52
|
+
when Project
|
53
|
+
set |= Buildr.artifacts(file.packages)
|
54
|
+
when Rake::Task
|
55
|
+
set |= [file]
|
56
|
+
when Struct
|
57
|
+
set |= Buildr.artifacts(file.values)
|
58
|
+
else
|
59
|
+
# non-artifacts passed as-is; in particular, String paths are
|
60
|
+
# unmodified since Rake FileTasks don't use absolute paths
|
61
|
+
set |= [file]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def initialize(*args) #:nodoc:
|
67
|
+
super
|
68
|
+
@params = {}
|
69
|
+
enhance do
|
70
|
+
filename = self.name
|
71
|
+
# Generate BND file with same name as target jar but different extension
|
72
|
+
bnd_filename = filename.sub /(\.jar)?$/, '.bnd'
|
73
|
+
|
74
|
+
params = self.to_params
|
75
|
+
params["-output"] = filename
|
76
|
+
File.open(bnd_filename, 'w') do |f|
|
77
|
+
f.print params.collect { |k, v| "#{k}=#{v}" }.join("\n")
|
78
|
+
end
|
79
|
+
|
80
|
+
Buildr::Bnd.bnd_main( "build", "-noeclipse", bnd_filename )
|
81
|
+
begin
|
82
|
+
Buildr::Bnd.bnd_main( "print", "-verify", filename )
|
83
|
+
rescue => e
|
84
|
+
rm filename
|
85
|
+
raise e
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Bnd
|
3
|
+
class << self
|
4
|
+
# The specs for requirements
|
5
|
+
def requires
|
6
|
+
["biz.aQute:bnd:jar:0.0.384"]
|
7
|
+
end
|
8
|
+
|
9
|
+
# Repositories containing the requirements
|
10
|
+
def remote_repositories
|
11
|
+
puts "Buildr::Bnd.remote_repositories is deprecated. Please use Buildr::Bnd.remote_repository instead."
|
12
|
+
[remote_repository]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Repositories containing the requirements
|
16
|
+
def remote_repository
|
17
|
+
"http://www.aQute.biz/repo"
|
18
|
+
end
|
19
|
+
|
20
|
+
def bnd_main(*args)
|
21
|
+
cp = Buildr.artifacts(self.requires).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
|
22
|
+
Java::Commands.java 'aQute.bnd.main.bnd', *(args + [{ :classpath => cp }])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Buildr
|
2
|
+
module Bnd
|
3
|
+
module ProjectExtension
|
4
|
+
include Extension
|
5
|
+
|
6
|
+
first_time do
|
7
|
+
desc "Does `bnd print` on the packaged bundle and stdouts the output for inspection"
|
8
|
+
Project.local_task("bnd:print")
|
9
|
+
end
|
10
|
+
|
11
|
+
def package_as_bundle(filename)
|
12
|
+
project.task('bnd:print' => [filename]) do |task|
|
13
|
+
Buildr::Bnd.bnd_main("print", filename)
|
14
|
+
end
|
15
|
+
|
16
|
+
dirname = File.dirname(filename)
|
17
|
+
directory(dirname)
|
18
|
+
|
19
|
+
# Add Buildr.application.buildfile so it will rebuild if we change settings
|
20
|
+
task = BundleTask.define_task(filename => [Buildr.application.buildfile, dirname])
|
21
|
+
task.project = self
|
22
|
+
# the last task is the task considered the packaging task
|
23
|
+
task
|
24
|
+
end
|
25
|
+
|
26
|
+
# Change the bundle package to .jar extension
|
27
|
+
def package_as_bundle_spec(spec)
|
28
|
+
spec.merge(:type => :jar)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Buildr::Project
|
35
|
+
include Buildr::Bnd::ProjectExtension
|
36
|
+
end
|
data/lib/buildr_bnd.rb
CHANGED
@@ -1,147 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class << self
|
6
|
-
|
7
|
-
# The specs for requirements
|
8
|
-
def requires
|
9
|
-
["biz.aQute:bnd:jar:0.0.384"]
|
10
|
-
end
|
11
|
-
|
12
|
-
# Repositories containing the requirements
|
13
|
-
def remote_repositories
|
14
|
-
puts "Buildr::Bnd.remote_repositories is deprecated. Please use Buildr::Bnd.remote_repository instead."
|
15
|
-
[remote_repository]
|
16
|
-
end
|
17
|
-
|
18
|
-
# Repositories containing the requirements
|
19
|
-
def remote_repository
|
20
|
-
"http://www.aQute.biz/repo"
|
21
|
-
end
|
22
|
-
|
23
|
-
def bnd_main(*args)
|
24
|
-
cp = Buildr.artifacts(self.requires).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
|
25
|
-
Java::Commands.java 'aQute.bnd.main.bnd', *(args + [{ :classpath => cp }])
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
class BundleTask < Rake::FileTask
|
31
|
-
attr_reader :project
|
32
|
-
|
33
|
-
def [](key)
|
34
|
-
@params[key]
|
35
|
-
end
|
36
|
-
|
37
|
-
def []=(key, value)
|
38
|
-
@params[key] = value
|
39
|
-
end
|
40
|
-
|
41
|
-
def classpath_element(dependencies)
|
42
|
-
artifacts = self.class.to_artifacts([dependencies])
|
43
|
-
self.prerequisites << artifacts
|
44
|
-
artifacts.each do |dependency|
|
45
|
-
@classpath << dependency.to_s
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_params
|
50
|
-
params = project.manifest.merge(@params).reject { |k, v| v.nil? }
|
51
|
-
params["-classpath"] ||= @classpath.collect(&:to_s).join(", ")
|
52
|
-
params['Bundle-SymbolicName'] ||= [project.group, project.name.gsub(':', '.')].join('.')
|
53
|
-
params['Bundle-Name'] ||= project.comment || project.name
|
54
|
-
params['Bundle-Description'] ||= project.comment
|
55
|
-
params['Bundle-Version'] ||= project.version
|
56
|
-
params['Import-Package'] ||= '*'
|
57
|
-
params['Export-Package'] ||= '*'
|
58
|
-
|
59
|
-
params
|
60
|
-
end
|
61
|
-
|
62
|
-
def project=(project)
|
63
|
-
@project = project
|
64
|
-
@classpath = [project.compile.target] + project.compile.dependencies
|
65
|
-
end
|
66
|
-
|
67
|
-
protected
|
68
|
-
|
69
|
-
# Convert objects to artifacts, where applicable
|
70
|
-
def self.to_artifacts(files)
|
71
|
-
files.flatten.inject([]) do |set, file|
|
72
|
-
case file
|
73
|
-
when ArtifactNamespace
|
74
|
-
set |= file.artifacts
|
75
|
-
when Symbol, Hash
|
76
|
-
set |= [Buildr.artifact(file)]
|
77
|
-
when /([^:]+:){2,4}/ # A spec as opposed to a file name.
|
78
|
-
set |= [Buildr.artifact(file)]
|
79
|
-
when Project
|
80
|
-
set |= Buildr.artifacts(file.packages)
|
81
|
-
when Rake::Task
|
82
|
-
set |= [file]
|
83
|
-
when Struct
|
84
|
-
set |= Buildr.artifacts(file.values)
|
85
|
-
else
|
86
|
-
# non-artifacts passed as-is; in particular, String paths are
|
87
|
-
# unmodified since Rake FileTasks don't use absolute paths
|
88
|
-
set |= [file]
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def initialize(*args) #:nodoc:
|
94
|
-
super
|
95
|
-
@params = {}
|
96
|
-
enhance do
|
97
|
-
filename = self.name
|
98
|
-
# Generate BND file with same name as target jar but different extension
|
99
|
-
bnd_filename = filename.sub /(\.jar)?$/, '.bnd'
|
100
|
-
|
101
|
-
params = self.to_params
|
102
|
-
params["-output"] = filename
|
103
|
-
File.open(bnd_filename, 'w') do |f|
|
104
|
-
f.print params.collect { |k, v| "#{k}=#{v}" }.join("\n")
|
105
|
-
end
|
106
|
-
|
107
|
-
Bnd.bnd_main( "build", "-noeclipse", bnd_filename )
|
108
|
-
begin
|
109
|
-
Bnd.bnd_main( "print", "-verify", filename )
|
110
|
-
rescue => e
|
111
|
-
rm filename
|
112
|
-
raise e
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def package_as_bundle(filename)
|
119
|
-
project.task('bnd:print' => [filename]) do |task|
|
120
|
-
Bnd.bnd_main( "print", filename )
|
121
|
-
end
|
122
|
-
|
123
|
-
dirname = File.dirname(filename)
|
124
|
-
directory( dirname )
|
125
|
-
|
126
|
-
# Add Buildr.application.buildfile so it will rebuild if we change settings
|
127
|
-
task = BundleTask.define_task(filename => [Buildr.application.buildfile, dirname])
|
128
|
-
task.project = self
|
129
|
-
# the last task is the task considered the packaging task
|
130
|
-
task
|
131
|
-
end
|
132
|
-
|
133
|
-
def package_as_bundle_spec(spec)
|
134
|
-
# Change the source distribution to .jar extension
|
135
|
-
spec.merge( :type => :jar )
|
136
|
-
end
|
137
|
-
|
138
|
-
first_time do
|
139
|
-
desc "Does `bnd print` on the packaged bundle and stdouts the output for inspection"
|
140
|
-
Project.local_task("bnd:print")
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
class Buildr::Project
|
146
|
-
include Buildr::Bnd
|
147
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/buildr/bnd/version')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/buildr/bnd/main')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/buildr/bnd/bundle_task')
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/buildr/bnd/project_extension')
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Peter Donald
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-05 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -33,6 +33,10 @@ extra_rdoc_files:
|
|
33
33
|
- CHANGELOG
|
34
34
|
files:
|
35
35
|
- lib/buildr_bnd.rb
|
36
|
+
- lib/buildr/bnd/version.rb
|
37
|
+
- lib/buildr/bnd/main.rb
|
38
|
+
- lib/buildr/bnd/bundle_task.rb
|
39
|
+
- lib/buildr/bnd/project_extension.rb
|
36
40
|
- spec/spec_helper.rb
|
37
41
|
- spec/spec.opts
|
38
42
|
- spec/buildr/bnd/project_extension_spec.rb
|
@@ -51,7 +55,7 @@ licenses: []
|
|
51
55
|
post_install_message:
|
52
56
|
rdoc_options:
|
53
57
|
- --title
|
54
|
-
- buildr-bnd 0.0.
|
58
|
+
- buildr-bnd 0.0.4
|
55
59
|
- --main
|
56
60
|
- README.rdoc
|
57
61
|
require_paths:
|