novoda-buildr 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/CHANGELOG +1050 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +245 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +90 -0
  40. data/doc/extending.textile +205 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +265 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +429 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +276 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +287 -0
  68. data/doc/testing.textile +233 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +662 -0
  73. data/lib/buildr/core/build.rb +463 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +363 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +971 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +774 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +424 -0
  94. data/lib/buildr/ide/eclipse.rb~ +424 -0
  95. data/lib/buildr/ide/eclipse/java.rb +53 -0
  96. data/lib/buildr/ide/eclipse/plugin.rb +71 -0
  97. data/lib/buildr/ide/eclipse/scala.rb +68 -0
  98. data/lib/buildr/ide/idea.ipr.template +300 -0
  99. data/lib/buildr/ide/idea.rb +190 -0
  100. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  101. data/lib/buildr/ide/idea7x.rb +212 -0
  102. data/lib/buildr/java.rb +23 -0
  103. data/lib/buildr/java/ant.rb +94 -0
  104. data/lib/buildr/java/bdd.rb +464 -0
  105. data/lib/buildr/java/cobertura.rb +274 -0
  106. data/lib/buildr/java/commands.rb +217 -0
  107. data/lib/buildr/java/compiler.rb +349 -0
  108. data/lib/buildr/java/deprecated.rb +141 -0
  109. data/lib/buildr/java/emma.rb +244 -0
  110. data/lib/buildr/java/jruby.rb +117 -0
  111. data/lib/buildr/java/jtestr_runner.rb.erb +118 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  113. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  114. data/lib/buildr/java/packaging.rb +717 -0
  115. data/lib/buildr/java/pom.rb +174 -0
  116. data/lib/buildr/java/rjb.rb +155 -0
  117. data/lib/buildr/java/test_result.rb +327 -0
  118. data/lib/buildr/java/tests.rb +341 -0
  119. data/lib/buildr/java/version_requirement.rb +172 -0
  120. data/lib/buildr/packaging.rb +24 -0
  121. data/lib/buildr/packaging/archive.rb +491 -0
  122. data/lib/buildr/packaging/artifact.rb +750 -0
  123. data/lib/buildr/packaging/artifact_namespace.rb +980 -0
  124. data/lib/buildr/packaging/artifact_search.rb +140 -0
  125. data/lib/buildr/packaging/gems.rb +106 -0
  126. data/lib/buildr/packaging/package.rb +241 -0
  127. data/lib/buildr/packaging/tar.rb +186 -0
  128. data/lib/buildr/packaging/version_requirement.rb +172 -0
  129. data/lib/buildr/packaging/zip.rb +73 -0
  130. data/lib/buildr/packaging/ziptask.rb +316 -0
  131. data/lib/buildr/resources/buildr.icns +0 -0
  132. data/lib/buildr/scala.rb +25 -0
  133. data/lib/buildr/scala/bdd.rb +114 -0
  134. data/lib/buildr/scala/compiler.rb +196 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  137. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  138. data/lib/buildr/scala/shell.rb +60 -0
  139. data/lib/buildr/scala/tests.rb +157 -0
  140. data/lib/buildr/shell.rb +180 -0
  141. data/rakelib/all-in-one.rake +84 -0
  142. data/rakelib/checks.rake +57 -0
  143. data/rakelib/doc.rake +92 -0
  144. data/rakelib/jekylltask.rb +120 -0
  145. data/rakelib/package.rake +73 -0
  146. data/rakelib/release.rake +152 -0
  147. data/rakelib/rspec.rake +73 -0
  148. data/rakelib/setup.rake +54 -0
  149. data/rakelib/stage.rake +214 -0
  150. data/spec/addon/drb_spec.rb +328 -0
  151. data/spec/core/application_spec.rb +509 -0
  152. data/spec/core/build_spec.rb +678 -0
  153. data/spec/core/checks_spec.rb +519 -0
  154. data/spec/core/common_spec.rb +670 -0
  155. data/spec/core/compile_spec.rb +624 -0
  156. data/spec/core/extension_spec.rb +201 -0
  157. data/spec/core/generate_spec.rb +33 -0
  158. data/spec/core/project_spec.rb +762 -0
  159. data/spec/core/test_spec.rb +1175 -0
  160. data/spec/core/transport_spec.rb +537 -0
  161. data/spec/core/util_spec.rb +67 -0
  162. data/spec/groovy/bdd_spec.rb +80 -0
  163. data/spec/groovy/compiler_spec.rb +240 -0
  164. data/spec/ide/eclipse_spec.rb +650 -0
  165. data/spec/ide/idea7x_spec.rb +84 -0
  166. data/spec/java/ant_spec.rb +33 -0
  167. data/spec/java/bdd_spec.rb +379 -0
  168. data/spec/java/cobertura_spec.rb +85 -0
  169. data/spec/java/compiler_spec.rb +446 -0
  170. data/spec/java/emma_spec.rb +119 -0
  171. data/spec/java/java_spec.rb +124 -0
  172. data/spec/java/packaging_spec.rb +1140 -0
  173. data/spec/java/test_coverage_helper.rb +257 -0
  174. data/spec/java/tests_spec.rb +493 -0
  175. data/spec/packaging/archive_spec.rb +538 -0
  176. data/spec/packaging/artifact_namespace_spec.rb +697 -0
  177. data/spec/packaging/artifact_spec.rb +802 -0
  178. data/spec/packaging/packaging_helper.rb +63 -0
  179. data/spec/packaging/packaging_spec.rb +684 -0
  180. data/spec/sandbox.rb +148 -0
  181. data/spec/scala/bdd_spec.rb +119 -0
  182. data/spec/scala/compiler_spec.rb +284 -0
  183. data/spec/scala/scala.rb +38 -0
  184. data/spec/scala/tests_spec.rb +263 -0
  185. data/spec/spec_helpers.rb +340 -0
  186. data/spec/version_requirement_spec.rb +143 -0
  187. metadata +384 -0
