buildr4osgi 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
data/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ COPYRIGHT NOTICES
2
+ -----------------
3
+ Copyright 2009 Intalio
4
+
5
+ This product includes software developed by Intalio
6
+ http://www.intalio.com
data/README.rdoc ADDED
@@ -0,0 +1,50 @@
1
+ = Buildr4osgi
2
+
3
+ A plugin for adding OSGi support to Buildr.
4
+
5
+ See the official Buildr site: http://buildr.apache.org
6
+
7
+ You just had this OSGi bundle started, and everything runs in your development environment.
8
+ You hit one of those issues:
9
+ * You can't run a reproducible build.
10
+ * Bundles are hard to package.
11
+ * And it looks like you are going to have to find a way to resolve all your plugin dependencies (none of them are in a Maven repository!)
12
+
13
+ Enter OSGi!
14
+
15
+ Your bundle uses one of the mechanisms defined by OSGi to define dependencies:
16
+ * Require-Bundle: you require some bundles, optionally with a version range or a version.
17
+ * Import-Package: you import a package exported by other bundles.
18
+ * Fragment-Host: your bundle has fragments, they will be added to the bundle classpath on activation.
19
+
20
+ Each of those instructions have their own use. There's just no way you are going to resolve all your dependencies manually though.
21
+
22
+ == Install Buildr4osgi
23
+
24
+ * See the github instructions on how to setup to install their gems: http://gems.github.com
25
+ * For the impatient:
26
+ * gem sources -a http://gems.github.com
27
+ * sudo gem install intalio-buildr4osgi
28
+
29
+ == Documentation
30
+
31
+ See http://oss.intalio.com/buildr4osgi
32
+
33
+ http://intalio.github.com/buildr4osgi is the cutting edge documentation if you work against the trunk.
34
+
35
+ == License
36
+
37
+ Licensed to the Apache Software Foundation (ASF) under one or more
38
+ contributor license agreements. See the NOTICE file distributed with this
39
+ work for additional information regarding copyright ownership. The ASF
40
+ licenses this file to you under the Apache License, Version 2.0 (the
41
+ "License"); you may not use this file except in compliance with the License.
42
+ You may obtain a copy of the License at
43
+
44
+ http://www.apache.org/licenses/LICENSE-2.0
45
+
46
+ Unless required by applicable law or agreed to in writing, software
47
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
48
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
49
+ License for the specific language governing permissions and limitations under
50
+ the License.
data/Rakefile ADDED
@@ -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
+
17
+ # We need JAVA_HOME for most things (setup, spec, etc).
18
+ unless ENV['JAVA_HOME']
19
+ if RUBY_PLATFORM[/java/]
20
+ ENV['JAVA_HOME'] = java.lang.System.getProperty('java.home')
21
+ elsif RUBY_PLATFORM[/darwin/]
22
+ ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.framework/Home'
23
+ else
24
+ fail "Please set JAVA_HOME first (set JAVA_HOME=... or env JAVA_HOME=... rake ...)"
25
+ end
26
+ end
27
+
28
+
29
+ # Load the Gem specification for the current platform (Ruby or JRuby).
30
+ def spec(platform = RUBY_PLATFORM[/java/] || 'ruby')
31
+ @specs ||= ['ruby', 'java', 'x86-mswin32'].inject({}) { |hash, spec_platform|
32
+ $platform = spec_platform
33
+ hash.update(spec_platform=>Gem::Specification.load('buildr4osgi.gemspec'))
34
+ }
35
+ @specs[platform]
36
+ end
37
+
38
+ # Tell us if we need sudo for various commands.
39
+ def sudo_needed?
40
+ Config::CONFIG['host_os'] !~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i && !ENV['GEM_HOME']
41
+ end
42
+
43
+
44
+ desc 'Clean up all temporary directories used for running tests, creating documentation, packaging, etc.'
45
+ task :clobber
@@ -0,0 +1,40 @@
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
+ Gem::Specification.new do |spec|
18
+ spec.name = 'buildr4osgi'
19
+ spec.version = '0.9.0'
20
+ spec.author = 'Antoine Toulme'
21
+ spec.email = "atoulme@intalio.com"
22
+ spec.homepage = "http://buildr.apache.org/"
23
+ spec.summary = "A plugin for adding OSGi support to Buildr."
24
+ spec.description = <<-TEXT
25
+ A plugin for adding OSGi support to Buildr. Ever dreamt you could resolve your OSGi dependencies ?
26
+ TEXT
27
+ #spec.rubyforge_project = 'buildr4osgi'
28
+ # Rakefile needs to create spec for both platforms (ruby and java), using the
29
+ # $platform global variable. In all other cases, we figure it out from RUBY_PLATFORM.
30
+ spec.platform = $platform || RUBY_PLATFORM[/java/] || 'ruby'
31
+ spec.files = Dir['{doc,etc,lib,rakelib,spec}/**/*', '*.{gemspec,buildfile}'] +
32
+ ['LICENSE', 'NOTICE', 'README.rdoc', 'Rakefile']
33
+ spec.require_paths = ['lib']
34
+ spec.has_rdoc = true
35
+ spec.extra_rdoc_files = 'README.rdoc', 'LICENSE', 'NOTICE'
36
+ spec.rdoc_options = '--title', 'Buildr4osgi', '--main', 'README.rdoc',
37
+ '--webcvs', 'http://github.com/intalio/buildr4osgi'
38
+ spec.post_install_message = "To get started run buildr --help"
39
+ spec.add_dependency("manifest", "= 0.0.6")
40
+ end
@@ -0,0 +1,54 @@
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
+ module CompilerSupport
18
+ class OSGiC < Buildr::Compiler::Javac
19
+
20
+ CURRENT_JDT_COMPILER = '3.4.1'
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=>:plugin
25
+
26
+
27
+ def compile(sources, target, dependencies) #:nodoc:
28
+ check_options options, OPTIONS
29
+ cmd_args = []
30
+ # tools.jar contains the Java compiler.
31
+ dependencies << Java.tools_jar if Java.tools_jar
32
+ cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
33
+ source_paths = sources.select { |source| File.directory?(source) }
34
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
35
+ cmd_args << '-d' << File.expand_path(target)
36
+ cmd_args += javac_args
37
+ cmd_args += files_from_sources(sources)
38
+ unless Buildr.application.options.dryrun
39
+ trace((%w[javac -classpath org.eclipse.jdt.internal.compiler.batch.Main] + cmd_args).join(' '))
40
+ Java.load
41
+ Java.org.eclipse.jdt.internal.compiler.batch.Main.main(cmd_args.
42
+ to_java(Java.java.lang.String)) == 0 or fail 'Failed to compile, see errors above'
43
+ end
44
+ end
45
+ alias :osgic_args :javac_args
46
+
47
+ end
48
+
49
+ end
50
+ end
51
+
52
+ Java.classpath << File.expand_path(File.join(File.dirname(__FILE__), "ecj-#{Buildr4OSGi::CompilerSupport::OSGiC::CURRENT_JDT_COMPILER}.jar"))
53
+
54
+ Buildr::Compiler.compilers.unshift Buildr4OSGi::CompilerSupport::OSGiC
@@ -0,0 +1,16 @@
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 'buildr4osgi/compile/compiler'
@@ -0,0 +1,271 @@
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 FeatureWriter
19
+
20
+ attr_accessor :feature_id
21
+ attr_accessor :version
22
+ attr_accessor :label
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
34
+
35
+ # :nodoc:
36
+ # When this module extends an object
37
+ # the update_sites and discovery_sites are initialized as empty arrays.
38
+ #
39
+ def FeatureWriter.extend_object(obj)
40
+ super(obj)
41
+ obj.update_sites = []
42
+ obj.discovery_sites = []
43
+ end
44
+
45
+
46
+ # Writes an Eclipse feature with this format:
47
+ #<feature id="com.acme.MyFeature" label="%feature.name"
48
+ # version="5.0.100" provider-name="%provider.name"
49
+ # plugin="myPlugin.id">
50
+ #
51
+ # <description url="%changesURL">
52
+ # %description
53
+ # </description>
54
+ #
55
+ # <copyright>
56
+ # Copyright (C) 1999-2008, Acme Inc. All rights reserved.
57
+ #The program(s) herein may be used and/or copied only with the
58
+ #written permission of Acme Inc. or in accordance with the
59
+ #terms and conditions stipulated in the agreement/contract under which
60
+ #the program(s) have been supplied.
61
+ # </copyright>
62
+ #
63
+ # <license url="%licenseURL">
64
+ # %license
65
+ # </license>
66
+ #
67
+ # <url>
68
+ # <update label="%updateSiteName" url="http://www.example.com/siteupdate/" />
69
+ # <discovery label="%updateSiteName" url="http://www.example.com/siteupdate/" />
70
+ # </url>
71
+ #
72
+ # <plugin id="org.thingy.eclipse" version="6.0.000" download-size="2262" install-size="0" unpack="false" />
73
+ # <plugin id="org.acme.lib.eclipse" version="6.0.000" download-size="329" install-size="0" unpack="false" />
74
+ #
75
+ #</feature>
76
+ #
77
+ def writeFeatureXml(plugins, externalize_strings = true)
78
+ x = Builder::XmlMarkup.new(:target => out = "", :indent => 1)
79
+ x.instruct!
80
+ feature_properties = {"id" => feature_id, "label" => externalize_strings ? "%feature.name" : label,
81
+ "version" => version, "provider-name" => externalize_strings ? "%provider.name" : provider}
82
+ feature_properties.merge!("plugin" => branding_plugin) if branding_plugin
83
+ feature_properties.merge!("plugin" => image) if image
84
+ x.feature(feature_properties) {
85
+ x.description( "%description", "url" => externalize_strings ? "%changesURL" : changesURL)
86
+ x.copyright(copyright)
87
+ x.license(externalize_strings ? "%license" : license, "url" => externalize_strings ? "%licenseURL" : licenseURL)
88
+ x.url {
89
+ update_sites.each_index {|index| x.update("label" => externalize_strings ? "%updatesite.name#{index}" : update_sites.at(index)[:name], "url" => update_sites.at(index)[:url] )} unless update_sites.nil?
90
+ discovery_sites.each_index {|index| x.discovery("label" => externalize_strings ? "%discoverysite.name#{index}" : discovery_sites.at(index)[:name], "url" => discovery_sites.at(index)[:url] )} unless discovery_sites.nil?
91
+ }
92
+
93
+ for plugin in plugins
94
+ x.plugin("id" => plugin[:id], "version" => plugin[:version], "download-size" => plugin[:"download-size"],
95
+ "install-size" => plugin[:"install-size"], "unpack" => plugin[:unpack])
96
+ end
97
+ }
98
+ out
99
+ end
100
+
101
+ # Writes the feature.properties file to a string and returns it
102
+ # Uses predefined keys in properties to match the keys used in feature.xml
103
+ #
104
+ def writeFeatureProperties()
105
+ properties = <<-PROPERTIES
106
+ # Built by Buildr4OSGi
107
+
108
+ feature.name=#{label}
109
+ provider.name=#{provider}
110
+ changesURL=#{changesURL}
111
+ description=#{description}
112
+ licenseURL=#{licenseURL}
113
+ license=#{license}
114
+
115
+ PROPERTIES
116
+ update_sites.each_index {|index| "updatesite.name#{index}=#{update_sites.at(index)[:name]}\n" } unless update_sites.nil?
117
+ discovery_sites.each_index {|index| "discoverysite.name#{index}=#{discovery_sites.at(index)[:name]}\n"} unless discovery_sites.nil?
118
+ properties
119
+ end
120
+
121
+ end
122
+
123
+
124
+
125
+ class FeatureTask < ::Buildr::Packaging::Java::JarTask
126
+
127
+ attr_accessor :plugins
128
+
129
+ attr_accessor :feature_xml
130
+ attr_accessor :feature_properties
131
+
132
+ def initialize(*args) #:nodoc:
133
+ super
134
+ @unjarred = {}
135
+ @plugins = ArrayAddWithOptions.new(@unjarred)
136
+ end
137
+
138
+ def generateFeature(project)
139
+ feature_id ||= project.id
140
+ version ||= project.version
141
+
142
+ mkpath File.join(project.base_dir, 'target')
143
+ resolved_plugins = {}
144
+ unless @plugins.nil? || @plugins.empty?
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
160
+ unless feature_xml
161
+ File.open(File.join(project.base_dir, 'target', 'feature.xml'), 'w') do |f|
162
+ f.write(writeFeatureXml(resolved_plugins.keys, feature_xml.nil? && feature_properties.nil? ))
163
+ end
164
+ path("eclipse/features/#{project.id}_#{project.version}").include File.join(project.base_dir, 'target/feature.xml')
165
+ else
166
+ path("eclipse/features/#{project.id}_#{project.version}").include feature_xml
167
+ end
168
+ unless feature_properties || feature_xml
169
+ File.open(File.join(project.base_dir, 'target', 'feature.properties'), 'w') do |f|
170
+ f.write(writeFeatureProperties())
171
+ end
172
+ path("eclipse/features/#{project.id}_#{project.version}").include File.join(project.base_dir, 'target/feature.properties')
173
+ else
174
+ path("eclipse/features/#{project.id}_#{project.version}").include feature_properties if feature_properties
175
+ end
176
+
177
+ resolved_plugins.each_pair do |info, plugin|
178
+ if info[:unjarred]
179
+ merge(plugin, :path => "eclipse/plugins/#{info[:id]}_#{info[:version]}")
180
+ else
181
+ include(plugin, :as => "eclipse/plugins/#{info[:id]}_#{info[:version]}.jar")
182
+ end
183
+ end
184
+ end
185
+
186
+ protected
187
+
188
+ class ArrayAddWithOptions < Array
189
+
190
+ def initialize(options_hash)
191
+ @options_hash = options_hash
192
+ end
193
+
194
+ def add_with_options(plugin, options = {:unjarred => false})
195
+ add(plugin)
196
+ @options_hash[plugin] = options[:unjarred] if options[:unjarred]
197
+ end
198
+
199
+ alias :add :<<
200
+ alias :<< :add_with_options
201
+
202
+ end
203
+
204
+ def adaptPlugin(plugin)
205
+ name = nil
206
+ size = nil
207
+ version = nil
208
+ group = nil
209
+ if plugin.is_a? Buildr::Project
210
+ plugin.package(:plugin).invoke #make sure it is present.
211
+ size = File.size(plugin.package(:plugin).to_s)
212
+ name = plugin.package(:plugin).manifest.main["Bundle-SymbolicName"]
213
+ version = plugin.package(:plugin).manifest.main["Bundle-Version"]
214
+ group = plugin.group
215
+ else
216
+ plugin.invoke
217
+ Zip::ZipFile.open(plugin.to_s) do |zip|
218
+ entry = zip.find_entry("META-INF/MANIFEST.MF")
219
+ unless entry.nil?
220
+ manifest = Manifest.read(zip.read("META-INF/MANIFEST.MF"))
221
+ bundle = ::OSGi::Bundle.fromManifest(manifest, plugin.to_s)
222
+ unless bundle.nil?
223
+ name = bundle.name
224
+ version = bundle.version
225
+ end
226
+ end
227
+ end
228
+ group = plugin.to_hash[:group]
229
+ size = File.size(plugin.to_s)
230
+ end
231
+ if (name.nil? || version.nil?)
232
+ raise "The dependency #{plugin} is not an Eclipse plugin: make sure the headers " +
233
+ "Bundle-SymbolicName and Bundle-Version are present in the manifest"
234
+ end
235
+ if size.nil?
236
+ warn "Could not determine the size of #{plugin}"
237
+ size ||= 0
238
+ end
239
+ return {:id => name, :group => group, :version => version,
240
+ :"download-size" => size, :"install-size" => size, :unpack => false}
241
+ end
242
+ end
243
+
244
+ # Methods added to project to package a project as a feature
245
+ #
246
+ module ActAsFeature
247
+ include Extension
248
+
249
+ protected
250
+
251
+ def package_as_feature(file_name)
252
+ task = FeatureTask.define_task(file_name)
253
+ task.extend FeatureWriter
254
+ task.enhance do |feature|
255
+ feature.generateFeature(project)
256
+ end
257
+ end
258
+
259
+ def package_as_feature_spec(spec) #:nodoc:
260
+ spec.merge(:type=>:jar, :classifier=>'feature')
261
+ end
262
+ end
263
+
264
+ end
265
+
266
+
267
+ module Buildr #:nodoc:
268
+ class Project #:nodoc:
269
+ include Buildr4OSGi::ActAsFeature
270
+ end
271
+ end