buildr 1.3.5-x86-mswin32 → 1.4.0-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/CHANGELOG +153 -8
  2. data/README.rdoc +1 -1
  3. data/addon/buildr/antlr.rb +5 -5
  4. data/addon/buildr/drb.rb +18 -18
  5. data/addon/buildr/hibernate.rb +18 -14
  6. data/addon/buildr/javacc.rb +4 -4
  7. data/addon/buildr/jetty.rb +5 -5
  8. data/addon/buildr/nailgun.rb +23 -23
  9. data/addon/buildr/openjpa.rb +1 -1
  10. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  11. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  12. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  13. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  15. data/addon/buildr/protobuf.rb +75 -0
  16. data/addon/buildr/xmlbeans.rb +5 -5
  17. data/buildr.buildfile +2 -2
  18. data/buildr.gemspec +8 -7
  19. data/doc/_layouts/default.html +2 -2
  20. data/doc/artifacts.textile +4 -4
  21. data/doc/building.textile +35 -3
  22. data/doc/contributing.textile +5 -0
  23. data/doc/download.textile +16 -5
  24. data/doc/extending.textile +38 -12
  25. data/doc/installing.textile +6 -5
  26. data/doc/languages.textile +182 -42
  27. data/doc/more_stuff.textile +2 -2
  28. data/doc/packaging.textile +14 -15
  29. data/doc/projects.textile +7 -2
  30. data/doc/quick_start.textile +4 -4
  31. data/doc/scripts/buildr-git.rb +63 -63
  32. data/doc/scripts/gitflow.rb +21 -21
  33. data/doc/settings_profiles.textile +9 -2
  34. data/doc/testing.textile +16 -5
  35. data/etc/KEYS +38 -0
  36. data/lib/buildr.rb +1 -1
  37. data/lib/buildr/core.rb +1 -0
  38. data/lib/buildr/core/application.rb +33 -27
  39. data/lib/buildr/core/build.rb +41 -28
  40. data/lib/buildr/core/cc.rb +172 -0
  41. data/lib/buildr/core/checks.rb +1 -1
  42. data/lib/buildr/core/common.rb +7 -6
  43. data/lib/buildr/core/compile.rb +7 -8
  44. data/lib/buildr/core/doc.rb +263 -0
  45. data/lib/buildr/core/environment.rb +6 -6
  46. data/lib/buildr/core/filter.rb +77 -35
  47. data/lib/buildr/core/generate.rb +7 -7
  48. data/lib/buildr/core/help.rb +1 -1
  49. data/lib/buildr/core/osx.rb +6 -6
  50. data/lib/buildr/core/progressbar.rb +4 -4
  51. data/lib/buildr/core/project.rb +144 -36
  52. data/lib/buildr/core/shell.rb +34 -34
  53. data/lib/buildr/core/test.rb +89 -20
  54. data/lib/buildr/core/transports.rb +8 -7
  55. data/lib/buildr/core/util.rb +77 -23
  56. data/lib/buildr/groovy/bdd.rb +5 -5
  57. data/lib/buildr/groovy/compiler.rb +19 -15
  58. data/lib/buildr/groovy/shell.rb +6 -6
  59. data/lib/buildr/ide/eclipse.rb +148 -75
  60. data/lib/buildr/ide/eclipse/java.rb +3 -3
  61. data/lib/buildr/ide/eclipse/plugin.rb +8 -5
  62. data/lib/buildr/ide/eclipse/scala.rb +4 -2
  63. data/lib/buildr/ide/idea.rb +2 -2
  64. data/lib/buildr/ide/idea7x.rb +23 -4
  65. data/lib/buildr/java.rb +1 -0
  66. data/lib/buildr/java/ant.rb +4 -4
  67. data/lib/buildr/java/bdd.rb +51 -54
  68. data/lib/buildr/java/cobertura.rb +57 -35
  69. data/lib/buildr/java/commands.rb +14 -5
  70. data/lib/buildr/java/compiler.rb +3 -217
  71. data/lib/buildr/java/deprecated.rb +4 -4
  72. data/lib/buildr/java/doc.rb +70 -0
  73. data/lib/buildr/java/emma.rb +22 -22
  74. data/lib/buildr/java/jruby.rb +4 -4
  75. data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
  76. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  77. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
  78. data/lib/buildr/java/packaging.rb +30 -29
  79. data/lib/buildr/java/pom.rb +4 -4
  80. data/lib/buildr/java/rjb.rb +6 -6
  81. data/lib/buildr/java/test_result.rb +61 -85
  82. data/lib/buildr/java/tests.rb +44 -27
  83. data/lib/buildr/java/version_requirement.rb +8 -8
  84. data/lib/buildr/packaging/archive.rb +55 -22
  85. data/lib/buildr/packaging/artifact.rb +75 -36
  86. data/lib/buildr/packaging/artifact_namespace.rb +90 -78
  87. data/lib/buildr/packaging/artifact_search.rb +5 -5
  88. data/lib/buildr/packaging/gems.rb +11 -7
  89. data/lib/buildr/packaging/package.rb +10 -7
  90. data/lib/buildr/packaging/tar.rb +14 -14
  91. data/lib/buildr/packaging/version_requirement.rb +30 -10
  92. data/lib/buildr/packaging/ziptask.rb +51 -13
  93. data/lib/buildr/scala.rb +1 -0
  94. data/lib/buildr/scala/bdd.rb +25 -20
  95. data/lib/buildr/scala/compiler.rb +87 -40
  96. data/lib/buildr/scala/doc.rb +106 -0
  97. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  98. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  99. data/lib/buildr/scala/shell.rb +14 -9
  100. data/lib/buildr/scala/tests.rb +33 -26
  101. data/lib/buildr/shell.rb +33 -33
  102. data/rakelib/all-in-one.rake +113 -0
  103. data/rakelib/checks.rake +1 -1
  104. data/rakelib/doc.rake +7 -0
  105. data/rakelib/package.rake +1 -1
  106. data/rakelib/release.rake +9 -6
  107. data/rakelib/rspec.rake +26 -7
  108. data/rakelib/setup.rake +15 -3
  109. data/rakelib/stage.rake +18 -11
  110. data/spec/addon/drb_spec.rb +25 -25
  111. data/spec/core/application_spec.rb +111 -21
  112. data/spec/core/build_spec.rb +16 -15
  113. data/spec/core/cc_spec.rb +174 -0
  114. data/spec/core/checks_spec.rb +34 -34
  115. data/spec/core/common_spec.rb +51 -5
  116. data/spec/core/compile_spec.rb +89 -14
  117. data/spec/core/extension_spec.rb +127 -19
  118. data/spec/core/generate_spec.rb +2 -2
  119. data/spec/core/project_spec.rb +10 -10
  120. data/spec/core/test_spec.rb +144 -35
  121. data/spec/core/transport_spec.rb +8 -8
  122. data/spec/core/util_spec.rb +63 -5
  123. data/spec/groovy/bdd_spec.rb +5 -5
  124. data/spec/groovy/compiler_spec.rb +29 -18
  125. data/spec/ide/eclipse_spec.rb +185 -9
  126. data/spec/ide/idea7x_spec.rb +22 -10
  127. data/spec/java/ant_spec.rb +9 -5
  128. data/spec/java/bdd_spec.rb +29 -37
  129. data/spec/java/cobertura_spec.rb +12 -12
  130. data/spec/java/commands_spec.rb +34 -0
  131. data/spec/java/compiler_spec.rb +53 -53
  132. data/spec/java/emma_spec.rb +11 -11
  133. data/spec/java/java_spec.rb +10 -10
  134. data/spec/java/packaging_spec.rb +67 -20
  135. data/spec/java/test_coverage_helper.rb +18 -18
  136. data/spec/java/tests_spec.rb +13 -9
  137. data/spec/packaging/archive_spec.rb +187 -20
  138. data/spec/packaging/artifact_namespace_spec.rb +172 -83
  139. data/spec/packaging/artifact_spec.rb +83 -18
  140. data/spec/packaging/packaging_spec.rb +41 -14
  141. data/spec/sandbox.rb +23 -12
  142. data/spec/scala/bdd_spec.rb +13 -8
  143. data/spec/scala/compiler_spec.rb +18 -13
  144. data/spec/scala/scala.rb +3 -3
  145. data/spec/scala/tests_spec.rb +46 -24
  146. data/spec/spec_helpers.rb +28 -10
  147. data/spec/version_requirement_spec.rb +25 -11
  148. metadata +149 -133
  149. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  150. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
  151. data/rakelib/stage.rake~ +0 -213
