buildr-gemjar 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/.braids +8 -0
  2. data/.gitignore +5 -0
  3. data/.rvmrc +1 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +20 -0
  7. data/README.md +98 -0
  8. data/Rakefile +8 -0
  9. data/buildr-gemjar.gemspec +42 -0
  10. data/lib/buildr-gemjar.rb +162 -0
  11. data/lib/buildr-gemjar/version.rb +3 -0
  12. data/meta.rakefile +30 -0
  13. data/spec/buildr-gemjar/version_spec.rb +11 -0
  14. data/spec/buildr-gemjar_spec.rb +179 -0
  15. data/spec/repo_builder.rb +59 -0
  16. data/spec/spec_helper.rb +44 -0
  17. data/vendor/buildr/.gitignore +17 -0
  18. data/vendor/buildr/CHANGELOG +1283 -0
  19. data/vendor/buildr/Gemfile +4 -0
  20. data/vendor/buildr/LICENSE +176 -0
  21. data/vendor/buildr/NOTICE +26 -0
  22. data/vendor/buildr/README.rdoc +134 -0
  23. data/vendor/buildr/Rakefile +44 -0
  24. data/vendor/buildr/_buildr +35 -0
  25. data/vendor/buildr/_jbuildr +35 -0
  26. data/vendor/buildr/addon/buildr/antlr.rb +65 -0
  27. data/vendor/buildr/addon/buildr/bnd.rb +147 -0
  28. data/vendor/buildr/addon/buildr/cobertura.rb +22 -0
  29. data/vendor/buildr/addon/buildr/drb.rb +281 -0
  30. data/vendor/buildr/addon/buildr/emma.rb +22 -0
  31. data/vendor/buildr/addon/buildr/hibernate.rb +149 -0
  32. data/vendor/buildr/addon/buildr/javacc.rb +85 -0
  33. data/vendor/buildr/addon/buildr/jaxb_xjc.rb +72 -0
  34. data/vendor/buildr/addon/buildr/jdepend.rb +60 -0
  35. data/vendor/buildr/addon/buildr/jetty.rb +248 -0
  36. data/vendor/buildr/addon/buildr/jibx.rb +86 -0
  37. data/vendor/buildr/addon/buildr/nailgun.rb +221 -0
  38. data/vendor/buildr/addon/buildr/openjpa.rb +88 -0
  39. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  40. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  41. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  42. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  43. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  44. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  45. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  46. data/vendor/buildr/addon/buildr/protobuf.rb +88 -0
  47. data/vendor/buildr/addon/buildr/xmlbeans.rb +93 -0
  48. data/vendor/buildr/all-in-one/_buildr +19 -0
  49. data/vendor/buildr/all-in-one/buildr +368 -0
  50. data/vendor/buildr/all-in-one/buildr.cmd +1 -0
  51. data/vendor/buildr/bin/buildr +19 -0
  52. data/vendor/buildr/buildr.buildfile +58 -0
  53. data/vendor/buildr/buildr.gemspec +74 -0
  54. data/vendor/buildr/doc/_config.yml +1 -0
  55. data/vendor/buildr/doc/_layouts/default.html +90 -0
  56. data/vendor/buildr/doc/_layouts/preface.html +22 -0
  57. data/vendor/buildr/doc/artifacts.textile +217 -0
  58. data/vendor/buildr/doc/building.textile +276 -0
  59. data/vendor/buildr/doc/contributing.textile +268 -0
  60. data/vendor/buildr/doc/css/default.css +236 -0
  61. data/vendor/buildr/doc/css/print.css +101 -0
  62. data/vendor/buildr/doc/css/syntax.css +23 -0
  63. data/vendor/buildr/doc/download.textile +138 -0
  64. data/vendor/buildr/doc/extending.textile +212 -0
  65. data/vendor/buildr/doc/images/1442160941-frontcover.jpg +0 -0
  66. data/vendor/buildr/doc/images/asf-logo.gif +0 -0
  67. data/vendor/buildr/doc/images/asf-logo.png +0 -0
  68. data/vendor/buildr/doc/images/buildr-hires.png +0 -0
  69. data/vendor/buildr/doc/images/buildr.png +0 -0
  70. data/vendor/buildr/doc/images/favicon.png +0 -0
  71. data/vendor/buildr/doc/images/growl-icon.tiff +0 -0
  72. data/vendor/buildr/doc/images/note.png +0 -0
  73. data/vendor/buildr/doc/images/project-structure.png +0 -0
  74. data/vendor/buildr/doc/images/tip.png +0 -0
  75. data/vendor/buildr/doc/images/zbuildr.png +0 -0
  76. data/vendor/buildr/doc/images/zbuildr.tif +0 -0
  77. data/vendor/buildr/doc/index.textile +69 -0
  78. data/vendor/buildr/doc/installing.textile +284 -0
  79. data/vendor/buildr/doc/languages.textile +599 -0
  80. data/vendor/buildr/doc/mailing_lists.textile +29 -0
  81. data/vendor/buildr/doc/more_stuff.textile +845 -0
  82. data/vendor/buildr/doc/packaging.textile +618 -0
  83. data/vendor/buildr/doc/preface.textile +54 -0
  84. data/vendor/buildr/doc/projects.textile +276 -0
  85. data/vendor/buildr/doc/quick_start.textile +210 -0
  86. data/vendor/buildr/doc/releasing.textile +117 -0
  87. data/vendor/buildr/doc/scripts/buildr-git.rb +512 -0
  88. data/vendor/buildr/doc/scripts/gitflow.rb +296 -0
  89. data/vendor/buildr/doc/scripts/install-jruby.sh +44 -0
  90. data/vendor/buildr/doc/scripts/install-linux.sh +73 -0
  91. data/vendor/buildr/doc/scripts/install-osx.sh +52 -0
  92. data/vendor/buildr/doc/settings_profiles.textile +287 -0
  93. data/vendor/buildr/doc/testing.textile +247 -0
  94. data/vendor/buildr/etc/KEYS +189 -0
  95. data/vendor/buildr/lib/buildr.rb +44 -0
  96. data/vendor/buildr/lib/buildr/clojure.rb +34 -0
  97. data/vendor/buildr/lib/buildr/clojure/shell.rb +52 -0
  98. data/vendor/buildr/lib/buildr/core.rb +34 -0
  99. data/vendor/buildr/lib/buildr/core/application.rb +700 -0
  100. data/vendor/buildr/lib/buildr/core/build.rb +516 -0
  101. data/vendor/buildr/lib/buildr/core/cc.rb +166 -0
  102. data/vendor/buildr/lib/buildr/core/checks.rb +253 -0
  103. data/vendor/buildr/lib/buildr/core/common.rb +151 -0
  104. data/vendor/buildr/lib/buildr/core/compile.rb +622 -0
  105. data/vendor/buildr/lib/buildr/core/doc.rb +276 -0
  106. data/vendor/buildr/lib/buildr/core/environment.rb +129 -0
  107. data/vendor/buildr/lib/buildr/core/filter.rb +404 -0
  108. data/vendor/buildr/lib/buildr/core/generate.rb +197 -0
  109. data/vendor/buildr/lib/buildr/core/help.rb +119 -0
  110. data/vendor/buildr/lib/buildr/core/jrebel.rb +42 -0
  111. data/vendor/buildr/lib/buildr/core/linux.rb +30 -0
  112. data/vendor/buildr/lib/buildr/core/osx.rb +46 -0
  113. data/vendor/buildr/lib/buildr/core/progressbar.rb +161 -0
  114. data/vendor/buildr/lib/buildr/core/project.rb +975 -0
  115. data/vendor/buildr/lib/buildr/core/run.rb +43 -0
  116. data/vendor/buildr/lib/buildr/core/shell.rb +137 -0
  117. data/vendor/buildr/lib/buildr/core/test.rb +843 -0
  118. data/vendor/buildr/lib/buildr/core/transports.rb +565 -0
  119. data/vendor/buildr/lib/buildr/core/util.rb +537 -0
  120. data/vendor/buildr/lib/buildr/groovy.rb +20 -0
  121. data/vendor/buildr/lib/buildr/groovy/bdd.rb +106 -0
  122. data/vendor/buildr/lib/buildr/groovy/compiler.rb +153 -0
  123. data/vendor/buildr/lib/buildr/groovy/doc.rb +76 -0
  124. data/vendor/buildr/lib/buildr/groovy/shell.rb +57 -0
  125. data/vendor/buildr/lib/buildr/ide.rb +19 -0
  126. data/vendor/buildr/lib/buildr/ide/eclipse.rb +427 -0
  127. data/vendor/buildr/lib/buildr/ide/eclipse/java.rb +53 -0
  128. data/vendor/buildr/lib/buildr/ide/eclipse/plugin.rb +71 -0
  129. data/vendor/buildr/lib/buildr/ide/eclipse/scala.rb +68 -0
  130. data/vendor/buildr/lib/buildr/ide/idea.rb +576 -0
  131. data/vendor/buildr/lib/buildr/java.rb +25 -0
  132. data/vendor/buildr/lib/buildr/java/ant.rb +94 -0
  133. data/vendor/buildr/lib/buildr/java/bdd.rb +460 -0
  134. data/vendor/buildr/lib/buildr/java/cobertura.rb +297 -0
  135. data/vendor/buildr/lib/buildr/java/commands.rb +223 -0
  136. data/vendor/buildr/lib/buildr/java/compiler.rb +135 -0
  137. data/vendor/buildr/lib/buildr/java/deprecated.rb +141 -0
  138. data/vendor/buildr/lib/buildr/java/doc.rb +86 -0
  139. data/vendor/buildr/lib/buildr/java/ecj.rb +69 -0
  140. data/vendor/buildr/lib/buildr/java/emma.rb +244 -0
  141. data/vendor/buildr/lib/buildr/java/external.rb +73 -0
  142. data/vendor/buildr/lib/buildr/java/jruby.rb +122 -0
  143. data/vendor/buildr/lib/buildr/java/jtestr_result.rb +295 -0
  144. data/vendor/buildr/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  145. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  146. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  147. data/vendor/buildr/lib/buildr/java/packaging.rb +734 -0
  148. data/vendor/buildr/lib/buildr/java/pom.rb +178 -0
  149. data/vendor/buildr/lib/buildr/java/rjb.rb +154 -0
  150. data/vendor/buildr/lib/buildr/java/test_result.rb +101 -0
  151. data/vendor/buildr/lib/buildr/java/tests.rb +362 -0
  152. data/vendor/buildr/lib/buildr/java/version_requirement.rb +172 -0
  153. data/vendor/buildr/lib/buildr/packaging.rb +25 -0
  154. data/vendor/buildr/lib/buildr/packaging/archive.rb +535 -0
  155. data/vendor/buildr/lib/buildr/packaging/artifact.rb +903 -0
  156. data/vendor/buildr/lib/buildr/packaging/artifact_namespace.rb +984 -0
  157. data/vendor/buildr/lib/buildr/packaging/artifact_search.rb +140 -0
  158. data/vendor/buildr/lib/buildr/packaging/gems.rb +105 -0
  159. data/vendor/buildr/lib/buildr/packaging/package.rb +249 -0
  160. data/vendor/buildr/lib/buildr/packaging/tar.rb +189 -0
  161. data/vendor/buildr/lib/buildr/packaging/version_requirement.rb +192 -0
  162. data/vendor/buildr/lib/buildr/packaging/zip.rb +178 -0
  163. data/vendor/buildr/lib/buildr/packaging/ziptask.rb +356 -0
  164. data/vendor/buildr/lib/buildr/resources/buildr.icns +0 -0
  165. data/vendor/buildr/lib/buildr/resources/completed.png +0 -0
  166. data/vendor/buildr/lib/buildr/resources/failed.png +0 -0
  167. data/vendor/buildr/lib/buildr/resources/icons-license.txt +17 -0
  168. data/vendor/buildr/lib/buildr/run.rb +195 -0
  169. data/vendor/buildr/lib/buildr/scala.rb +26 -0
  170. data/vendor/buildr/lib/buildr/scala/bdd.rb +118 -0
  171. data/vendor/buildr/lib/buildr/scala/compiler.rb +242 -0
  172. data/vendor/buildr/lib/buildr/scala/doc.rb +142 -0
  173. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  174. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  175. data/vendor/buildr/lib/buildr/scala/shell.rb +52 -0
  176. data/vendor/buildr/lib/buildr/scala/tests.rb +171 -0
  177. data/vendor/buildr/lib/buildr/shell.rb +185 -0
  178. data/vendor/buildr/lib/buildr/version.rb +18 -0
  179. data/vendor/buildr/rakelib/all-in-one.rake +113 -0
  180. data/vendor/buildr/rakelib/checks.rake +57 -0
  181. data/vendor/buildr/rakelib/doc.rake +137 -0
  182. data/vendor/buildr/rakelib/metrics.rake +39 -0
  183. data/vendor/buildr/rakelib/package.rake +73 -0
  184. data/vendor/buildr/rakelib/release.rake +161 -0
  185. data/vendor/buildr/rakelib/rspec.rake +101 -0
  186. data/vendor/buildr/rakelib/setup.rake +66 -0
  187. data/vendor/buildr/rakelib/stage.rake +220 -0
  188. data/vendor/buildr/spec/addon/bnd_spec.rb +330 -0
  189. data/vendor/buildr/spec/addon/drb_spec.rb +328 -0
  190. data/vendor/buildr/spec/addon/jaxb_xjc_spec.rb +125 -0
  191. data/vendor/buildr/spec/core/application_spec.rb +631 -0
  192. data/vendor/buildr/spec/core/build_spec.rb +837 -0
  193. data/vendor/buildr/spec/core/cc_spec.rb +224 -0
  194. data/vendor/buildr/spec/core/checks_spec.rb +519 -0
  195. data/vendor/buildr/spec/core/common_spec.rb +725 -0
  196. data/vendor/buildr/spec/core/compile_spec.rb +658 -0
  197. data/vendor/buildr/spec/core/doc_spec.rb +195 -0
  198. data/vendor/buildr/spec/core/extension_spec.rb +201 -0
  199. data/vendor/buildr/spec/core/generate_spec.rb +33 -0
  200. data/vendor/buildr/spec/core/project_spec.rb +772 -0
  201. data/vendor/buildr/spec/core/run_spec.rb +93 -0
  202. data/vendor/buildr/spec/core/shell_spec.rb +146 -0
  203. data/vendor/buildr/spec/core/test_spec.rb +1320 -0
  204. data/vendor/buildr/spec/core/transport_spec.rb +544 -0
  205. data/vendor/buildr/spec/core/util_spec.rb +141 -0
  206. data/vendor/buildr/spec/groovy/bdd_spec.rb +80 -0
  207. data/vendor/buildr/spec/groovy/compiler_spec.rb +251 -0
  208. data/vendor/buildr/spec/groovy/doc_spec.rb +65 -0
  209. data/vendor/buildr/spec/ide/eclipse_spec.rb +739 -0
  210. data/vendor/buildr/spec/ide/idea_spec.rb +1144 -0
  211. data/vendor/buildr/spec/java/ant_spec.rb +37 -0
  212. data/vendor/buildr/spec/java/bdd_spec.rb +374 -0
  213. data/vendor/buildr/spec/java/cobertura_spec.rb +112 -0
  214. data/vendor/buildr/spec/java/commands_spec.rb +93 -0
  215. data/vendor/buildr/spec/java/compiler_spec.rb +252 -0
  216. data/vendor/buildr/spec/java/doc_spec.rb +56 -0
  217. data/vendor/buildr/spec/java/ecj_spec.rb +115 -0
  218. data/vendor/buildr/spec/java/emma_spec.rb +121 -0
  219. data/vendor/buildr/spec/java/external_spec.rb +56 -0
  220. data/vendor/buildr/spec/java/java_spec.rb +132 -0
  221. data/vendor/buildr/spec/java/packaging_spec.rb +1270 -0
  222. data/vendor/buildr/spec/java/run_spec.rb +78 -0
  223. data/vendor/buildr/spec/java/test_coverage_helper.rb +257 -0
  224. data/vendor/buildr/spec/java/tests_spec.rb +497 -0
  225. data/vendor/buildr/spec/packaging/archive_spec.rb +775 -0
  226. data/vendor/buildr/spec/packaging/artifact_namespace_spec.rb +743 -0
  227. data/vendor/buildr/spec/packaging/artifact_spec.rb +1066 -0
  228. data/vendor/buildr/spec/packaging/packaging_helper.rb +63 -0
  229. data/vendor/buildr/spec/packaging/packaging_spec.rb +719 -0
  230. data/vendor/buildr/spec/sandbox.rb +165 -0
  231. data/vendor/buildr/spec/scala/bdd_spec.rb +124 -0
  232. data/vendor/buildr/spec/scala/compiler_spec.rb +289 -0
  233. data/vendor/buildr/spec/scala/doc_spec.rb +88 -0
  234. data/vendor/buildr/spec/scala/scala.rb +38 -0
  235. data/vendor/buildr/spec/scala/tests_spec.rb +283 -0
  236. data/vendor/buildr/spec/spec_helpers.rb +369 -0
  237. data/vendor/buildr/spec/version_requirement_spec.rb +143 -0
  238. data/vendor/buildr/spec/xpath_matchers.rb +121 -0
  239. data/vendor/buildr/tests/BUILDR-320/Buildfile +29 -0
  240. data/vendor/buildr/tests/JavaSystemProperty/Buildfile +18 -0
  241. data/vendor/buildr/tests/JavaSystemProperty/src/test/java/FooTest.java +24 -0
  242. data/vendor/buildr/tests/compile_with_parent/Buildfile +18 -0
  243. data/vendor/buildr/tests/compile_with_parent/child/src/main/java/Foo.java +23 -0
  244. data/vendor/buildr/tests/helloWorld/Buildfile +20 -0
  245. data/vendor/buildr/tests/helloWorld/src/main/java/HelloWorld.java +23 -0
  246. data/vendor/buildr/tests/integration_testing.rb +56 -0
  247. data/vendor/buildr/tests/junit3/Buildfile +9 -0
  248. data/vendor/buildr/tests/junit3/src/main/java/Foo.java +23 -0
  249. data/vendor/buildr/tests/junit3/src/test/java/FooTest.java +28 -0
  250. data/vendor/buildr/tests/package_war_as_jar/Buildfile +15 -0
  251. data/vendor/buildr/tests/package_war_as_jar/src/main/java/Foo.java +19 -0
  252. metadata +524 -0