@@ -0,0 +1,424 @@
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
+ require 'buildr/core/project'
18
+ require 'buildr/packaging'
19
+
20
+
21
+ module Buildr
22
+ module Eclipse #:nodoc:
23
+ include Extension
24
+
25
+ class Eclipse
26
+
27
+ attr_reader :options
28
+
29
+ def initialize(project)
30
+ @project = project
31
+ @options = Options.new(project)
32
+ end
33
+
34
+ # :call-seq:
35
+ # classpath_variables { :VAR => '/path/to/location' }
36
+ # Sets classpath variables to be used for library path substitution
37
+ # on the project.
38
+ #
39
+ def classpath_variables(*values)
40
+ fail "eclipse.classpath_variables expects a single hash argument" if values.size > 1
41
+ if values.size == 1
42
+ fail "eclipse.classpath_variables expects a Hash argument" unless values[0].is_a? Hash
43
+ # convert keys to strings
44
+ values = values[0].inject({}) { |h, (k,v)| h[k.to_s] = @project.path_to(v); h }
45
+ @variables = values.merge(@variables || {})
46
+ end
47
+ @variables || (@project.parent ? @project.parent.eclipse.classpath_variables : default_classpath_variables)
48
+ end
49
+
50
+ def default_classpath_variables
51
+ vars = {}
52
+ vars[:SCALA_HOME] = ENV['SCALA_HOME'] if ENV['SCALA_HOME']
53
+ vars[:JAVA_HOME] = ENV['JAVA_HOME'] if ENV['JAVA_HOME']
54
+ vars
55
+ end
56
+
57
+ # :call-seq:
58
+ # natures=(natures)
59
+ # Sets the Eclipse project natures on the project.
60
+ #
61
+ def natures=(var)
62
+ @natures = arrayfy(var)
63
+ end
64
+
65
+ # :call-seq:
66
+ # natures() => [n1, n2]
67
+ # Returns the Eclipse project natures on the project.
68
+ # They may be derived from the parent project if no specific natures have been set
69
+ # on the project.
70
+ #
71
+ # An Eclipse project nature is used internally by Eclipse to determine the aspects of a project.
72
+ def natures(*values)
73
+ if values.size > 0
74
+ @natures ||= []
75
+ @natures += values
76
+ else
77
+ @natures || (@project.parent ? @project.parent.eclipse.natures : [])
78
+ end
79
+ end
80
+
81
+ # :call-seq:
82
+ # classpath_containers=(cc)
83
+ # Sets the Eclipse project classpath containers on the project.
84
+ #
85
+ def classpath_containers=(var)
86
+ @classpath_containers = arrayfy(var)
87
+ end
88
+
89
+ # :call-seq:
90
+ # classpath_containers() => [con1, con2]
91
+ # Returns the Eclipse project classpath containers on the project.
92
+ # They may be derived from the parent project if no specific classpath containers have been set
93
+ # on the project.
94
+ #
95
+ # A classpath container is an Eclipse pre-determined ensemble of dependencies made available to
96
+ # the project classpath.
97
+ def classpath_containers(*values)
98
+ if values.size > 0
99
+ @classpath_containers ||= []
100
+ @classpath_containers += values
101
+ else
102
+ @classpath_containers || (@project.parent ? @project.parent.eclipse.classpath_containers : [])
103
+ end
104
+ end
105
+
106
+ # :call-seq:
107
+ # exclude_libs() => [lib1, lib2]
108
+ # Returns the an array of libraries to be excluded from the generated Eclipse classpath
109
+ def exclude_libs(*values)
110
+ if values.size > 0
111
+ @exclude_libs ||= []
112
+ @exclude_libs += values
113
+ else
114
+ @exclude_libs || (@project.parent ? @project.parent.eclipse.exclude_libs : [])
115
+ end
116
+ end
117
+
118
+ # :call-seq:
119
+ # exclude_libs=(lib1, lib2)
120
+ # Sets libraries to be excluded from the generated Eclipse classpath
121
+ #
122
+ def exclude_libs=(libs)
123
+ @exclude_libs = arrayfy(libs)
124
+ end
125
+
126
+ # :call-seq:
127
+ # builders=(builders)
128
+ # Sets the Eclipse project builders on the project.
129
+ #
130
+ def builders=(var)
131
+ @builders = arrayfy(var)
132
+ end
133
+
134
+ # :call-seq:
135
+ # builders() => [b1, b2]
136
+ # Returns the Eclipse project builders on the project.
137
+ # They may be derived from the parent project if no specific builders have been set
138
+ # on the project.
139
+ #
140
+ # A builder is an Eclipse background job that parses the source code to produce built artifacts.
141
+ def builders(*values)
142
+ if values.size > 0
143
+ @builders ||= []
144
+ @builders += values
145
+ else
146
+ @builders || (@project.parent ? @project.parent.eclipse.builders : [])
147
+ end
148
+ end
149
+
150
+ def external_sources=(var)
151
+ @external_sources = arrayfy(var)
152
+ end
153
+
154
+ def external_sources(*values)
155
+ if values.size > 0
156
+ @external_sources ||= []
157
+ @external_sources += values
158
+ else
159
+ @external_sources || (@project.parent ? @project.parent.eclipse.external_sources : [])
160
+ end
161
+ end
162
+
163
+ private
164
+
165
+ def arrayfy(obj)
166
+ obj.is_a?(Array) ? obj : [obj]
167
+ end
168
+ end
169
+
170
+ class Options
171
+
172
+ attr_writer :m2_repo_var
173
+
174
+ def initialize(project)
175
+ @project = project
176
+ end
177
+
178
+ # The classpath variable used to point at the local maven2 repository.
179
+ # Example:
180
+ # eclipse.options.m2_repo_var = 'M2_REPO'
181
+ def m2_repo_var(*values)
182
+ fail "m2_repo_var can only accept one value: #{values}" if values.size > 1
183
+ if values.size > 0
184
+ @m2_repo_var = values[0]
185
+ else
186
+ @m2_repo_var || (@project.parent ? @project.parent.eclipse.options.m2_repo_var : 'M2_REPO')
187
+ end
188
+ end
189
+ end
190
+
191
+ def eclipse
192
+ @eclipse ||= Eclipse.new(self)
193
+ @eclipse
194
+ end
195
+
196
+ first_time do
197
+ # Global task "eclipse" generates artifacts for all projects.
198
+ desc 'Generate Eclipse artifacts for all projects'
199
+ Project.local_task('eclipse'=>'artifacts') { |name| "Generating Eclipse project for #{name}" }
200
+ end
201
+
202
+ before_define do |project|
203
+ project.recursive_task('eclipse')
204
+ end
205
+
206
+ after_define(:eclipse => :package) do |project|
207
+ # Need to enhance because using project.projects during load phase of the
208
+ # buildfile has harmful side-effects on project definition order
209
+ project.enhance do
210
+ eclipse = project.task('eclipse')
211
+ # We don't create the .project and .classpath files if the project contains projects.
212
+ if project.projects.empty?
213
+
214
+ eclipse.enhance [ file(project.path_to('.classpath')), file(project.path_to('.project')) ]
215
+
216
+ # The only thing we need to look for is a change in the Buildfile.
217
+ file(project.path_to('.classpath')=>Buildr.application.buildfile) do |task|
218
+ if (project.eclipse.natures.reject { |x| x.is_a?(Symbol) }.size > 0)
219
+ info "Writing #{task.name}"
220
+
221
+ m2repo = Buildr::Repositories.instance.local
222
+
223
+ File.open(task.name, 'w') do |file|
224
+ classpathentry = ClasspathEntryWriter.new project, file
225
+ classpathentry.write do
226
+ # Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
227
+ cp = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s, project.resources.target.to_s ]
228
+ cp = cp.uniq
229
+
230
+ # Convert classpath elements into applicable Project objects
231
+ cp.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
232
+
233
+ # Remove excluded libs
234
+ cp -= project.eclipse.exclude_libs.map(&:to_s)
235
+
236
+ # project_libs: artifacts created by other projects
237
+ project_libs, others = cp.partition { |path| path.is_a?(Project) }
238
+
239
+ # Separate artifacts under known classpath variable paths
240
+ # including artifacts located in local Maven2 repository
241
+ vars = []
242
+ project.eclipse.classpath_variables.merge(project.eclipse.options.m2_repo_var => m2repo).each do |name, path|
243
+ matching, others = others.partition { |f| File.expand_path(f.to_s).index(path) == 0 }
244
+ matching.each do |m|
245
+ vars << [m, name, path]
246
+ end
247
+ end
248
+
249
+ # Generated: Any non-file classpath elements in the project are assumed to be generated
250
+ libs, generated = others.partition { |path| File.file?(path.to_s) }
251
+
252
+ classpathentry.src project.compile.sources + generated
253
+ classpathentry.src project.resources
254
+
255
+ if project.test.compile.target
256
+ classpathentry.src project.test.compile
257
+ classpathentry.src project.test.resources
258
+ end
259
+
260
+ # Classpath elements from other projects
261
+ classpathentry.src_projects project_libs
262
+
263
+ classpathentry.output project.compile.target if project.compile.target
264
+ classpathentry.lib libs
265
+ classpathentry.var vars
266
+
267
+ project.eclipse.classpath_containers.each { |container|
268
+ classpathentry.con container
269
+ }
270
+ end
271
+ end
272
+ end
273
+ end
274
+
275
+ # The only thing we need to look for is a change in the Buildfile.
276
+ file(project.path_to('.project')=>Buildr.application.buildfile) do |task|
277
+ info "Writing #{task.name}"
278
+ File.open(task.name, 'w') do |file|
279
+ xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
280
+ xml.projectDescription do
281
+ xml.name project.id
282
+ xml.projects
283
+ unless project.eclipse.builders.empty?
284
+ xml.buildSpec do
285
+ project.eclipse.builders.each { |builder|
286
+ xml.buildCommand do
287
+ xml.name builder
288
+ end
289
+ }
290
+ end
291
+ end
292
+ unless project.eclipse.natures.empty?
293
+ xml.natures do
294
+ project.eclipse.natures.each { |nature|
295
+ xml.nature nature unless nature.is_a? Symbol
296
+ }
297
+ end
298
+ end
299
+ unless project.eclipse.external_sources.empty?
300
+ xml.linkedResources do
301
+ project.eclipse.external_sources.each { |external_source|
302
+ xml.link do
303
+ xml.name external_source.to_s.split(":").last.concat("_src")
304
+ xml.type '2'
305
+ xml.location external_source._(:src)
306
+ end
307
+ }
308
+ end
309
+ end
310
+ end
311
+ end
312
+ end
313
+ end
314
+ end
315
+ end
316
+
317
+
318
+ # Writes 'classpathentry' tags in an xml file.
319
+ # It converts tasks to paths.
320
+ # It converts absolute paths to relative paths.
321
+ # It ignores duplicate directories.
322
+ class ClasspathEntryWriter #:nodoc:
323
+ def initialize project, target
324
+ @project = project
325
+ @xml = Builder::XmlMarkup.new(:target=>target, :indent=>2)
326
+ @excludes = [ '**/.svn/', '**/CVS/' ].join('|')
327
+ @paths_written = []
328
+ end
329
+
330
+ def write &block
331
+ @xml.classpath &block
332
+ end
333
+
334
+ def con path
335
+ @xml.classpathentry :kind=>'con', :path=>path
336
+ end
337
+
338
+ def lib libs
339
+ libs.map(&:to_s).sort.uniq.each do |path|
340
+ @xml.classpathentry :kind=>'lib', :path=>relative(path)
341
+ end
342
+ end
343
+
344
+ # Write a classpathentry of kind 'src'.
345
+ # Accept an array of absolute paths or a task.
346
+ def src arg
347
+ if [:sources, :target].all? { |message| arg.respond_to?(message) }
348
+ src_from_task arg
349
+ else
350
+ src_from_absolute_paths arg
351
+ end
352
+ end
353
+
354
+ # Write a classpathentry of kind 'src' for dependent projects.
355
+ # Accept an array of projects.
356
+ def src_projects project_libs
357
+ project_libs.map(&:id).sort.uniq.each do |project_id|
358
+ @xml.classpathentry :kind=>'src', :combineaccessrules=>'false', :path=>"/#{project_id}"
359
+ end
360
+ end
361
+
362
+ def output target
363
+ @xml.classpathentry :kind=>'output', :path=>relative(target)
364
+ end
365
+
366
+ # Write a classpathentry of kind 'var' (variable) for a library in a local repo.
367
+ # * +libs+ is an array of library paths.
368
+ # * +var_name+ is a variable name as defined in Eclipse (e.g., 'M2_REPO').
369
+ # * +var_value+ is the value of this variable (e.g., '/home/me/.m2').
370
+ # E.g., <tt>var([lib1, lib2], 'M2_REPO', '/home/me/.m2/repo')</tt>
371
+ def var(libs)
372
+ libs.each do |lib_path, var_name, var_value|
373
+ lib_artifact = file(lib_path)
374
+ relative_lib_path = lib_path.sub(var_value, var_name.to_s)
375
+ if lib_artifact.respond_to? :sources_artifact
376
+ source_path = lib_artifact.sources_artifact.to_s
377
+ relative_source_path = source_path.sub(var_value, var_name)
378
+ @xml.classpathentry :kind=>'var', :path=>relative_lib_path, :sourcepath=>relative_source_path
379
+ else
380
+ @xml.classpathentry :kind=>'var', :path=>relative_lib_path
381
+ end
382
+ end
383
+ end
384
+
385
+ private
386
+
387
+ # Find a path relative to the project's root directory.
388
+ def relative path
389
+ path or raise "Invalid path '#{path.inspect}'"
390
+ msg = [:to_path, :to_str, :to_s].find { |msg| path.respond_to? msg }
391
+ path = path.__send__(msg)
392
+ Util.relative_path(File.expand_path(path), @project.path_to)
393
+ end
394
+
395
+ def src_from_task task
396
+ src_from_absolute_paths task.sources, task.target
397
+ end
398
+
399
+ def src_from_absolute_paths absolute_paths, output=nil
400
+ relative_paths = absolute_paths.map { |src| relative(src) }
401
+ relative_paths.sort.uniq.each do |path|buildr
402
+ unless @paths_written.include?(path)
403
+ attributes = { :kind=>'src', :path=>path, :excluding=>@excludes }
404
+ attributes[:output] = relative(output) if output
405
+ @xml.classpathentry attributes
406
+ @paths_written << path
407
+ end
408
+ end
409
+ end
410
+ end
411
+
412
+ end
413
+
414
+ end # module Buildr
415
+
416
+ class Buildr::Project
417
+ include Buildr::Eclipse
418
+ end
419
+
420
+ # Order is significant for auto-detection, from most specific to least
421
+ require 'buildr/ide/eclipse/plugin'
422
+ require 'buildr/ide/eclipse/scala'
423
+ require 'buildr/ide/eclipse/java'
424
+
@@ -0,0 +1,53 @@
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
+ require 'buildr/core/project'
18
+ require 'buildr/core/common'
19
+
20
+ module Buildr
21
+ module Eclipse
22
+ module Java
23
+ include Extension
24
+
25
+ NATURE = 'org.eclipse.jdt.core.javanature'
26
+ CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
27
+ BUILDER = 'org.eclipse.jdt.core.javabuilder'
28
+
29
+ after_define do |project|
30
+ eclipse = project.eclipse
31
+
32
+ # smart defaults
33
+ if project.compile.language == :java || project.test.compile.language == :java
34
+ eclipse.natures = NATURE if eclipse.natures.empty?
35
+ eclipse.classpath_containers = CONTAINER if eclipse.classpath_containers.empty?
36
+ eclipse.builders = BUILDER if eclipse.builders.empty?
37
+ end
38
+
39
+ # :java nature explicitly set
40
+ if eclipse.natures.include? :java
41
+ eclipse.natures += [NATURE] unless eclipse.natures.include? NATURE
42
+ eclipse.classpath_containers += [CONTAINER] unless eclipse.classpath_containers.include? CONTAINER
43
+ eclipse.builders += [BUILDER] unless eclipse.builders.include? BUILDER
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+
51
+ class Buildr::Project
52
+ include Buildr::Eclipse::Java
53
+ end