@@ -18,7 +18,7 @@ require 'buildr/packaging/version_requirement'
18
18
 
19
19
 
20
20
  module Buildr
21
-
21
+
22
22
  # An ArtifactNamespace is a hierarchical dictionary used to manage ArtifactRequirements.
23
23
  # It can be used to have different artifact versions per project
24
24
  # or to allow users to select a version for addons or modules.
@@ -31,27 +31,27 @@ module Buildr
31
31
  # The method_missing method for instances provides some syntactic sugar to these.
32
32
  # See the following examples, and the methods for ArtifactRequirement.
33
33
  #
34
- # = Avoiding constant polution on buildfile
34
+ # = Avoiding constant pollution on buildfile
35
35
  #
36
- # Each project has its own ArtifactNamespace inheriting the one from the
36
+ # Each project has its own ArtifactNamespace inheriting the one from the
37
37
  # parent project up to the root namespace.
38
- #
39
- # Consider the following snippet, as project grows, each subproject
40
- # may need diferent artifact combinations and/or versions. Asigning
38
+ #
39
+ # Consider the following snippet, as project grows, each subproject
40
+ # may need different artifact combinations and/or versions. Assigning
41
41
  # artifact specifications to constants can make it painful to maintain
42
42
  # their references even if using structs/hashes.
