buildr 1.3.5-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +998 -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 +244 -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 +79 -0
  40. data/doc/extending.textile +186 -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 +266 -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 +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -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 +280 -0
  68. data/doc/testing.textile +222 -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 +656 -0
  73. data/lib/buildr/core/build.rb +452 -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 +362 -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 +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -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 +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
@@ -0,0 +1,93 @@
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 File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+
20
+ describe Extension do
21
+
22
+ it 'should call Extension.first_time during include' do
23
+ TestExtension.should_receive(:first_time_called).once
24
+ class Buildr::Project
25
+ include TestExtension
26
+ end
27
+ end
28
+
29
+ it 'should call before_define and after_define in order when project is defined' do
30
+ begin
31
+ TestExtension.initialized do |extension|
32
+ extension.should_receive(:before_define_called).once.ordered
33
+ extension.should_receive(:after_define_called).once.ordered
34
+ end
35
+ class Buildr::Project
36
+ include TestExtension
37
+ end
38
+ define('foo')
39
+ ensure
40
+ TestExtension.initialized { |ignore| }
41
+ end
42
+ end
43
+
44
+ it 'should call before_define and after_define for each project defined' do
45
+ begin
46
+ extensions = 0
47
+ TestExtension.initialized do |extension|
48
+ extensions += 1
49
+ extension.should_receive(:before_define_called).once.ordered
50
+ extension.should_receive(:after_define_called).once.ordered
51
+ end
52
+ class Buildr::Project
53
+ include TestExtension
54
+ end
55
+ define('foo')
56
+ define('bar')
57
+ extensions.should equal(2)
58
+ ensure
59
+ TestExtension.initialized { |ignore| }
60
+ end
61
+ end
62
+ end
63
+
64
+ module TestExtension
65
+ include Extension
66
+
67
+ def initialize(*args)
68
+ # callback is used to obtain extension instance created by buildr
69
+ @@initialized.call(self) if @@initialized
70
+ super
71
+ end
72
+
73
+ def TestExtension.initialized(&block)
74
+ @@initialized = block
75
+ end
76
+
77
+ first_time do
78
+ TestExtension.first_time_called()
79
+ end
80
+
81
+ before_define do |project|
82
+ project.before_define_called()
83
+ end
84
+
85
+ after_define do |project|
86
+ project.after_define_called()
87
+ end
88
+
89
+ def TestExtension.first_time_called()
90
+ end
91
+
92
+ end
93
+
@@ -0,0 +1,33 @@
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 File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+
20
+ describe Buildr::Generate do
21
+
22
+ describe 'Generated buildfile' do
23
+ it 'should be a legal buildfile' do
24
+ File.open('buildfile', 'w') { |file| file.write Generate.from_directory(Dir.pwd).join("\n") }
25
+ lambda { Buildr.application.run }.should_not raise_error
26
+ end
27
+
28
+ it 'should not contain NEXT_VERSION because it was removed in buildr 1.3.3' do
29
+ buildfile = Generate.from_directory(Dir.pwd)
30
+ buildfile.each { |line| line.should_not include('NEXT_VERSION')}
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,762 @@
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 File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+
20
+ describe Project do
21
+ it 'should be findable' do
22
+ foo = define('foo')
23
+ project('foo').should be(foo)
24
+ end
25
+
26
+ it 'should not exist unless defined' do
27
+ lambda { project('foo') }.should raise_error(RuntimeError, /No such project/)
28
+ end
29
+
30
+ it 'should fail to be defined if its name is already used for a task' do
31
+ lambda { define('test') }.should raise_error(RuntimeError, /Invalid project name/i)
32
+ define 'valid' do
33
+ lambda { define('build') }.should raise_error(RuntimeError, /Invalid project name/i)
34
+ end
35
+ end
36
+
37
+ it 'should exist once defined' do
38
+ define 'foo'
39
+ lambda { project('foo') }.should_not raise_error
40
+ end
41
+
42
+ it 'should always return same project for same name' do
43
+ foo, bar = define('foo'), define('bar')
44
+ foo.should_not be(bar)
45
+ foo.should be(project('foo'))
46
+ bar.should be(project('bar'))
47
+ end
48
+
49
+ it 'should show up in projects list if defined' do
50
+ define('foo')
51
+ projects.map(&:name).should include('foo')
52
+ end
53
+
54
+ it 'should not show up in projects list unless defined' do
55
+ projects.map(&:name).should_not include('foo')
56
+ end
57
+
58
+ it 'should be findable from within a project' do
59
+ define('foo')
60
+ project('foo').project('foo').should be(project('foo'))
61
+ end
62
+
63
+ it 'should cease to exist when project list cleared' do
64
+ define 'foo'
65
+ projects.map(&:name).should include('foo')
66
+ Project.clear
67
+ projects.map(&:name).should be_empty
68
+ end
69
+
70
+ it 'should be defined only once' do
71
+ lambda { define 'foo' }.should_not raise_error
72
+ lambda { define 'foo' }.should raise_error
73
+ end
74
+
75
+ it 'should be definable in any order' do
76
+ Buildr.define('baz') { define('bar') { project('foo:bar') } }
77
+ Buildr.define('foo') { define('bar') }
78
+ lambda { project('foo') }.should_not raise_error
79
+ end
80
+
81
+ it 'should detect circular dependency' do
82
+ Buildr.define('baz') { define('bar') { project('foo:bar') } }
83
+ Buildr.define('foo') { define('bar') { project('baz:bar') } }
84
+ lambda { project('foo') }.should raise_error(RuntimeError, /Circular dependency/)
85
+ end
86
+ end
87
+
88
+ describe Project, ' property' do
89
+ it 'should be set if passed as argument' do
90
+ define 'foo', 'version'=>'1.1'
91
+ project('foo').version.should eql('1.1')
92
+ end
93
+
94
+ it 'should be set if assigned in body' do
95
+ define('foo') { self.version = '1.2' }
96
+ project('foo').version.should eql('1.2')
97
+ end
98
+
99
+ it 'should take precedence when assigned in body' do
100
+ define('foo', 'version'=>'1.1') { self.version = '1.2' }
101
+ project('foo').version.should eql('1.2')
102
+ end
103
+
104
+ it 'should inherit from parent (for some properties)' do
105
+ define('foo', 'version'=>'1.2', :group=>'foobar') { define 'bar' }
106
+ project('foo:bar').version.should eql('1.2')
107
+ project('foo:bar').group.should eql('foobar')
108
+ end
109
+
110
+ it 'should have different value if set in sub-project' do
111
+ define 'foo', 'version'=>'1.2', :group=>'foobar' do
112
+ define 'bar', :version=>'1.3' do
113
+ self.group = 'barbaz'
114
+ end
115
+ end
116
+ project('foo:bar').version.should eql('1.3')
117
+ project('foo:bar').group.should eql('barbaz')
118
+ end
119
+ end
120
+
121
+
122
+ describe Project, ' block' do
123
+ it 'should execute once' do
124
+ define('foo') { self.name.should eql('foo') }
125
+ end
126
+
127
+ it 'should execute in describe of project' do
128
+ define('foo') { self.version = '1.3' }
129
+ project('foo').version.should eql('1.3')
130
+ end
131
+
132
+ it 'should execute by passing project' do
133
+ define('foo') { |project| project.version = '1.3' }
134
+ project('foo').version.should eql('1.3')
135
+ end
136
+
137
+ it 'should execute in namespace of project' do
138
+ define('foo') { define('bar') { Buildr.application.current_scope.should eql(['foo', 'bar']) } }
139
+ end
140
+ end
141
+
142
+
143
+ describe Project, '#base_dir' do
144
+ it 'should be pwd if not specified' do
145
+ define('foo').base_dir.should eql(Dir.pwd)
146
+ end
147
+
148
+ it 'should come from property, if specified' do
149
+ foo = define('foo', :base_dir=>'tmp')
150
+ foo.base_dir.should point_to_path('tmp')
151
+ end
152
+
153
+ it 'should be expanded path' do
154
+ foo = define('foo', :base_dir=>'tmp')
155
+ foo.base_dir.should eql(File.expand_path('tmp'))
156
+ end
157
+
158
+ it 'should be relative to parent project' do
159
+ define('foo') { define('bar') { define 'baz' } }
160
+ project('foo:bar:baz').base_dir.should point_to_path('bar/baz')
161
+ end
162
+
163
+ it 'should be settable only if not read' do
164
+ lambda { define('foo', :base_dir=>'tmp') }.should_not raise_error
165
+ lambda { define('bar', :base_dir=>'tmp') { self.base_dir = 'bar' } }.should raise_error(Exception, /Cannot set/)
166
+ end
167
+ end
168
+
169
+
170
+ describe Layout do
171
+ before :each do
172
+ @layout = Layout.new
173
+ end
174
+
175
+ it 'should expand empty to itself' do
176
+ @layout.expand.should eql('')
177
+ @layout.expand('').should eql('')
178
+ end
179
+
180
+ it 'should expand array of symbols' do
181
+ @layout.expand(:foo, :bar).should eql('foo/bar')
182
+ end
183
+
184
+ it 'should expand array of names' do
185
+ @layout.expand('foo', 'bar').should eql('foo/bar')
186
+ end
187
+
188
+ it 'should map symbol to path' do
189
+ @layout[:foo] = 'baz'
190
+ @layout.expand(:foo, :bar).should eql('baz/bar')
191
+ end
192
+
193
+ it 'should map symbols to path' do
194
+ @layout[:foo, :bar] = 'none'
195
+ @layout.expand(:foo, :bar).should eql('none')
196
+ end
197
+
198
+ it 'should map strings to path' do
199
+ @layout[:foo, "bar"] = 'none'
200
+ @layout.expand(:foo, :bar).should eql('none')
201
+ @layout.expand(:foo, 'bar').should eql('none')
202
+ end
203
+
204
+ it 'should ignore nil elements' do
205
+ @layout[:foo, :bar] = 'none'
206
+ @layout.expand(:foo, nil, :bar).should eql('none')
207
+ @layout.expand(nil, :foo).should eql('foo')
208
+ end
209
+
210
+ it 'should return nil if path not mapped' do
211
+ @layout[:foo].should be_nil
212
+ end
213
+
214
+ it 'should return path from symbol' do
215
+ @layout[:foo] = 'path'
216
+ @layout[:foo].should eql('path')
217
+ end
218
+
219
+ it 'should return path from symbol' do
220
+ @layout[:foo, :bar] = 'path'
221
+ @layout[:foo, :bar].should eql('path')
222
+ end
223
+
224
+ it 'should do eager mapping' do
225
+ @layout[:one] = 'none'
226
+ @layout[:one, :two] = '1..2'
227
+ @layout.expand(:one, :two, :three).should eql('1..2/three')
228
+ end
229
+
230
+ end
231
+
232
+
233
+ describe Project, '#layout' do
234
+ before :each do
235
+ @layout = Layout.new
236
+ end
237
+
238
+ it 'should exist by default' do
239
+ define('foo').layout.should respond_to(:expand)
240
+ end
241
+
242
+ it 'should be clone of default layout' do
243
+ define 'foo' do
244
+ layout.should_not be(Layout.default)
245
+ layout.expand(:test, :main).should eql(Layout.default.expand(:test, :main))
246
+ end
247
+ end
248
+
249
+ it 'should come from property, if specified' do
250
+ foo = define('foo', :layout=>@layout)
251
+ foo.layout.should eql(@layout)
252
+ end
253
+
254
+ it 'should inherit from parent project' do
255
+ define 'foo', :layout=>@layout do
256
+ layout[:foo] = 'foo'
257
+ define 'bar'
258
+ end
259
+ project('foo:bar').layout[:foo].should eql('foo')
260
+ end
261
+
262
+ it 'should clone when inheriting from parent project' do
263
+ define 'foo', :layout=>@layout do
264
+ layout[:foo] = 'foo'
265
+ define 'bar' do
266
+ layout[:foo] = 'bar'
267
+ end
268
+ end
269
+ project('foo').layout[:foo].should eql('foo')
270
+ project('foo:bar').layout[:foo].should eql('bar')
271
+ end
272
+
273
+ it 'should be settable only if not read' do
274
+ lambda { define('foo', :layout=>@layout) }.should_not raise_error
275
+ lambda { define('bar', :layout=>@layout) { self.layout = @layout.clone } }.should raise_error(Exception, /Cannot set/)
276
+ end
277
+
278
+ end
279
+
280
+
281
+ describe Project, '#path_to' do
282
+ it 'should return absolute paths as is' do
283
+ define('foo').path_to('/tmp').should eql(File.expand_path('/tmp'))
284
+ end
285
+
286
+ it 'should resolve empty path to project\'s base directory' do
287
+ define('foo').path_to.should eql(project('foo').base_dir)
288
+ end
289
+
290
+ it 'should resolve relative paths' do
291
+ define('foo').path_to('tmp').should eql(File.expand_path('tmp'))
292
+ end
293
+
294
+ it 'should accept multiple arguments' do
295
+ define('foo').path_to('foo', 'bar').should eql(File.expand_path('foo/bar'))
296
+ end
297
+
298
+ it 'should handle relative paths' do
299
+ define('foo').path_to('..', 'bar').should eql(File.expand_path('../bar'))
300
+ end
301
+
302
+ it 'should resolve symbols using layout' do
303
+ define('foo').layout[:foo] = 'bar'
304
+ project('foo').path_to(:foo).should eql(File.expand_path('bar'))
305
+ project('foo').path_to(:foo, 'tmp').should eql(File.expand_path('bar/tmp'))
306
+ end
307
+
308
+ it 'should resolve path for sub-project' do
309
+ define('foo') { define 'bar' }
310
+ project('foo:bar').path_to('foo').should eql(File.expand_path('foo', project('foo:bar').base_dir))
311
+ end
312
+
313
+ it 'should be idempotent for relative paths' do
314
+ define 'foo'
315
+ path = project('foo').path_to('bar')
316
+ project('foo').path_to(path).should eql(path)
317
+ end
318
+ end
319
+
320
+
321
+ describe Project, '#on_define' do
322
+ it 'should be called when project is defined' do
323
+ names = []
324
+ Project.on_define { |project| names << project.name }
325
+ define 'foo' ; define 'bar'
326
+ names.should eql(['foo', 'bar'])
327
+ end
328
+
329
+ it 'should be called with project object' do
330
+ Project.on_define { |project| project.name.should eql('foo') }
331
+ define('foo')
332
+ end
333
+
334
+ it 'should be called with project object and set properties' do
335
+ Project.on_define { |project| project.version.should eql('2.0') }
336
+ define('foo', :version=>'2.0')
337
+ end
338
+
339
+ it 'should execute in namespace of project' do
340
+ scopes = []
341
+ Project.on_define { |project| scopes << Buildr.application.current_scope }
342
+ define('foo') { define 'bar' }
343
+ scopes.should eql([['foo'], ['foo', 'bar']])
344
+ end
345
+
346
+ it 'should be called before project block' do
347
+ order = []
348
+ Project.on_define { |project| order << 'on_define' }
349
+ define('foo') { order << 'define' }
350
+ order.should eql(['on_define', 'define'])
351
+ end
352
+
353
+ it 'should accept enhancement and call it after project block' do
354
+ order = []
355
+ Project.on_define { |project| project.enhance { order << 'enhance' } }
356
+ define('foo') { order << 'define' }
357
+ order.should eql(['define', 'enhance'])
358
+ end
359
+
360
+ it 'should accept enhancement and call it with project' do
361
+ Project.on_define { |project| project.enhance { |project| project.name.should eql('foo') } }
362
+ define('foo')
363
+ end
364
+
365
+ it 'should execute enhancement in namespace of project' do
366
+ scopes = []
367
+ Project.on_define { |project| project.enhance { scopes << Buildr.application.current_scope } }
368
+ define('foo') { define 'bar' }
369
+ scopes.should eql([['foo'], ['foo', 'bar']])
370
+ end
371
+
372
+ it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
373
+ Buildr::VERSION.should < '1.5'
374
+ end
375
+ end
376
+
377
+
378
+ describe Rake::Task, ' recursive' do
379
+ before do
380
+ @order = []
381
+ Project.on_define do |project| # TODO on_define is deprecated
382
+ project.recursive_task('doda') { @order << project.name }
383
+ end
384
+ define('foo') { define('bar') { define('baz') } }
385
+ end
386
+
387
+ it 'should invoke same task in child project' do
388
+ task('foo:doda').invoke
389
+ @order.should include('foo:bar:baz')
390
+ @order.should include('foo:bar')
391
+ @order.should include('foo')
392
+ end
393
+
394
+ it 'should invoke in depth-first order' do
395
+ task('foo:doda').invoke
396
+ @order.should eql([ 'foo:bar:baz', 'foo:bar', 'foo' ])
397
+ end
398
+
399
+ it 'should not invoke task in parent project' do
400
+ task('foo:bar:baz:doda').invoke
401
+ @order.should eql([ 'foo:bar:baz' ])
402
+ end
403
+ end
404
+
405
+
406
+ describe 'Sub-project' do
407
+ it 'should point at parent project' do
408
+ define('foo') { define 'bar' }
409
+ project('foo:bar').parent.should be(project('foo'))
410
+ end
411
+
412
+ it 'should be defined only within parent project' do
413
+ lambda { define('foo:bar') }.should raise_error
414
+ end
415
+
416
+ it 'should have unique name' do
417
+ lambda do
418
+ define 'foo' do
419
+ define 'bar'
420
+ define 'bar'
421
+ end
422
+ end.should raise_error
423
+ end
424
+
425
+ it 'should be findable from root' do
426
+ define('foo') { define 'bar' }
427
+ projects.map(&:name).should include('foo:bar')
428
+ end
429
+
430
+ it 'should be findable from parent project' do
431
+ define('foo') { define 'bar' }
432
+ project('foo').projects.map(&:name).should include('foo:bar')
433
+ end
434
+
435
+ it 'should be findable during project definition' do
436
+ define 'foo' do
437
+ bar = define 'bar' do
438
+ baz = define 'baz'
439
+ project('baz').should eql(baz)
440
+ end
441
+ # Note: evaluating bar:baz first unearthed a bug that doesn't happen
442
+ # if we evaluate bar, then bar:baz.
443
+ project('bar:baz').should be(bar.project('baz'))
444
+ project('bar').should be(bar)
445
+ end
446
+ end
447
+
448
+ it 'should be findable only if exists' do
449
+ define('foo') { define 'bar' }
450
+ lambda { project('foo').project('baz') }.should raise_error(RuntimeError, /No such project/)
451
+ end
452
+
453
+ it 'should always execute its definition ' do
454
+ ordered = []
455
+ define 'foo' do
456
+ ordered << self.name
457
+ define('bar') { ordered << self.name }
458
+ define('baz') { ordered << self.name }
459
+ end
460
+ ordered.should eql(['foo', 'foo:bar', 'foo:baz'])
461
+ end
462
+
463
+ it 'should execute in order of dependency' do
464
+ ordered = []
465
+ define 'foo' do
466
+ ordered << self.name
467
+ define('bar') { project('foo:baz') ; ordered << self.name }
468
+ define('baz') { ordered << self.name }
469
+ end
470
+ ordered.should eql(['foo', 'foo:baz', 'foo:bar'])
471
+ end
472
+
473
+ it 'should warn of circular dependency' do
474
+ lambda do
475
+ define 'foo' do
476
+ define('bar') { project('foo:baz') }
477
+ define('baz') { project('foo:bar') }
478
+ end
479
+ end.should raise_error(RuntimeError, /Circular dependency/)
480
+ end
481
+ end
482
+
483
+
484
+ describe 'Top-level project' do
485
+ it 'should have no parent' do
486
+ define('foo')
487
+ project('foo').parent.should be_nil
488
+ end
489
+ end
490
+
491
+
492
+ describe Buildr, '#project' do
493
+ it 'should raise error if no such project' do
494
+ lambda { project('foo') }.should raise_error(RuntimeError, /No such project/)
495
+ end
496
+
497
+ it 'should return a project if exists' do
498
+ foo = define('foo')
499
+ project('foo').should be(foo)
500
+ end
501
+
502
+ it 'should find a project by its full name' do
503
+ bar, baz = nil
504
+ define('foo') { bar = define('bar') { baz = define('baz') } }
505
+ project('foo:bar').should be(bar)
506
+ project('foo:bar:baz').should be(baz)
507
+ end
508
+
509
+ it 'should find a project from any context' do
510
+ bar, baz = nil
511
+ define('foo') { bar = define('bar') { baz = define('baz') } }
512
+ project('foo:bar').project('foo:bar:baz').should be(baz)
513
+ project('foo:bar:baz').project('foo:bar').should be(bar)
514
+ end
515
+
516
+ it 'should find a project from its parent or sibling project' do
517
+ define 'foo' do
518
+ define 'bar'
519
+ define 'baz'
520
+ end
521
+ project('foo').project('bar').should be(project('foo:bar'))
522
+ project('foo').project('baz').should be(project('foo:baz'))
523
+ project('foo:bar').project('baz').should be(project('foo:baz'))
524
+ end
525
+
526
+ it 'should fine a project from its parent by proximity' do
527
+ define 'foo' do
528
+ define('bar') { define 'baz' }
529
+ define 'baz'
530
+ end
531
+ project('foo').project('baz').should be(project('foo:baz'))
532
+ project('foo:bar').project('baz').should be(project('foo:bar:baz'))
533
+ end
534
+
535
+ it 'should invoke project before returning it' do
536
+ define('foo').should_receive(:invoke).once
537
+ project('foo')
538
+ end
539
+
540
+ it 'should fail if called without a project name' do
541
+ lambda { project }.should raise_error(ArgumentError)
542
+ end
543
+
544
+ it 'should return self if called on a project without a name' do
545
+ define('foo') { project.should be(self) }
546
+ end
547
+
548
+ it 'should evaluate parent project before returning' do
549
+ # Note: gets around our define that also invokes the project.
550
+ Buildr.define('foo') { define('bar'); define('baz') }
551
+ project('foo:bar').should eql(projects[1])
552
+ end
553
+ end
554
+
555
+
556
+ describe Buildr, '#projects' do
557
+ it 'should only return defined projects' do
558
+ projects.should eql([])
559
+ define 'foo'
560
+ projects.should eql([project('foo')])
561
+ end
562
+
563
+ it 'should return all defined projects' do
564
+ define 'foo'
565
+ define('bar') { define 'baz' }
566
+ projects.should include(project('foo'))
567
+ projects.should include(project('bar'))
568
+ projects.should include(project('bar:baz'))
569
+ end
570
+
571
+ it 'should return only named projects' do
572
+ define 'foo' ; define 'bar' ; define 'baz'
573
+ projects('foo', 'bar').should include(project('foo'))
574
+ projects('foo', 'bar').should include(project('bar'))
575
+ projects('foo', 'bar').should_not include(project('baz'))
576
+ end
577
+
578
+ it 'should complain if named project does not exist' do
579
+ define 'foo'
580
+ projects('foo').should include(project('foo'))
581
+ lambda { projects('bar') }.should raise_error(RuntimeError, /No such project/)
582
+ end
583
+
584
+ it 'should find a project from its parent or sibling project' do
585
+ define 'foo' do
586
+ define 'bar'
587
+ define 'baz'
588
+ end
589
+ project('foo').projects('bar').should eql(projects('foo:bar'))
590
+ project('foo').projects('baz').should eql(projects('foo:baz'))
591
+ project('foo:bar').projects('baz').should eql(projects('foo:baz'))
592
+ end
593
+
594
+ it 'should fine a project from its parent by proximity' do
595
+ define 'foo' do
596
+ define('bar') { define 'baz' }
597
+ define 'baz'
598
+ end
599
+ project('foo').projects('baz').should eql(projects('foo:baz'))
600
+ project('foo:bar').projects('baz').should eql(projects('foo:bar:baz'))
601
+ end
602
+
603
+ it 'should evaluate all projects before returning' do
604
+ # Note: gets around our define that also invokes the project.
605
+ Buildr.define('foo') { define('bar'); define('baz') }
606
+ projects.should eql(projects('foo', 'foo:bar', 'foo:baz'))
607
+ end
608
+ end
609
+
610
+
611
+ describe Rake::Task, ' local directory' do
612
+ before do
613
+ @task = Project.local_task(task(('doda')))
614
+ Project.on_define { |project| task('doda') { |task| @task.from project.name } }
615
+ end
616
+
617
+ it 'should execute project in local directory' do
618
+ define 'foo'
619
+ @task.should_receive(:from).with('foo')
620
+ @task.invoke
621
+ end
622
+
623
+ it 'should execute sub-project in local directory' do
624
+ @task.should_receive(:from).with('foo:bar')
625
+ define('foo') { define 'bar' }
626
+ in_original_dir(project('foo:bar').base_dir) { @task.invoke }
627
+ end
628
+
629
+ it 'should do nothing if no project in local directory' do
630
+ @task.should_not_receive(:from)
631
+ define('foo') { define 'bar' }
632
+ in_original_dir('../not_foo') { @task.invoke }
633
+ end
634
+
635
+ it 'should find closest project that matches current directory' do
636
+ mkpath 'bar/src/main'
637
+ define('foo') { define 'bar' }
638
+ @task.should_receive(:from).with('foo:bar')
639
+ in_original_dir('bar/src/main') { @task.invoke }
640
+ end
641
+ end
642
+
643
+
644
+ describe Project, '#task' do
645
+ it 'should create a regular task' do
646
+ define('foo') { task('bar') }
647
+ Buildr.application.lookup('foo:bar').should_not be_nil
648
+ end
649
+
650
+ it 'should return a task defined in the project' do
651
+ define('foo') { task('bar') }
652
+ project('foo').task('bar').should be_instance_of(Rake::Task)
653
+ end
654
+
655
+ it 'should not create task outside project definition' do
656
+ define 'foo'
657
+ lambda { project('foo').task('bar') }.should raise_error(RuntimeError, /no task foo:bar/)
658
+ end
659
+
660
+ it 'should include project name as prefix' do
661
+ define('foo') { task('bar') }
662
+ project('foo').task('bar').name.should eql('foo:bar')
663
+ end
664
+
665
+ it 'should ignore namespace if starting with color' do
666
+ define 'foo' do
667
+ task(':bar').name.should == 'bar'
668
+ end
669
+ Rake::Task.task_defined?('bar').should be_true
670
+ end
671
+
672
+ it 'should accept single dependency' do
673
+ define('foo') { task('bar'=>'baz') }
674
+ project('foo').task('bar').prerequisites.should include('baz')
675
+ end
676
+
677
+ it 'should accept multiple dependencies' do
678
+ define('foo') { task('bar'=>['baz1', 'baz2']) }
679
+ project('foo').task('bar').prerequisites.should include('baz1')
680
+ project('foo').task('bar').prerequisites.should include('baz2')
681
+ end
682
+
683
+ it 'should execute task exactly once' do
684
+ define('foo') do
685
+ task 'baz'
686
+ task 'bar'=>'baz'
687
+ end
688
+ lambda { project('foo').task('bar').invoke }.should run_tasks(['foo:baz', 'foo:bar'])
689
+ end
690
+
691
+ it 'should create a file task' do
692
+ define('foo') { file('bar') }
693
+ Buildr.application.lookup(File.expand_path('bar')).should_not be_nil
694
+ end
695
+
696
+ it 'should create file task with absolute path' do
697
+ define('foo') { file('/tmp') }
698
+ Buildr.application.lookup(File.expand_path('/tmp')).should_not be_nil
699
+ end
700
+
701
+ it 'should create file task relative to project base directory' do
702
+ define('foo', :base_dir=>'tmp') { file('bar') }
703
+ Buildr.application.lookup(File.expand_path('tmp/bar')).should_not be_nil
704
+ end
705
+
706
+ it 'should accept single dependency' do
707
+ define('foo') { file('bar'=>'baz') }
708
+ project('foo').file('bar').prerequisites.should include('baz')
709
+ end
710
+
711
+ it 'should accept multiple dependencies' do
712
+ define('foo') { file('bar'=>['baz1', 'baz2']) }
713
+ project('foo').file('bar').prerequisites.should include('baz1')
714
+ project('foo').file('bar').prerequisites.should include('baz2')
715
+ end
716
+
717
+ it 'should accept hash arguments' do
718
+ define('foo') do
719
+ task 'bar'=>'bar_dep'
720
+ file 'baz'=>'baz_dep'
721
+ end
722
+ project('foo').task('bar').prerequisites.should include('bar_dep')
723
+ project('foo').file('baz').prerequisites.should include('baz_dep')
724
+ end
725
+
726
+ it 'should return a file task defined in the project' do
727
+ define('foo') { file('bar') }
728
+ project('foo').file('bar').should be_instance_of(Rake::FileTask)
729
+ end
730
+
731
+ it 'should create file task relative to project definition' do
732
+ define('foo') { define 'bar' }
733
+ project('foo:bar').file('baz').name.should point_to_path('bar/baz')
734
+ end
735
+
736
+ it 'should execute task exactly once' do
737
+ define('foo') do
738
+ task 'baz'
739
+ file 'bar'=>'baz'
740
+ end
741
+ lambda { project('foo').file('bar').invoke }.should run_tasks(['foo:baz', project('foo').path_to('bar')])
742
+ end
743
+ end
744
+
745
+
746
+ =begin
747
+ describe Buildr::Generate do
748
+ it 'should be able to create buildfile from directory structure' do
749
+ write 'src/main/java/Foo.java', ''
750
+ write 'one/two/src/main/java/Foo.java', ''
751
+ write 'one/three/src/main/java/Foo.java', ''
752
+ write 'four/src/main/java/Foo.java', ''
753
+ script = Buildr::Generate.from_directory(Dir.pwd)
754
+ instance_eval(script.join("\n"), "generated buildfile")
755
+ # projects should have been defined
756
+ root = Dir.pwd.pathmap('%n')
757
+ names = [root, "#{root}:one:two", "#{root}:one:three", "#{root}:four"]
758
+ # the top level project has the directory name.
759
+ names.each { |name| lambda { project(name) }.should_not raise_error }
760
+ end
761
+ end
762
+ =end