@@ -0,0 +1,743 @@
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 File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
17
+
18
+ describe Buildr::ArtifactNamespace do
19
+
20
+ before(:each) { Buildr::ArtifactNamespace.clear }
21
+
22
+ def abc_module
23
+ Object.module_eval 'module A; module B; module C; end; end; end'
24
+ yield
25
+ ensure
26
+ Object.send :remove_const, :A
27
+ end
28
+
29
+ describe '.root' do
30
+ it 'should return the top level namespace' do
31
+ Buildr::ArtifactNamespace.root.should be_root
32
+ end
33
+
34
+ it 'should yield the namespace if a block is given' do
35
+ flag = false
36
+ Buildr::ArtifactNamespace.root { |ns| flag = true; ns.should be_root }
37
+ flag.should == true
38
+ end
39
+
40
+ it 'should return the root when used outside of a project definition' do
41
+ artifact_ns.should be_root
42
+ end
43
+
44
+ it 'should yield to a block when used outside of a project definition' do
45
+ flag = false
46
+ artifact_ns {|ns| flag = true; ns.should be_root}
47
+ flag.should == true
48
+ end
49
+ end
50
+
51
+ describe '.instance' do
52
+ it 'should return the top level namespace when invoked outside a project definition' do
53
+ artifact_ns.should be_root
54
+ end
55
+
56
+ it 'should return the namespace for the receiving project' do
57
+ define('foo') { }
58
+ project('foo').artifact_ns.name.should == 'foo'
59
+ end
60
+
61
+ it 'should return the current project namespace when invoked inside a project' do
62
+ define 'foo' do
63
+ artifact_ns.should_not be_root
64
+ artifact_ns.name.should == 'foo'
65
+ task :doit do
66
+ artifact_ns.should_not be_root
67
+ artifact_ns.name.should == 'foo'
68
+ end.invoke
69
+ end
70
+ end
71
+
72
+ it 'should return the root namespace if given :root' do
73
+ artifact_ns(:root).should be_root
74
+ end
75
+
76
+ it 'should return the namespace for the given name' do
77
+ artifact_ns(:foo).name.should == 'foo'
78
+ artifact_ns('foo:bar').name.should == 'foo:bar'
79
+ artifact_ns(['foo', 'bar', 'baz']).name.should == 'foo:bar:baz'
80
+ abc_module do
81
+ artifact_ns(A::B::C).name.should == 'A::B::C'
82
+ end
83
+ artifact_ns(:root).should be_root
84
+ artifact_ns(:current).should be_root
85
+ define 'foo' do
86
+ artifact_ns(:current).name.should == 'foo'
87
+ define 'baz' do
88
+ artifact_ns(:current).name.should == 'foo:baz'
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ describe '#parent' do
95
+ it 'should be nil for root namespace' do
96
+ artifact_ns(:root).parent.should be_nil
97
+ end
98
+
99
+ it 'should be the parent namespace for nested modules' do
100
+ abc_module do
101
+ artifact_ns(A::B::C).parent.should == artifact_ns(A::B)
102
+ artifact_ns(A::B).parent.should == artifact_ns(A)
103
+ artifact_ns(A).parent.should == artifact_ns(:root)
104
+ end
105
+ end
106
+
107
+ it 'should be the parent namespace for nested projects' do
108
+ define 'a' do
109
+ define 'b' do
110
+ define 'c' do
111
+ artifact_ns.parent.should == artifact_ns(parent)
112
+ end
113
+ artifact_ns.parent.should == artifact_ns(parent)
114
+ end
115
+ artifact_ns.parent.should == artifact_ns(:root)
116
+ end
117
+ end
118
+ end
119
+
120
+ describe '#parent=' do
121
+ it 'should reject to set parent for root namespace' do
122
+ lambda { artifact_ns(:root).parent = :foo }.should raise_error(Exception, /cannot set parent/i)
123
+ end
124
+
125
+ it 'should allow to set parent' do
126
+ artifact_ns(:bar).parent = :foo
127
+ artifact_ns(:bar).parent.should == artifact_ns(:foo)
128
+ artifact_ns(:bar).parent = artifact_ns(:baz)
129
+ artifact_ns(:bar).parent.should == artifact_ns(:baz)
130
+ end
131
+
132
+ it 'should allow to set parent to :current' do
133
+ abc_module do
134
+ mod = A::B
135
+ artifact_ns(mod).parent = :current
136
+ def mod.stuff
137
+ Buildr::artifact_ns(self)
138
+ end
139
+ define 'a' do
140
+ define 'b' do
141
+ mod.stuff.parent.should == artifact_ns
142
+ end
143
+ mod.stuff.parent.should == artifact_ns
144
+ end
145
+ end
146
+ end
147
+ end
148
+
149
+ describe '#need' do
150
+ it 'should accept an artifact spec' do
151
+ define 'one' do
152
+ artifact_ns.need 'a:b:c:1'
153
+ # referenced by spec
154
+ artifact_ns['a:b:c'].should_not be_selected
155
+
156
+ # referenced by name
157
+ artifact_ns[:b].should_not be_selected
158
+ artifact_ns[:b].should be_satisfied_by('a:b:c:1')
159
+ artifact_ns[:b].should_not be_satisfied_by('a:b:c:2')
160
+ artifact_ns[:b].should_not be_satisfied_by('d:b:c:1')
161
+ artifact_ns[:b].version.should == '1'
162
+ end
163
+ end
164
+
165
+ it 'should accept a requirement_spec' do
166
+ define 'one' do
167
+ artifact_ns.need 'thing -> a:b:c:2.1 -> ~>2.0'
168
+ # referenced by spec
169
+ artifact_ns['a:b:c'].should_not be_selected
170
+
171
+ # referenced by name
172
+ artifact_ns.key?(:b).should be_false
173
+ artifact_ns[:thing].should_not be_selected
174
+ artifact_ns[:thing].should be_satisfied_by('a:b:c:2.5')
175
+ artifact_ns[:thing].should_not be_satisfied_by('a:b:c:3')
176
+ artifact_ns[:thing].version.should == '2.1'
177
+ end
178
+ end
179
+
180
+ it 'should accept a hash :name -> requirement_spec' do
181
+ define 'one' do
182
+ artifact_ns.need :thing => 'a:b:c:2.1 -> ~>2.0'
183
+ artifact_ns[:thing].should be_satisfied_by('a:b:c:2.5')
184
+ artifact_ns[:thing].should_not be_satisfied_by('a:b:c:3')
185
+ artifact_ns[:thing].version.should == '2.1'
186
+ end
187
+
188
+ define 'two' do
189
+ artifact_ns.need :thing => 'a:b:c:(~>2.0 | 2.1)'
190
+ artifact_ns[:thing].should be_satisfied_by('a:b:c:2.5')
191
+ artifact_ns[:thing].should_not be_satisfied_by('a:b:c:3')
192
+ artifact_ns[:thing].version.should == '2.1'
193
+ end
194
+ end
195
+
196
+ it 'should take a hash :name -> specs_array' do
197
+ define 'one' do
198
+ artifact_ns.need :things => ['foo:bar:jar:1.0',
199
+ 'foo:baz:jar:2.0',]
200
+ artifact_ns['foo:bar:jar'].should_not be_selected
201
+ artifact_ns['foo:baz:jar'].should_not be_selected
202
+ artifact_ns[:bar, :baz].should == [nil, nil]
203
+ artifact_ns[:things].map(&:unversioned_spec).should include('foo:bar:jar', 'foo:baz:jar')
204
+ artifact_ns.alias :baz, 'foo:baz:jar'
205
+ artifact_ns[:baz].should == artifact_ns['foo:baz:jar']
206
+ end
207
+ end
208
+
209
+ it 'should select best matching version if defined' do
210
+ define 'one' do
211
+ artifact_ns.use :a => 'foo:bar:jar:1.5'
212
+ artifact_ns.use :b => 'foo:baz:jar:2.0'
213
+ define 'two' do
214
+ artifact_ns[:a].requirement.should be_nil
215
+ artifact_ns[:a].should be_selected
216
+
217
+ artifact_ns.need :c => 'foo:bat:jar:3.0'
218
+ artifact_ns['foo:bat:jar'].should_not be_selected
219
+ artifact_ns[:c].should_not be_selected
220
+
221
+ artifact_ns.need :one => 'foo:bar:jar:>=1.0'
222
+ artifact_ns[:one].version.should == '1.5'
223
+ artifact_ns[:one].should be_selected
224
+ artifact_ns[:a].requirement.should be_nil
225
+
226
+ artifact_ns.need :two => 'foo:baz:jar:>2'
227
+ artifact_ns[:two].version.should be_nil
228
+ artifact_ns[:two].should_not be_selected
229
+ artifact_ns[:b].requirement.should be_nil
230
+ end
231
+ end
232
+ end
233
+ end
234
+
235
+ describe '#use' do
236
+ it 'should register the artifact on namespace' do
237
+ define 'one' do
238
+ artifact_ns.use :thing => 'a:b:c:1'
239
+ artifact_ns[:thing].requirement.should be_nil
240
+ artifact_ns[:thing].version.should == '1'
241
+ artifact_ns[:thing].id.should == 'b'
242
+ define 'one' do
243
+ artifact_ns.use :thing => 'a:d:c:2'
244
+ artifact_ns[:thing].requirement.should be_nil
245
+ artifact_ns[:thing].version.should == '2'
246
+ artifact_ns[:thing].id.should == 'd'
247
+
248
+ artifact_ns.use :copied => artifact_ns.parent[:thing]
249
+ artifact_ns[:copied].should_not == artifact_ns.parent[:thing]
250
+ artifact_ns[:copied].requirement.should be_nil
251
+ artifact_ns[:copied].version.should == '1'
252
+ artifact_ns[:copied].id.should == 'b'
253
+
254
+ artifact_ns.use :aliased => :copied
255
+ artifact_ns[:aliased].should == artifact_ns[:copied]
256
+
257
+ lambda { artifact_ns.use :invalid => :unknown }.should raise_error(NameError, /undefined/i)
258
+ end
259
+ artifact_ns[:copied].should be_nil
260
+ end
261
+ end
262
+
263
+ it 'should register two artifacts with different version on namespace' do
264
+ define 'one' do
265
+ artifact_ns.use :foo => 'a:b:c:1'
266
+ artifact_ns.use :bar => 'a:b:c:2'
267
+ artifact_ns[:foo].version.should == '1'
268
+ artifact_ns[:bar].version.should == '2'
269
+ # unversioned references the last version set.
270
+ artifact_ns['a:b:c'].version.should == '2'
271
+ end
272
+ end
273
+
274
+ it 'should complain if namespace requirement is not satisfied' do
275
+ define 'one' do
276
+ artifact_ns.need :bar => 'foo:bar:baz:~>1.5'
277
+ lambda { artifact_ns.use :bar => '1.4' }.should raise_error(Exception, /unsatisfied/i)
278
+ end
279
+ end
280
+
281
+ it 'should be able to register a group' do
282
+ specs = ['its:me:here:1', 'its:you:there:2']
283
+ artifact_ns.use :them => specs
284
+ artifact_ns[:them].map(&:to_spec).should == specs
285
+ artifact_ns['its:me:here'].should_not be_nil
286
+ artifact_ns[:you].should be_nil
287
+ end
288
+
289
+ it 'should be able to assign sub namespaces' do
290
+ artifact_ns(:foo).bar = "foo:bar:baz:0"
291
+ artifact_ns(:moo).foo = artifact_ns(:foo)
292
+ artifact_ns(:moo).foo.should == artifact_ns(:foo)
293
+ artifact_ns(:moo).foo_bar.should == artifact_ns(:foo).bar
294
+ end
295
+
296
+ it 'should handle symbols with dashes and periods' do
297
+ [:'a-b', :'a.b'].each do |symbol|
298
+ artifact_ns.use symbol => 'a:b:c:1'
299
+ artifact_ns[symbol].version.should == '1'
300
+ artifact_ns[symbol].id.should == 'b'
301
+ end
302
+ end
303
+
304
+ it 'should handle version string' do
305
+ foo = artifact_ns do |ns|
306
+ ns.bar = 'a:b:c:1'
307
+ end
308
+ foo.use :bar => '2.0'
309
+ foo.bar.version.should == '2.0'
310
+ end
311
+ end
312
+
313
+ describe '#values' do
314
+ it 'returns the artifacts defined on namespace' do
315
+ define 'foo' do
316
+ artifact_ns.use 'foo:one:baz:1.0'
317
+ define 'bar' do
318
+ artifact_ns.use 'foo:two:baz:1.0'
319
+
320
+ specs = artifact_ns.values.map(&:to_spec)
321
+ specs.should include('foo:two:baz:1.0')
322
+ specs.should_not include('foo:one:baz:1.0')
323
+
324
+ specs = artifact_ns.values(true).map(&:to_spec)
325
+ specs.should include('foo:two:baz:1.0', 'foo:one:baz:1.0')
326
+ end
327
+ end
328
+ end
329
+ end
330
+
331
+ describe '#values_at' do
332
+ it 'returns the named artifacts' do
333
+ define 'foo' do
334
+ artifact_ns.use 'foo:one:baz:1.0'
335
+ define 'bar' do
336
+ artifact_ns.use :foo_baz => 'foo:two:baz:1.0'
337
+
338
+ specs = artifact_ns.values_at('one').map(&:to_spec)
339
+ specs.should include('foo:one:baz:1.0')
340
+ specs.should_not include('foo:two:baz:1.0')
341
+
342
+ specs = artifact_ns.values_at('foo_baz').map(&:to_spec)
343
+ specs.should include('foo:two:baz:1.0')
344
+ specs.should_not include('foo:one:baz:1.0')
345
+ end
346
+ end
347
+ end
348
+
349
+ it 'returns first artifacts by their unversioned spec' do
350
+ define 'foo' do
351
+ artifact_ns.use 'foo:one:baz:2.0'
352
+ define 'bar' do
353
+ artifact_ns.use :older => 'foo:one:baz:1.0'
354
+
355
+ specs = artifact_ns.values_at('foo:one:baz').map(&:to_spec)
356
+ specs.should include('foo:one:baz:1.0')
357
+ specs.should_not include('foo:one:baz:2.0')
358
+ end
359
+ specs = artifact_ns.values_at('foo:one:baz').map(&:to_spec)
360
+ specs.should include('foo:one:baz:2.0')
361
+ specs.should_not include('foo:one:baz:1.0')
362
+ end
363
+ end
364
+
365
+ it 'return first artifact satisfying a dependency' do
366
+ define 'foo' do
367
+ artifact_ns.use 'foo:one:baz:2.0'
368
+ define 'bar' do
369
+ artifact_ns.use :older => 'foo:one:baz:1.0'
370
+
371
+ specs = artifact_ns.values_at('foo:one:baz:>1.0').map(&:to_spec)
372
+ specs.should include('foo:one:baz:2.0')
373
+ specs.should_not include('foo:one:baz:1.0')
374
+ end
375
+ end
376
+ end
377
+ end
378
+
379
+ describe '#artifacts' do
380
+ it 'returns artifacts in namespace' do
381
+ define 'one' do
382
+ artifact_ns[:foo] = 'group:foo:jar:1'
383
+ artifact_ns[:bar] = 'group:bar:jar:1'
384
+ artifact_ns.artifacts.map{|a| a.to_spec}.should include('group:foo:jar:1', 'group:bar:jar:1')
385
+ end
386
+ end
387
+ end
388
+
389
+ describe '#keys' do
390
+ it 'returns names in namespace' do
391
+ define 'one' do
392
+ artifact_ns[:foo] = 'group:foo:jar:1'
393
+ artifact_ns[:bar] = 'group:bar:jar:1'
394
+ artifact_ns.keys.should include('foo', 'bar')
395
+ end
396
+ end
397
+ end
398
+
399
+ describe '#delete' do
400
+ it 'deletes corresponding artifact requirement' do
401
+ define 'one' do
402
+ artifact_ns[:foo] = 'group:foo:jar:1'
403
+ artifact_ns[:bar] = 'group:bar:jar:1'
404
+ artifact_ns.delete :bar
405
+ artifact_ns.artifacts.map{|a| a.to_spec}.should include('group:foo:jar:1')
406
+ artifact_ns[:foo].to_spec.should eql('group:foo:jar:1')
407
+ end
408
+ end
409
+ end
410
+
411
+ describe '#clear' do
412
+ it 'clears all artifact requirements in namespace' do
413
+ define 'one' do
414
+ artifact_ns[:foo] = 'group:foo:jar:1'
415
+ artifact_ns[:bar] = 'group:bar:jar:1'
416
+ artifact_ns.clear
417
+ artifact_ns.artifacts.should be_empty
418
+ end
419
+ end
420
+ end
421
+
422
+ describe '#method_missing' do
423
+ it 'should use cool_aid! to create a requirement' do
424
+ define 'foo' do
425
+ artifact_ns.cool_aid!('cool:aid:jar:2').should be_kind_of(ArtifactNamespace::ArtifactRequirement)
426
+ artifact_ns[:cool_aid].version.should == '2'
427
+ artifact_ns[:cool_aid].should_not be_selected
428
+ define 'bar' do
429
+ artifact_ns.cool_aid! 'cool:aid:man:3', '>2'
430
+ artifact_ns[:cool_aid].version.should == '3'
431
+ artifact_ns[:cool_aid].requirement.should be_satisfied_by('2.5')
432
+ artifact_ns[:cool_aid].should_not be_selected
433
+ end
434
+ end
435
+ end
436
+
437
+ it 'should use cool_aid= as shorhand for [:cool_aid]=' do
438
+ artifact_ns.cool_aid = 'cool:aid:jar:1'
439
+ artifact_ns[:cool_aid].should be_selected
440
+ end
441
+
442
+ it 'should use cool_aid as shorthand for [:cool_aid]' do
443
+ artifact_ns.need :cool_aid => 'cool:aid:jar:1'
444
+ artifact_ns.cool_aid.should_not be_selected
445
+ end
446
+
447
+ it 'should use cool_aid? to test if artifact has been defined and selected' do
448
+ artifact_ns.need :cool_aid => 'cool:aid:jar:>1'
449
+ artifact_ns.should_not have_cool_aid
450
+ artifact_ns.should_not have_unknown
451
+ artifact_ns.cool_aid = '2'
452
+ artifact_ns.should have_cool_aid
453
+ end
454
+ end
455
+
456
+ describe '#ns' do
457
+ it 'should create a sub namespace' do
458
+ artifact_ns.ns :foo
459
+ artifact_ns[:foo].should be_kind_of(ArtifactNamespace)
460
+ artifact_ns(:foo).should_not === artifact_ns.foo
461
+ artifact_ns.foo.parent.should == artifact_ns
462
+ end
463
+
464
+ it 'should take any use arguments' do
465
+ artifact_ns.ns :foo, :bar => 'foo:bar:jar:0', :baz => 'foo:baz:jar:0'
466
+ artifact_ns.foo.bar.should be_selected
467
+ artifact_ns.foo[:baz].should be_selected
468
+ end
469
+
470
+ it 'should access sub artifacts using with foo_bar like syntax' do
471
+ artifact_ns.ns :foo, :bar => 'foo:bar:jar:0', :baz => 'foo:baz:jar:0'
472
+ artifact_ns[:foo_baz].should be_selected
473
+ artifact_ns.foo_bar.should be_selected
474
+
475
+ artifact_ns.foo.ns :bat, 'bat:man:jar:>1'
476
+ batman = artifact_ns.foo.bat.man
477
+ batman.should be_selected
478
+ artifact_ns[:foo_bat_man] = '3'
479
+ artifact_ns[:foo_bat_man].should == batman
480
+ artifact_ns[:foo_bat_man].version.should == '3'
481
+ end
482
+
483
+ it 'should include sub artifacts when calling #values' do
484
+ artifact_ns.ns :bat, 'bat:man:jar:>1'
485
+ artifact_ns.values.should_not be_empty
486
+ artifact_ns.values.first.unversioned_spec.should == 'bat:man:jar'
487
+ end
488
+
489
+ it 'should reopen a sub-namespace' do
490
+ artifact_ns.ns :bat, 'bat:man:jar:>1'
491
+ bat = artifact_ns[:bat]
492
+ bat.should == artifact_ns.ns(:bat)
493
+ end
494
+
495
+ it 'should fail reopening if not a sub-namespace' do
496
+ artifact_ns.foo = 'foo:bar:baz:0'
497
+ lambda { artifact_ns.ns(:foo) }.should raise_error(TypeError, /not a sub/i)
498
+ end
499
+
500
+ it 'should clone artifacts when assigned' do
501
+ artifact_ns(:foo).bar = "foo:bar:jar:0"
502
+ artifact_ns(:moo).ns :muu, :miu => artifact_ns(:foo).bar
503
+ artifact_ns(:moo).muu.miu.should_not == artifact_ns(:foo).bar
504
+ artifact_ns(:moo).muu.miu.to_spec.should == artifact_ns(:foo).bar.to_spec
505
+ end
506
+
507
+ it 'should clone parent artifacts by name' do
508
+ define 'foo' do
509
+ artifact_ns.bar = "foo:bar:jar:0"
510
+ define 'moo' do
511
+ artifact_ns.ns(:muu).use :bar
512
+ artifact_ns.muu_bar.should be_selected
513
+ artifact_ns.muu.bar.should_not == artifact_ns.bar
514
+ end
515
+ end
516
+ end
517
+ end
518
+
519
+ it 'should be an Enumerable' do
520
+ artifact_ns.should be_kind_of(Enumerable)
521
+ artifact_ns.use 'foo:bar:baz:1.0'
522
+ artifact_ns.map(&:artifact).should include(artifact('foo:bar:baz:1.0'))
523
+ end
524
+
525
+ end # ArtifactNamespace
526
+
527
+ describe Buildr::ArtifactNamespace::ArtifactRequirement do
528
+ before(:each) { Buildr::ArtifactNamespace.clear }
529
+ it 'should be created from artifact_ns' do
530
+ foo = artifact_ns do |ns|
531
+ ns.bar = 'a:b:c:1.0'
532
+ end
533
+ foo.bar.should be_kind_of(ArtifactNamespace::ArtifactRequirement)
534
+ end
535
+
536
+ it 'should handle version as string' do
537
+ foo = artifact_ns do |ns|
538
+ ns.bar = 'a:b:c:1.0'
539
+ end
540
+ foo.bar.version = '2.0'
541
+ foo.bar.version.should == '2.0'
542
+ end
543
+
544
+ it 'should handle version string directly' do
545
+ foo = artifact_ns do |ns|
546
+ ns.bar = 'a:b:c:1.0'
547
+ end
548
+ foo.bar = '2.0'
549
+ foo.bar.version.should == '2.0'
550
+ end
551
+
552
+ end # ArtifactRequirement
553
+
554
+ describe Buildr do
555
+ before(:each) { Buildr::ArtifactNamespace.clear }
556
+
557
+ describe '.artifacts' do
558
+ it 'should take ruby symbols and ask the current namespace for them' do
559
+ define 'foo' do
560
+ artifact_ns.cool = 'cool:aid:jar:1.0'
561
+ artifact_ns.use 'some:other:jar:1.0'
562
+ artifact_ns.use 'bat:man:jar:1.0'
563
+ compile.with :cool, :other, :'bat:man:jar'
564
+ compile.dependencies.map(&:to_spec).should include('cool:aid:jar:1.0', 'some:other:jar:1.0', 'bat:man:jar:1.0')
565
+ end
566
+ end
567
+
568
+ it 'should take a namespace' do
569
+ artifact_ns(:moo).muu = 'moo:muu:jar:1.0'
570
+ define 'foo' do
571
+ compile.with artifact_ns(:moo)
572
+ compile.dependencies.map(&:to_spec).should include('moo:muu:jar:1.0')
573
+ end
574
+ end
575
+ end
576
+
577
+ describe '.artifact' do
578
+ it 'should search current namespace if given a symbol' do
579
+ define 'foo' do
580
+ artifact_ns.use :cool => 'cool:aid:jar:1.0'
581
+ define 'bar' do
582
+ artifact(:cool).should == artifact_ns[:cool].artifact
583
+ end
584
+ end
585
+ end
586
+
587
+ it 'should search current namespace if given a symbol spec' do
588
+ define 'foo' do
589
+ artifact_ns.use 'cool:aid:jar:1.0'
590
+ define 'bar' do
591
+ artifact(:'cool:aid:jar').should == artifact_ns[:aid].artifact
592
+ end
593
+ end
594
+ end
595
+
596
+ it 'should fail when no artifact by that name is found' do
597
+ define 'foo' do
598
+ artifact_ns.use 'cool:aid:jar:1.0'
599
+ define 'bar' do
600
+ lambda { artifact(:cool) }.should raise_error(IndexError, /artifact/)
601
+ end
602
+ end
603
+ end
604
+ end
605
+ end
606
+
607
+ describe "Extension using ArtifactNamespace" do
608
+ before(:each) { Buildr::ArtifactNamespace.clear }
609
+
610
+ def abc_module
611
+ Object.module_eval 'module A; module B; module C; end; end; end'
612
+ yield
613
+ ensure
614
+ Object.send :remove_const, :A
615
+ end
616
+
617
+ it 'can register namespace listeners' do
618
+ abc_module do
619
+ # An example extension to illustrate namespace listeners and method forwarding
620
+ class A::Example
621
+
622
+ module Ext
623
+ include Buildr::Extension
624
+ def example; @example ||= A::Example.new; end
625
+ before_define do |p|
626
+ Rake::Task.define_task('example') { p.example.doit }
627
+ end
628
+ end
629
+
630
+ REQUIRES = ArtifactNamespace.for(self) do |ns|
631
+ ns.xmlbeans! 'org.apache.xmlbeans:xmlbeans:jar:2.3.0', '>2'
632
+ ns.stax_api! 'stax:stax-api:jar:>=1.0.1'
633
+ end
634
+
635
+ attr_reader :options, :requires
636
+
637
+ def initialize
638
+ # We could actually use the REQUIRES namespace, but to make things
639
+ # a bit more interesting, suppose each Example instance can have its
640
+ # own artifact requirements in adition to those specified on REQUIRES.
641
+ # To achieve this we create an anonymous namespace.
642
+ @requires = ArtifactNamespace.new # a namespace per instance
643
+ REQUIRES.each { |requirement| @requires.need requirement }
644
+
645
+ # For user convenience, we make the options object respond to
646
+ # :xmlbeans, :xmlbeans=, :xmlbeans?
647
+ # forwarding them to the namespace.
648
+ @options = OpenObject.new.extend(@requires.accessor(:xmlbeans, :stax_api))
649
+ # Register callbacks so we can perform some logic when an artifact
650
+ # is selected by the user.
651
+ options.xmlbeans.add_listener &method(:selected_xmlbeans)
652
+ options.stax_api.add_listener do |stax|
653
+ # Now using a proc
654
+ stax.should be_selected
655
+ stax.version.should == '1.6180'
656
+ options[:math] = :golden # customize our options for this version
657
+ # In this example we set the stax version when running outside
658
+ # a project definition. This means we have no access to the project
659
+ # namespace unless we had a reference to the project or knew it's name
660
+ Buildr.artifact_ns(:current).name.should == 'root'
661
+ end
662
+ end
663
+
664
+ include RSpec::Matchers # for assertions
665
+
666
+ # Called with the ArtifactRequirement that has just been selected
667
+ # by a user. This allows extension author to selectively perform
668
+ # some action by inspecting the requirement state.
669
+ def selected_xmlbeans(xmlbeans)
670
+ xmlbeans.should be_selected
671
+ xmlbeans.version.should == '3.1415'
672
+ options[:math] = :pi
673
+ # This example just sets xmlbeans for foo:bar project
674
+ # So the currently running namespace should have the foo:bar name
675
+ Buildr.artifact_ns(:current).name.should == 'foo:bar'
676
+ end
677
+
678
+ # Suppose we invoke an ant task here or something else.
679
+ def doit
680
+ # Now call ant task with our selected artifact and options
681
+ classpath = requires.map(&:artifact).map(&:to_s).join(File::PATH_SEPARATOR)
682
+ lambda { ant('thing') { |ant| ant.classpath classpath, :math => options[:math] } }
683
+
684
+ # We are not a Project instance, hence we have no artifact_ns
685
+ lambda { artifact_ns }.should raise_error(NameError)
686
+
687
+ # Extension authors may NOT rely project's namespaces.
688
+ # However the ruby-way gives you power and at the same time
689
+ # makes you dangerous, (think open-modules, monkey-patching)
690
+ # Given that buildr is pure ruby, consider it a sharp-edged sword.
691
+ # Having said that, you may actually inspect a project's
692
+ # namespace, but don't write on it without letting your users
693
+ # know you will.
694
+ # This example obtains the current project namespace to make
695
+ # some assertions.
696
+
697
+ # To obtain a project's namespace we need either
698
+ # 1) a reference to the project, and call artifact_ns on it
699
+ # project.artifact_ns # the namespace for project
700
+ # 2) know the project name
701
+ # Buildr.artifact_ns('the:project')
702
+ # 3) Use :current to reference the currently running project
703
+ # Buildr.artifact_ns(:current)
704
+ name = Buildr.artifact_ns(:current).name
705
+ case name
706
+ when 'foo:bar'
707
+ options[:math].should == :pi
708
+ requires.xmlbeans.version.should == '3.1415'
709
+ requires.stax_api.version.should == '1.0.1'
710
+ when 'foo:baz'
711
+ options[:math].should == :golden
712
+ requires.xmlbeans.version.should == '2.3.0'
713
+ requires.stax_api.version.should == '1.6180'
714
+ else
715
+ fail "This example expects foo:bar or foo:baz projects not #{name.inspect}"
716
+ end
717
+ end
718
+ end
719
+
720
+ define 'foo' do
721
+ define 'bar' do
722
+ extend A::Example::Ext
723
+ task('setup') do
724
+ example.options.xmlbeans = '3.1415'
725
+ end
726
+ task('run' => [:setup, :example])
727
+ end
728
+ define 'baz' do
729
+ extend A::Example::Ext
730
+ end
731
+ end
732
+
733
+ project('foo:bar').example.requires.should_not == project('foo:baz').example.requires
734
+ project('foo:bar').example.requires.xmlbeans.should_not == project('foo:baz').example.requires.xmlbeans
735
+
736
+ # current namespace outside a project is :root, see the stax callback
737
+ project('foo:baz').example.options.stax_api = '1.6180'
738
+ # we call the task outside the project, see #doit
739
+ lambda { task('foo:bar:run').invoke }.should run_task('foo:bar:example')
740
+ lambda { task('foo:baz:example').invoke }.should run_task('foo:baz:example')
741
+ end
742
+ end
743
+ end