43
43
  #
44
44
  # -- buildfile --
45
45
  # SPRING = 'org.springframework:spring:jar:2.5'
46
46
  # SPRING_OLD = 'org.springframework:spring:jar:1.0'
47
- # LOGGING = ['comons-logging:commons-logging:jar:1.1.1',
47
+ # LOGGING = ['comons-logging:commons-logging:jar:1.1.1',
48
48
  # 'log4j:log4j:jar:1.2.15']
49
49
  # WL_LOGGING = artifact('bea:wlcommons-logging:jar:8.1').from('path/to/wlcommons-logging.jar')
50
- # LOGGING_WEBLOGIC = ['comons-logging:commons-logging:jar:1.1.1',
50
+ # LOGGING_WEBLOGIC = ['comons-logging:commons-logging:jar:1.1.1',
51
51
  # WL_LOGGING]
52
52
  # COMMONS = struct :collections => 'commons-collection:commons-collection:jar:3.1',
53
53
  # :net => 'commons-net:commons-net:jar:1.4.0'
54
- #
54
+ #
55
55
  # define 'example1' do
56
56
  # define 'one' do
57
57
  # compile.with SPRING, LOGGING_WEBLOGIC, COMMONS
@@ -64,11 +64,11 @@ module Buildr
64
64
  # end
65
65
  # end
66
66
  #
67
- #
67
+ #
68
68
  # With ArtifactNamespace you can do some more advanced stuff, the following
69
69
  # annotated snipped could still be reduced if default artifact definitions were
70
- # loaded from yaml file (see section bellow and ArtifactNamespace.load).
71
- #
70
+ # loaded from yaml file (see section below and ArtifactNamespace.load).
71
+ #
72
72
  # -- buildfile --
73
73
  # artifact_ns do |ns| # the current namespace (root if called outside a project)
74
74
  # # default artifacts
@@ -83,15 +83,15 @@ module Buildr
83
83
  # :logging => 'comons-logging:commons-logging:jar:1.1.1'
84
84
  #
85
85
  #
86
- # # When a child namespace asks for the :log artifact,
86
+ # # When a child namespace asks for the :log artifact,
87
87
  # # these artifacts will be searched starting from the :current namespace.
88
88
  # ns.virtual :log, :logger, :commons_logging
89
89
  # end
90
- #
90
+ #
91
91
  # artifact_ns('example2:one') do |ns| # namespace for the one subproject
92
92
  # ns.logger = artifact('bea:wlcommons-logging:jar:8.1').from('path/to/wlcommons-logging.jar')
93
93
  # end
94
- # artifact_ns('example2:two') do |ns|
94
+ # artifact_ns('example2:two') do |ns|
95
95
  # ns.spring = '1.0' # for project two use an older spring version (just for an example)
96
96
  # end
97
97
  # artifact_ns('example2:three').commons_collections = 2.2'
@@ -100,8 +100,8 @@ module Buildr
100
100
  # ns.ns(:compilation).use :commons_logging, :beanutils, :spring # compile time dependencies
101
101
  # ns.ns(:testing).use :log, :beanutils, 'cglib:cglib-nodep:jar:2.1.3' # run time dependencies
102
102
  # end
103
- #
104
- # define 'example2' do
103
+ #
104
+ # define 'example2' do
105
105
  # define 'one' do
106
106
  # compile.with :spring, :log, :commons # uses weblogic logging
107
107
  # end
@@ -130,14 +130,14 @@ module Buildr
130
130
  # An example usage is documented on the ArtifactNamespace.load method.
131
131
  #
132
132
  # = For addon/plugin writers & Customizing artifact versions
133
- #
133
+ #
134
134
  # Sometimes users would need to change the default artifact versions used by some
135
135
  # module, for example, the XMLBeans compiler needs this, because of compatibility
136
136
  # issues. Another example would be to select the groovy version to use on all our
137
137
  # projects so that Buildr modules requiring groovy jars can use user prefered versions.
138
138
  #
139
- # To meet this goal, an ArtifactNamespace allows to specify ArgumentRequirement objects.
140
- # In fact the only diference with the examples you have already seen is that requirements
139
+ # To meet this goal, an ArtifactNamespace allows to specify ArtifactRequirement objects.
140
+ # In fact the only difference with the examples you have already seen is that requirements
141
141
  # have an associated VersionRequirement, so that each time a user tries to select a version,
142
142
  # buildr checks if it satisfies the requirements.
143
143
  #
@@ -145,14 +145,14 @@ module Buildr
145
145
  # syntactic sugar is provided by ArtifactNamespace#method_missing.
146
146
  #
147
147
  # The following example is taken from the XMLBeans compiler module.
148
- # And illustrates how addon authors should specify their requirements,
148
+ # And illustrates how addon authors should specify their requirements,
149
149
  # provide default versions, and document the namespace for users to customize.
150
- #
150
+ #
151
151
  # module Buildr::XMLBeans
152
152
  #
153
153
  # # You need to document this constant, giving users some hints
154
- # # about when are (maybe some of) these artifacts used. I mean,
155
- # # some modules, add jars to the Buildr classpath when its file
154
+ # # about when are (maybe some of) these artifacts used. I mean,
155
+ # # some modules, add jars to the Buildr classpath when its file
156
156
  # # is required, you would need to tell your users, so that they
157
157
  # # can open the namespace and specify their defaults. Of course
158
158
  # # when the requirements are defined, buildr checks if any compatible
@@ -174,29 +174,29 @@ module Buildr
174
174
  # ns.need " some_name -> ar:ti:fact:3.2.5 -> ( >2 & <4)"
175
175
  #
176
176
  # # As you can see it's just an artifact spec, prefixed with
177
- # # ' some_name -> ', this means users can use that name to
177
+ # # ' some_name -> ', this means users can use that name to
178
178
  # # reference the requirement, also this string has a VersionRequirement
179
179
  # # just after another ->.
180
180
  # end
181
181
  #
182
- # # The REQUIRES constant is an ArtifactNamespace instance,
183
- # # that means we can use it directly. Note that calling
182
+ # # The REQUIRES constant is an ArtifactNamespace instance,
183
+ # # that means we can use it directly. Note that calling
184
184
  # # Buildr.artifact_ns would lead to the currently executing context,
185
185
  # # not the one for this module.
186
186
  # def use
187
187
  # # test if user specified his own version, if so, we could perform some
188
188
  # # functionallity based on this.
189
- # REQUIRES.some_name.selected? # => false
190
- #
189
+ # REQUIRES.some_name.selected? # => false
190
+ #
191
191
  # REQUIRES.some_name.satisfied_by?('1.5') # => false
192
192
  # puts REQUIRES.some_name.requirement # => ( >2 & <4 )
193
193
  #
194
194
  # REQUIRES.artifacts # get the Artifact tasks
195
195
  # end
196
196
  #
197
- # end
197
+ # end
198
198
  #
199
- # A more advanced example using ArtifactRequirement listeners is included
199
+ # A more advanced example using ArtifactRequirement listeners is included
200
200
  # in the artifact_namespace_spec.rb description for 'Extension using ArtifactNamespace'
201
201
  # That's it for addon writers, now, users can select their prefered version with
202
202
  # something like:
@@ -210,8 +210,8 @@ module Buildr
210
210
  #
211
211
  # Buildr::XMLBeans::REQUIRES.parent = :current
212
212
  #
213
- # Now, provided that the compiler does not caches its artifacts, it will
214
- # select the correct version. (See the first section for how to select per project
213
+ # Now, provided that the compiler does not caches its artifacts, it will
214
+ # select the correct version. (See the first section for how to select per project
215
215
  # artifacts).
216
216
  #
217
217
  #
@@ -224,7 +224,7 @@ module Buildr
224
224
  const_set(:ROOT, new('root'))
225
225
  end
226
226
 
227
- # Populate namespaces from a hash of hashes.
227
+ # Populate namespaces from a hash of hashes.
228
228
  # The following example uses the profiles yaml to achieve this.
229
229
  #
230
230
  # -- profiles.yaml --
@@ -235,8 +235,8 @@ module Buildr
235
235
  # groovy: org.codehaus.groovy:groovy:jar:1.5.4
236
236
  # logging: # define a named group
237
237
  # - log4j:log4j:jar:1.2.15
238
- # - commons-logging:commons-logging:1.1.1
239
- #
238
+ # - commons-logging:commons-logging:jar:1.1.1
239
+ #
240
240
  # # open Buildr::XMLBeans namespace
241
241
  # Buildr::XMLBeans:
242
242
  # xmlbeans: 2.2
@@ -246,11 +246,11 @@ module Buildr
246
246
  # spring: org.springframework:spring:jar:1.0
247
247
  #
248
248
  # -- buildfile --
249
- # ArtifactNamespace.load(Buildr.profile['artifacts'])
249
+ # ArtifactNamespace.load(Buildr.settings.profile['artifacts'])
250
250
  def load(namespaces = {})
251
251
  namespaces.each_pair { |name, uses| instance(name).use(uses) }
252
252
  end
253
-
253
+
254
254
  # :call-seq:
255
255
  # ArtifactNamespace.instance { |current_ns| ... } -> current_ns
256
256
  # ArtifactNamespace.instance(name) { |ns| ... } -> ns
@@ -274,17 +274,20 @@ module Buildr
274
274
  end
275
275
  end
276
276
  name = name.to_s
277
- return ROOT if name.size == 0
278
- name = name.to_s
279
- @instances ||= Hash.new { |h, k| h[k] = new(k) }
280
- instance = @instances[name]
277
+ if name.size == 0
278
+ instance = ROOT
279
+ else
280
+ name = name.to_s
281
+ @instances ||= Hash.new { |h, k| h[k] = new(k) }
282
+ instance = @instances[name]
283
+ end
281
284
  yield(instance) if block_given?
282
285
  instance
283
286
  end
284
287
 
285
288
  alias_method :[], :instance
286
289
  alias_method :for, :instance
287
-
290
+
288
291
  # :call-seq:
289
292
  # ArtifactNamespace.root { |ns| ... } -> ns
290
293
  #
@@ -296,9 +299,9 @@ module Buildr
296
299
  end
297
300
 
298
301
  module DClone #:nodoc:
299
- def dclone
302
+ def dclone
300
303
  clone = self.clone
301
- clone.instance_variables.each do |i|
304
+ clone.instance_variables.each do |i|
302
305
  value = clone.instance_variable_get(i)
303
306
  value = value.dclone rescue
304
307
  clone.instance_variable_set(i, value)
@@ -325,7 +328,7 @@ module Buildr
325
328
  end
326
329
  obj
327
330
  end
328
-
331
+
329
332
  def aliases(name)
330
333
  return [] unless name
331
334
  name = name.to_sym
@@ -338,7 +341,7 @@ module Buildr
338
341
  end
339
342
 
340
343
  def get(key, include_parent = nil)
341
- [].tap { |a| aliases(key).select { |n| a[0] = self[n] } }.first ||
344
+ [].tap { |a| aliases(key).select { |n| a[0] = self[n] } }.first ||
342
345
  (include_parent && parent && parent.get(key, include_parent))
343
346
  end
344
347
 
@@ -361,17 +364,17 @@ module Buildr
361
364
  end
362
365
 
363
366
  # An artifact requirement is an object that ActsAsArtifact and has
364
- # an associated VersionRequirement. It also knows the name (some times equal to the
367
+ # an associated VersionRequirement. It also knows the name (some times equal to the
365
368
  # artifact id) that is used to store it in an ArtifactNamespace.
366
369
  class ArtifactRequirement
367
370
  attr_accessor :version
368
371
  attr_reader :name, :requirement
369
372
 
370
373
  include DClone
371
-
374
+
372
375
  # Create a requirement from an `artifact requirement spec`.
373
- # This spec has three parts, separated by ->
374
- #
376
+ # This spec has three parts, separated by ->
377
+ #
375
378
  # some_name -> ar:ti:fact:3.2.5 -> ( >2 & <4)
376
379
  #
377
380
  # As you can see it's just an artifact spec, prefixed with
@@ -387,7 +390,7 @@ module Buildr
387
390
  #
388
391
  # The last part consist of a VersionRequirement.
389
392
  # -> ( >2 & <4)
390
- #
393
+ #
391
394
  # VersionRequirement supports RubyGem's comparision operators
392
395
  # in adition to parens, logical and, logical or and negation.
393
396
  # See the docs for VersionRequirement for more info on operators.
@@ -416,7 +419,7 @@ module Buildr
416
419
  def name=(name)
417
420
  @name = name.to_s
418
421
  end
419
-
422
+
420
423
  # Set a the requirement, this must be an string formatted for
421
424
  # VersionRequirement#create to parse.
422
425
  def requirement=(version_requirement)
@@ -426,7 +429,7 @@ module Buildr
426
429
  # Return a hash consisting of :name, :spec, :requirement
427
430
  def requirement_hash(spec = self)
428
431
  result = {}
429
- if String === spec
432
+ if String === spec
430
433
  parts = spec.split(/\s*->\s*/, 3).map(&:strip)
431
434
  case parts.size
432
435
  when 1
@@ -451,7 +454,7 @@ module Buildr
451
454
  result[:requirement] ||= VersionRequirement.create(result[:spec][:version])
452
455
  result
453
456
  end
454
-
457
+
455
458
  # Test if this requirement is satisfied by an artifact spec.
456
459
  def satisfied_by?(spec)
457
460
  return false unless requirement
@@ -502,7 +505,7 @@ module Buildr
502
505
  ary = ary[0...-1] if ary.size > 3
503
506
  ary.join(':')
504
507
  end
505
-
508
+
506
509
  class << self
507
510
  # Return an artifact spec without the version part.
508
511
  def unversioned_spec(spec)
@@ -522,16 +525,17 @@ module Buildr
522
525
  include DClone
523
526
  include Enumerable
524
527
  attr_reader :name
525
-
528
+
526
529
  def initialize(name = nil) #:nodoc:
527
530
  @name = name.to_s if name
528
531
  end
529
532
  clear
530
-
533
+
531
534
  def root
535
+ yield ROOT if block_given?
532
536
  ROOT
533
537
  end
534
-
538
+
535
539
  # ROOT namespace has no parent
536
540
  def parent
537
541
  if root?
@@ -547,22 +551,22 @@ module Buildr
547
551
  root
548
552
  end
549
553
  end
550
-
554
+
551
555
  # Set the parent for the current namespace, except if it is ROOT
552
556
  def parent=(other)
553
557
  raise 'Cannot set parent of root namespace' if root?
554
558
  @parent = other
555
559
  @registry = nil
556
560
  end
557
-
561
+
558
562
  # Is this the ROOT namespace?
559
563
  def root?
560
564
  ROOT == self
561
565
  end
562
566
 
563
- # Create a named sub-namespace, sub-namespaces are themselves
567
+ # Create a named sub-namespace, sub-namespaces are themselves
564
568
  # ArtifactNamespace instances but cannot be referenced by
565
- # the Buildr.artifact_ns, ArtifactNamespace.instance methods.
569
+ # the Buildr.artifact_ns, ArtifactNamespace.instance methods.
566
570
  # Reference needs to be through this object using the given +name+
567
571
  #
568
572
  # artifact_ns('foo').ns(:bar).need :thing => 'some:thing:jar:1.0'
@@ -617,7 +621,7 @@ module Buildr
617
621
  end
618
622
  named.each_pair do |name, artifact|
619
623
  if Array === artifact # a group
620
- artifact.each do |a|
624
+ artifact.each do |a|
621
625
  unvers = a.unversioned_spec
622
626
  previous = registry[unvers]
623
627
  if previous && previous.selected? && a.satisfied_by?(previous)
@@ -645,7 +649,7 @@ module Buildr
645
649
  # artifact_ns.use :name => 'org:foo:bar:jar:1.2.3'
646
650
  # artifact_ns.use :name => '2.5.6'
647
651
  #
648
- # First and second form are equivalent, the third is used when an
652
+ # First and second form are equivalent, the third is used when an
649
653
  # ArtifactRequirement has been previously defined with :name, so it
650
654
  # just selects the version.
651
655
  #
@@ -686,7 +690,7 @@ module Buildr
686
690
  is_group = Array === artifact
687
691
  artifact = [artifact].flatten.map do |artifact|
688
692
  unvers = artifact.unversioned_spec
689
- previous = get(unvers, false) || get(name, false)
693
+ previous = get(unvers, false) || get(name, false)
690
694
  if previous # have previous on current namespace
691
695
  if previous.requirement # we must satisfy the requirement
692
696
  unless unvers # we only have the version
@@ -697,7 +701,7 @@ module Buildr
697
701
  raise "Unsatisfied dependency #{previous} " +
698
702
  "not satisfied by #{artifact}" unless satisfied
699
703
  previous.version = artifact.version # OK, set new version
700
- artifact = previous # use the same object for aliases
704
+ artifact = previous # use the same object for aliases
701
705
  else # not a requirement, set the new values
702
706
  unless artifact.id == previous.id && name != previous.name
703
707
  previous.copy_attrs(artifact)
@@ -711,13 +715,13 @@ module Buildr
711
715
  artifact.copy_attrs(previous)
712
716
  artifact.version = version
713
717
  end
714
- artifact.requirement = nil
718
+ artifact.requirement = nil
715
719
  end
716
720
  artifact.selected!
717
721
  end
718
722
  artifact = artifact.first unless is_group
719
723
  if is_group
720
- names = artifact.map do |art|
724
+ names = artifact.map do |art|
721
725
  unv = art.unversioned_spec
722
726
  registry[unv] = art
723
727
  unv
@@ -792,7 +796,7 @@ module Buildr
792
796
 
793
797
  # Return only the named requirements
794
798
  def values_at(*names)
795
- names.map do |name|
799
+ names.map do |name|
796
800
  catch :artifact do
797
801
  unless name.to_s[/^[\w\-\.]+$/]
798
802
  unvers = ArtifactRequirement.unversioned_spec(name)
@@ -816,11 +820,19 @@ module Buildr
816
820
  registry.key?(name, include_parents)
817
821
  end
818
822
 
823
+ def keys
824
+ values.map(&:name)
825
+ end
826
+
819
827
  def delete(name, include_parents = false)
820
828
  registry.delete(name, include_parents)
821
829
  self
822
830
  end
823
-
831
+
832
+ def clear
833
+ keys.each { |k| delete(k) }
834
+ end
835
+
824
836
  # :call-seq:
825
837
  # group :who, :me, :you
826
838
  # group :them, :me, :you, :namespace => ns
@@ -828,7 +840,7 @@ module Buildr
828
840
  # Create a virtual group on this namespace. When the namespace
829
841
  # is asked for the +who+ artifact, it's value is an array made from
830
842
  # the remaining names. These names are searched by default from the current
831
- # namespace.
843
+ # namespace.
832
844
  # Second form specified the starting namespace to search from.
833
845
  def group(group_name, *members)
834
846
  namespace = (Hash === members.last && members.pop[:namespace]) || :current
@@ -867,7 +879,7 @@ module Buildr
867
879
  # and is equivalent to:
868
880
  # artifact_ns.use :cool_aid => '1.0'
869
881
  #
870
- # Third form obtains the named ArtifactRequirement, can be
882
+ # Third form obtains the named ArtifactRequirement, can be
871
883
  # used to test if a named requirement has been defined.
872
884
  # It is equivalent to:
873
885
  # artifact_ns.fetch(:cool_aid) { nil }
@@ -892,7 +904,7 @@ module Buildr
892
904
  when /\?$/ then
893
905
  name = $`.gsub(/^(has|have)_/, '').intern
894
906
  [get(name)].flatten.all? { |a| a && a.selected? }
895
- else
907
+ else
896
908
  if block || args.size > 0
897
909
  raise ArgumentError.new("wrong number of arguments #{args.size} for 0 or block given")
898
910
  end
@@ -900,7 +912,7 @@ module Buildr
900
912
  end
901
913
  end
902
914
 
903
- # Return an anonymous module
915
+ # Return an anonymous module
904
916
  # # first create a requirement
905
917
  # artifact_ns.cool_aid! 'cool:aid:jar:>=1.0'
906
918
  #
@@ -911,7 +923,7 @@ module Buildr
911
923
  # artifact_ns.cool_aid.version # -> '2.0'
912
924
  def accessor(*names)
913
925
  ns = self
914
- Module.new do
926
+ Module.new do
915
927
  names.each do |name|
916
928
  define_method("#{name}") { ns.send("#{name}") }
917
929
  define_method("#{name}?") { ns.send("#{name}?") }
@@ -950,7 +962,7 @@ module Buildr
950
962
  m.parent = parent.send(:registry) unless root?
951
963
  end
952
964
  end
953
-
965
+
954
966
  end # ArtifactNamespace
955
967
 
956
968
  # :call-seq:
@@ -966,7 +978,7 @@ module Buildr
966
978
  name = self if name.nil? && self.kind_of?(Project)
967
979
  ArtifactNamespace.instance(name, &block)
968
980
  end
969
-
981
+
970
982
  end
971
983
 
972
984