buildr 1.4.16 → 1.4.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG +20 -0
  3. data/addon/buildr/bnd.rb +158 -158
  4. data/addon/buildr/checkstyle-report.xsl +87 -0
  5. data/addon/buildr/checkstyle.rb +213 -205
  6. data/addon/buildr/css_lint-report.xsl +83 -0
  7. data/addon/buildr/css_lint.rake +196 -0
  8. data/addon/buildr/custom_pom.rb +282 -0
  9. data/addon/buildr/drb.rb +0 -1
  10. data/addon/buildr/git_auto_version.rb +34 -34
  11. data/addon/buildr/gwt.rb +171 -171
  12. data/addon/buildr/hibernate.rb +8 -8
  13. data/addon/buildr/javancss.rb +155 -155
  14. data/addon/buildr/jaxb_xjc.rb +74 -74
  15. data/addon/buildr/jibx.rb +0 -1
  16. data/addon/buildr/org/apache/buildr/BuildrNail.java +2 -2
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.java +3 -3
  18. data/addon/buildr/package_as_nsis.rb +2 -2
  19. data/addon/buildr/pmd.rb +166 -166
  20. data/addon/buildr/scss_lint-report.xsl +79 -0
  21. data/addon/buildr/scss_lint.rb +199 -0
  22. data/addon/buildr/wsgen.rb +4 -0
  23. data/doc/building.textile +3 -3
  24. data/doc/css/default.css +3 -3
  25. data/doc/css/print.css +1 -1
  26. data/doc/download.textile +18 -7
  27. data/doc/index.textile +8 -1
  28. data/doc/installing.textile +3 -3
  29. data/doc/languages.textile +0 -1
  30. data/doc/mailing_lists.textile +0 -4
  31. data/doc/more_stuff.textile +127 -3
  32. data/doc/preface.textile +1 -1
  33. data/doc/projects.textile +6 -6
  34. data/doc/releasing.textile +0 -1
  35. data/lib/buildr/clojure/shell.rb +0 -1
  36. data/lib/buildr/core/build.rb +16 -16
  37. data/lib/buildr/core/filter.rb +3 -3
  38. data/lib/buildr/core/jrebel.rb +0 -1
  39. data/lib/buildr/core/linux.rb +0 -1
  40. data/lib/buildr/core/run.rb +0 -1
  41. data/lib/buildr/core/shell.rb +0 -1
  42. data/lib/buildr/groovy/doc.rb +0 -1
  43. data/lib/buildr/ide/eclipse.rb +0 -2
  44. data/lib/buildr/ide/idea.rb +44 -8
  45. data/lib/buildr/java/bdd.rb +0 -1
  46. data/lib/buildr/java/commands.rb +2 -3
  47. data/lib/buildr/java/jruby.rb +2 -2
  48. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +5 -5
  49. data/lib/buildr/java/tests.rb +0 -1
  50. data/lib/buildr/packaging/artifact_namespace.rb +0 -2
  51. data/lib/buildr/resources/icons-license.txt +14 -17
  52. data/lib/buildr/scala/bdd.rb +0 -1
  53. data/lib/buildr/scala/compiler.rb +0 -1
  54. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
  55. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +0 -2
  56. data/lib/buildr/version.rb +1 -1
  57. data/rakelib/metrics.rake +3 -3
  58. data/rakelib/release.rake +8 -2
  59. data/spec/addon/bnd_spec.rb +383 -383
  60. data/spec/addon/custom_pom_spec.rb +149 -0
  61. data/spec/addon/drb_spec.rb +0 -1
  62. data/spec/addon/jaxb_xjc_spec.rb +130 -130
  63. data/spec/core/application_spec.rb +0 -1
  64. data/spec/core/build_spec.rb +1 -1
  65. data/spec/core/console_spec.rb +0 -1
  66. data/spec/core/doc_spec.rb +0 -1
  67. data/spec/core/extension_spec.rb +0 -1
  68. data/spec/core/generate_from_eclipse_spec.rb +9 -9
  69. data/spec/core/run_spec.rb +2 -3
  70. data/spec/core/shell_spec.rb +0 -1
  71. data/spec/ide/idea_spec.rb +1979 -1941
  72. data/spec/java/cobertura_spec.rb +6 -6
  73. data/spec/java/commands_spec.rb +11 -11
  74. data/spec/java/compiler_spec.rb +0 -1
  75. data/spec/java/doc_spec.rb +0 -1
  76. data/spec/java/ecj_spec.rb +1 -3
  77. data/spec/java/external_spec.rb +0 -2
  78. data/spec/java/java_spec.rb +3 -3
  79. data/spec/java/run_spec.rb +0 -1
  80. data/spec/java/tests_spec.rb +15 -0
  81. data/spec/xpath_matchers.rb +121 -120
  82. metadata +10 -2
@@ -34,7 +34,7 @@ describe Project, :run do
34
34
  end
35
35
  project('foo').run.classpath.should include(artifact('group:compile:jar:1.0'))
36
36
  end
37
-
37
+
38
38
  it 'should not include test dependencies' do
39
39
  define('foo') do
40
40
  compile.using(:javac).with 'group:compile:jar:1.0'
@@ -70,7 +70,7 @@ describe Project, :run do
70
70
  end
71
71
  project('foo').run.runner.should be_a(Run::JavaRunner)
72
72
  end
73
-
73
+
74
74
  it "should run with the project resources" do
75
75
  write 'src/main/java/Test.java', 'class Test {}'
76
76
  write 'src/main/resources/test.properties', ''
@@ -103,4 +103,3 @@ describe Project, :run do
103
103
  end
104
104
 
105
105
  end
106
-
@@ -143,4 +143,3 @@ Shell.providers.each do |provider|
143
143
  end
144
144
  end
145
145
  end
146
-
@@ -1,1941 +1,1979 @@
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.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'xpath_matchers'))
19
-
20
- def ensure_facet_xpath(doc, type, name)
21
- facet_xpath = "/module/component[@name='FacetManager']/facet"
22
- doc.should have_xpath(facet_xpath)
23
- web_facet_xpath = "#{facet_xpath}[@type='#{type}', @name='#{name}']"
24
- doc.should have_xpath(web_facet_xpath)
25
- web_facet_xpath
26
- end
27
-
28
- describe Buildr::IntellijIdea do
29
-
30
- def invoke_generate_task
31
- task('idea').invoke
32
- end
33
-
34
- def invoke_clean_task
35
- task('idea:clean').invoke
36
- end
37
-
38
- def root_project_filename(project)
39
- project._("#{project.name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.ipr")
40
- end
41
-
42
- def root_project_xml(project)
43
- xml_document(root_project_filename(project))
44
- end
45
-
46
- def root_module_filename(project)
47
- project._("#{project.name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.iml")
48
- end
49
-
50
- def root_module_xml(project)
51
- xml_document(root_module_filename(project))
52
- end
53
-
54
- def subproject_module_filename(project, sub_project_name)
55
- project._("#{sub_project_name}/#{sub_project_name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.iml")
56
- end
57
-
58
- def subproject_module_xml(project, sub_project_name)
59
- xml_document(subproject_module_filename(project, sub_project_name))
60
- end
61
-
62
- def xml_document(filename)
63
- File.should be_exist(filename)
64
- REXML::Document.new(File.read(filename))
65
- end
66
-
67
- def xpath_to_module
68
- "/project/component[@name='ProjectModuleManager']/modules/module"
69
- end
70
-
71
- describe "idea:clean" do
72
- before do
73
- write "foo.ipr"
74
- write "foo.iml"
75
- write "other.ipr"
76
- write "other.iml"
77
- mkdir_p 'bar'
78
- write "bar/bar.iml"
79
- write "bar/other.ipr"
80
- write "bar/other.iml"
81
-
82
- @foo = define "foo" do
83
- define "bar"
84
- end
85
- invoke_clean_task
86
- end
87
-
88
- it "should remove the ipr file" do
89
- File.exists?("foo.ipr").should be_false
90
- end
91
-
92
- it "should remove the project iml file" do
93
- File.exists?("foo.iml").should be_false
94
- end
95
-
96
- it "should remove the subproject iml file" do
97
- File.exists?("foo.iml").should be_false
98
- end
99
-
100
- it "should not remove other iml and ipr files" do
101
- File.exists?("other.ipr").should be_true
102
- File.exists?("other.iml").should be_true
103
- File.exists?("bar/other.ipr").should be_true
104
- File.exists?("bar/other.iml").should be_true
105
- end
106
- end
107
-
108
- describe "idea task" do
109
-
110
- def order_entry_xpath
111
- "/module/component[@name='NewModuleRootManager']/orderEntry"
112
- end
113
-
114
- describe "with a single dependency" do
115
- describe "of type compile" do
116
- before do
117
- artifact('group:id:jar:1.0') { |t| write t.to_s }
118
- @foo = define "foo" do
119
- compile.with 'group:id:jar:1.0'
120
- end
121
- invoke_generate_task
122
- end
123
-
124
- it "generates one exported 'module-library' orderEntry in IML" do
125
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library', @exported='']/library/CLASSES/root", 1)
126
- end
127
- end
128
-
129
- describe "with iml.main_dependencies override" do
130
- before do
131
- artifact('group:id:jar:1.0') { |t| write t.to_s }
132
- @foo = define "foo" do
133
- iml.main_dependencies << 'group:id:jar:1.0'
134
- end
135
- invoke_generate_task
136
- end
137
-
138
- it "generates one exported 'module-library' orderEntry in IML" do
139
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library', @exported='']/library/CLASSES/root", 1)
140
- end
141
- end
142
-
143
- describe "of type test" do
144
- before do
145
- artifact('group:id:jar:1.0') { |t| write t.to_s }
146
- @foo = define "foo" do
147
- test.with 'group:id:jar:1.0'
148
- end
149
- invoke_generate_task
150
- end
151
-
152
- it "generates one non-exported test scope 'module-library' orderEntry in IML" do
153
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported]/library/CLASSES/root", 0)
154
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @scope='TEST']/library/CLASSES/root", 1)
155
- end
156
- end
157
-
158
- describe "with iml.test_dependencies override" do
159
- before do
160
- artifact('group:id:jar:1.0') { |t| write t.to_s }
161
- @foo = define "foo" do
162
- iml.test_dependencies << 'group:id:jar:1.0'
163
- end
164
- invoke_generate_task
165
- end
166
-
167
- it "generates one non-exported 'module-library' orderEntry in IML" do
168
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported]/library/CLASSES/root", 0)
169
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library']/library/CLASSES/root", 1)
170
- end
171
- end
172
-
173
- describe "with sources artifact present" do
174
- before do
175
- artifact('group:id:jar:1.0') { |t| write t.to_s }
176
- artifact('group:id:jar:sources:1.0') { |t| write t.to_s }
177
- @foo = define "foo" do
178
- compile.with 'group:id:jar:1.0'
179
- end
180
- invoke_generate_task
181
- end
182
-
183
- it "generates 'module-library' orderEntry in IML with SOURCES specified" do
184
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library', @exported='']/library/SOURCES/root", 1)
185
- end
186
- end
187
-
188
- describe "with local_repository_env_override set to nil" do
189
- before do
190
- Buildr.repositories.instance_eval do
191
- @local = @remote = @release_to = nil
192
- end
193
- artifact('group:id:jar:1.0') { |t| write t.to_s }
194
- @foo = define "foo" do
195
- iml.local_repository_env_override = nil
196
- compile.with 'group:id:jar:1.0'
197
- end
198
- invoke_generate_task
199
- end
200
-
201
- it "generates orderEntry with absolute path for classes jar" do
202
- root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
203
- "jar://$MODULE_DIR$/home/.m2/repository/group/id/1.0/id-1.0.jar!/")
204
- end
205
- end
206
- describe "with local_repository_env_override set to MAVEN_REPOSITORY" do
207
- before do
208
- artifact('group:id:jar:1.0') { |t| write t.to_s }
209
- @foo = define "foo" do
210
- iml.local_repository_env_override = 'MAVEN_REPOSITORY'
211
- compile.with 'group:id:jar:1.0'
212
- end
213
- invoke_generate_task
214
- end
215
-
216
- it "generates orderEntry with absolute path for classes jar" do
217
- root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
218
- "jar://$MAVEN_REPOSITORY$/group/id/1.0/id-1.0.jar!/")
219
- end
220
- end
221
- end
222
-
223
- describe "with multiple dependencies" do
224
- before do
225
- artifact('group:id:jar:1.0') { |t| write t.to_s }
226
- artifact('group:id2:jar:1.0') { |t| write t.to_s }
227
- @foo = define "foo" do
228
- compile.with 'group:id:jar:1.0', 'group:id2:jar:1.0'
229
- end
230
- invoke_generate_task
231
- end
232
-
233
- it "generates multiple 'module-library' orderEntry in IML" do
234
- root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library']", 2)
235
- end
236
- end
237
-
238
- describe "with a single non artifact dependency" do
239
- before do
240
- @foo = define "foo" do
241
- filename = _("foo-dep.jar")
242
- File.open(filename, "wb") { |t| write "Hello" }
243
- compile.with filename
244
- end
245
- invoke_generate_task
246
- end
247
-
248
- it "generates one exported 'module-library' orderEntry in IML" do
249
- root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
250
- "jar://$MODULE_DIR$/foo-dep.jar!/")
251
- end
252
- end
253
-
254
- describe "with extra_modules specified" do
255
- before do
256
- @foo = define "foo" do
257
- ipr.extra_modules << 'other.iml'
258
- ipr.extra_modules << 'other_other.iml'
259
- end
260
- invoke_generate_task
261
- end
262
-
263
- it "generate an IPR with extra modules specified" do
264
- doc = xml_document(@foo._("foo.ipr"))
265
- doc.should have_nodes("#{xpath_to_module}", 3)
266
- module_ref = "$PROJECT_DIR$/foo.iml"
267
- doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
268
- module_ref = "$PROJECT_DIR$/other.iml"
269
- doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
270
- module_ref = "$PROJECT_DIR$/other_other.iml"
271
- doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
272
- end
273
- end
274
-
275
- describe "with web and webservice facet added to root project" do
276
- before do
277
- @foo = define "foo" do
278
- iml.add_facet("Web", "web") do |facet|
279
- facet.configuration do |conf|
280
- conf.descriptors do |desc|
281
- desc.deploymentDescriptor :name => 'web.xml',
282
- :url => "file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml",
283
- :optional => "false", :version => "2.4"
284
- end
285
- conf.webroots do |webroots|
286
- webroots.root :url => "file://$MODULE_DIR$/src/main/webapp", :relative => "/"
287
- end
288
- end
289
- end
290
- iml.add_facet("WebServices Client", "WebServicesClient") do |facet|
291
- facet.configuration "ws.engine" => "Glassfish / JAX-WS 2.X RI / Metro 1.X / JWSDP 2.0"
292
- end
293
- define 'bar'
294
- end
295
- invoke_generate_task
296
- end
297
-
298
- it "generates an IML for root project with a web and webservice facet" do
299
- doc = xml_document(@foo._("foo.iml"))
300
- ensure_facet_xpath(doc, 'web', 'Web')
301
- ensure_facet_xpath(doc, 'WebServicesClient', 'WebServices Client')
302
- end
303
- end
304
-
305
- describe "using add_gwt_facet" do
306
- before do
307
- @foo = define "foo" do
308
- iml.add_gwt_facet("com.biz.MyModule" => true, "com.biz.MyOtherModule" => false)
309
- end
310
- invoke_generate_task
311
- end
312
-
313
- it "generates a gwt facet with default settings" do
314
- doc = xml_document(@foo._("foo.iml"))
315
- facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
316
- setting_xpath = "#{facet_xpath}/configuration/setting"
317
- doc.should have_xpath("#{setting_xpath}[@name='gwtSdkUrl', value='file://$GWT_TOOLS$']")
318
- doc.should have_xpath("#{setting_xpath}[@name='gwtScriptOutputStyle', value='PRETTY']")
319
- doc.should have_xpath("#{setting_xpath}[@name='compilerParameters', value='-draftCompile -localWorkers 2 -strict']")
320
- doc.should have_xpath("#{setting_xpath}[@name='compilerParameters', value='-draftCompile -localWorkers 2 -strict']")
321
- doc.should have_xpath("#{setting_xpath}[@name='compilerMaxHeapSize', value='512']")
322
- doc.should have_xpath("#{setting_xpath}[@name='webFacet', value='Web']")
323
- end
324
-
325
- it "generates a gwt facet with specified modules" do
326
- doc = xml_document(@foo._("foo.iml"))
327
- facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
328
- prefix = "#{facet_xpath}/configuration/packaging/module"
329
- doc.should have_xpath("#{prefix}[@name='com.biz.MyModule', @enabled='true']")
330
- doc.should have_xpath("#{prefix}[@name='com.biz.MyOtherModule', @enabled='false']")
331
- end
332
- end
333
-
334
- describe "using add_gwt_facet that detects gwt sdk" do
335
- before do
336
- artifact('com.google.gwt:gwt-dev:jar:2.5.1-not-a-release') { |task| write task.name }
337
- @foo = define "foo" do
338
- compile.with 'com.google.gwt:gwt-dev:jar:2.5.1-not-a-release'
339
- iml.add_gwt_facet("com.biz.MyModule" => true)
340
- end
341
- invoke_generate_task
342
- end
343
-
344
- it "generates a gwt facet with detected gwt sdk settings" do
345
- doc = xml_document(@foo._("foo.iml"))
346
- facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
347
- setting_xpath = "#{facet_xpath}/configuration/setting"
348
- doc.should have_xpath("#{setting_xpath}[@name='gwtSdkType', value='maven']")
349
- doc.should have_xpath("#{setting_xpath}[@name='gwtSdkUrl', value='$MAVEN_REPOSITORY$/com/google/gwt/gwt-dev/2.5.1-not-a-release']")
350
- end
351
- end
352
-
353
- describe "using add_gwt_facet that specifies gwt sdk" do
354
- before do
355
- artifact('com.example:library:jar:2.0') { |task| write task.name }
356
- @foo = define "foo" do
357
- iml.add_gwt_facet({"com.biz.MyModule" => true},:gwt_dev_artifact => 'com.example:library:jar:2.0')
358
- end
359
- invoke_generate_task
360
- end
361
-
362
- it "generates a gwt facet with detected gwt sdk settings" do
363
- doc = xml_document(@foo._("foo.iml"))
364
- facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
365
- setting_xpath = "#{facet_xpath}/configuration/setting"
366
- doc.should have_xpath("#{setting_xpath}[@name='gwtSdkType', value='maven']")
367
- doc.should have_xpath("#{setting_xpath}[@name='gwtSdkUrl', value='$MAVEN_REPOSITORY$/com/google/gwt/gwt-dev/2.5.1']")
368
- end
369
- end
370
-
371
- describe "using add_gwt_facet that specifies settings" do
372
- before do
373
- @foo = define "foo" do
374
- iml.add_gwt_facet({"com.biz.MyModule" => true, "com.biz.MyOtherModule" => false},
375
- :settings => {:gwtScriptOutputStyle => 'OTHER', :compilerMaxHeapSize => 1024, :zang => 'zang'})
376
- end
377
- invoke_generate_task
378
- end
379
-
380
- it "generates a gwt facet with specified settings" do
381
- doc = xml_document(@foo._("foo.iml"))
382
- facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
383
- setting_xpath = "#{facet_xpath}/configuration/setting"
384
- doc.should have_xpath("#{setting_xpath}[@name='zang', value='zang']")
385
- doc.should have_xpath("#{setting_xpath}[@name='gwtScriptOutputStyle', value='OTHER']")
386
- doc.should have_xpath("#{setting_xpath}[@name='compilerMaxHeapSize', value='1024']")
387
- end
388
- end
389
-
390
- describe "using add_web_facet with jsf and idea version 12" do
391
- before do
392
- write "src/main/webapp/WEB-INF/web.xml"
393
- write "src/main/webapp/WEB-INF/faces-config.xml"
394
-
395
- @foo = define "foo" do
396
- ipr.version = "12"
397
- iml.add_web_facet
398
- end
399
- invoke_generate_task
400
- end
401
-
402
- it "generates a web facet with jsf facet auto-detected" do
403
- doc = xml_document(@foo._("foo.iml"))
404
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
405
- doc.should have_xpath("#{web_facet_xpath}/facet[@type='jsf', @name='JSF']")
406
- end
407
- end
408
-
409
- describe "using add_web_facet should default to no jsf" do
410
- before do
411
- write "src/main/webapp/WEB-INF/web.xml"
412
-
413
- @foo = define "foo" do
414
- iml.add_web_facet
415
- end
416
- invoke_generate_task
417
- end
418
-
419
- it "does not generate a web facet with jsf facet" do
420
- doc = xml_document(@foo._("foo.iml"))
421
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
422
- doc.should_not have_xpath("#{web_facet_xpath}/facet[@type='jsf', @name='JSF']")
423
- end
424
- end
425
-
426
- describe "using add_web_facet with jsf and idea version 13" do
427
- before do
428
- write "src/main/webapp/WEB-INF/web.xml"
429
- write "src/main/webapp/WEB-INF/faces-config.xml"
430
-
431
- @foo = define "foo" do
432
- ipr.version = "13"
433
- iml.add_web_facet
434
- end
435
- invoke_generate_task
436
- end
437
-
438
- it "does not generate a web facet with jsf facet" do
439
- doc = xml_document(@foo._("foo.iml"))
440
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
441
- doc.should_not have_xpath("#{web_facet_xpath}/facet[@type='jsf', @name='JSF']")
442
- end
443
- end
444
-
445
- describe "using add_web_facet with jsf and idea version 13 and jsf 'enabled'" do
446
- before do
447
- write "src/main/webapp/WEB-INF/web.xml"
448
- write "src/main/webapp/WEB-INF/faces-config.xml"
449
-
450
- @foo = define "foo" do
451
- ipr.version = "13"
452
- iml.add_web_facet(:enable_jsf => true)
453
- end
454
- invoke_generate_task
455
- end
456
-
457
- it "does not generate a web facet with jsf facet" do
458
- doc = xml_document(@foo._("foo.iml"))
459
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
460
- doc.should_not have_xpath("#{web_facet_xpath}/facet[@type='jsf', @name='JSF']")
461
- end
462
- end
463
-
464
- describe "using add_web_facet" do
465
- before do
466
- write "src/main/webapp/WEB-INF/web.xml"
467
- write "src/main/webapp/WEB-INF/glassfish-web.xml"
468
- write "src/main/webapp/WEB-INF/context.xml"
469
-
470
- @foo = define "foo" do
471
- iml.add_web_facet
472
- end
473
- invoke_generate_task
474
- end
475
-
476
- it "generates a web facet with appropriate deployment descriptors" do
477
- doc = xml_document(@foo._("foo.iml"))
478
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
479
- deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
480
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='web.xml', url='file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml']")
481
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='glassfish-web.xml', url='file://$MODULE_DIR$/src/main/webapp/WEB-INF/glassfish-web.xml']")
482
- end
483
-
484
- it "generates a web facet with derived webroots" do
485
- doc = xml_document(@foo._("foo.iml"))
486
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
487
- doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/webapp', @realtive='/']")
488
- end
489
- end
490
-
491
- describe "using add_web_facet with specified parameters" do
492
- before do
493
- @foo = define "foo" do
494
- iml.add_web_facet(:deployment_descriptors => ["src/main/webapp2/WEB-INF/web.xml"],
495
- :webroots => {"src/main/webapp2" => "/", "src/main/css" => "/css"})
496
- end
497
- invoke_generate_task
498
- end
499
-
500
- it "generates a web facet with appropriate deployment descriptors" do
501
- doc = xml_document(@foo._("foo.iml"))
502
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
503
- deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
504
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='web.xml', url='file://$MODULE_DIR$/src/main/webapp2/WEB-INF/web.xml']")
505
- end
506
-
507
- it "generates a web facet with specified webroots" do
508
- doc = xml_document(@foo._("foo.iml"))
509
- web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
510
- doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/webapp2', @realtive='/']")
511
- doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/css', @realtive='/css']")
512
- end
513
- end
514
-
515
- describe "using add_jpa_facet" do
516
- before do
517
- write "src/main/resources/META-INF/persistence.xml", "org.hibernate.ejb.HibernatePersistence"
518
- write "src/main/resources/META-INF/orm.xml"
519
-
520
- @foo = define "foo" do
521
- iml.add_jpa_facet
522
- end
523
- invoke_generate_task
524
- end
525
-
526
- it "generates a jpa facet with appropriate deployment descriptors" do
527
- doc = xml_document(@foo._("foo.iml"))
528
- facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
529
- deployment_descriptor_xpath = "#{facet_xpath}/configuration/deploymentDescriptor"
530
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='persistence.xml', url='file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml']")
531
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='orm.xml', url='file://$MODULE_DIR$/src/main/resources/META-INF/orm.xml']")
532
- end
533
-
534
- it "generates a jpa facet with default settings" do
535
- doc = xml_document(@foo._("foo.iml"))
536
- facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
537
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled', @value='true']")
538
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name', @value='Hibernate']")
539
- end
540
- end
541
-
542
- describe "using add_jpa_facet specifying parameters" do
543
- before do
544
- write "src/main/resources2/META-INF/persistence.xml"
545
- write "src/main/resources2/META-INF/orm.xml"
546
-
547
- @foo = define "foo" do
548
- iml.add_jpa_facet(:provider_enabled => 'Hibernate',
549
- :deployment_descriptors => ["src/main/resources2/META-INF/persistence.xml",
550
- "src/main/resources2/META-INF/orm.xml"])
551
- end
552
- invoke_generate_task
553
- end
554
-
555
- it "generates a jpa facet with appropriate deployment descriptors" do
556
- doc = xml_document(@foo._("foo.iml"))
557
- facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
558
- deployment_descriptor_xpath = "#{facet_xpath}/configuration/deploymentDescriptor"
559
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='persistence.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/persistence.xml']")
560
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='orm.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/orm.xml']")
561
- end
562
-
563
- it "generates a jpa facet with default settings" do
564
- doc = xml_document(@foo._("foo.iml"))
565
- facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
566
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled', @value='true']")
567
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name', @value='Hibernate']")
568
- end
569
- end
570
-
571
- describe "using add_jpa_facet derived from main_source_directories" do
572
- before do
573
- write "src/main/resources2/META-INF/persistence.xml"
574
- write "src/main/resources2/META-INF/orm.xml"
575
-
576
- @foo = define "foo" do
577
- iml.main_source_directories << "src/main/resources2"
578
- iml.add_jpa_facet
579
-
580
- end
581
- invoke_generate_task
582
- end
583
-
584
- it "generates a jpa facet with appropriate deployment descriptors" do
585
- doc = xml_document(@foo._("foo.iml"))
586
- facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
587
- deployment_descriptor_xpath = "#{facet_xpath}/configuration/deploymentDescriptor"
588
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='persistence.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/persistence.xml']")
589
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='orm.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/orm.xml']")
590
- end
591
- end
592
-
593
- describe "using add_jpa_facet with hibernate configured in persistence.xml" do
594
- before do
595
- write "src/main/resources/META-INF/persistence.xml", "org.hibernate.ejb.HibernatePersistence"
596
- write "src/main/resources/META-INF/orm.xml"
597
-
598
- @foo = define "foo" do
599
- iml.add_jpa_facet
600
- end
601
- invoke_generate_task
602
- end
603
-
604
- it "generates a jpa facet with default settings" do
605
- doc = xml_document(@foo._("foo.iml"))
606
- facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
607
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled', @value='true']")
608
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name', @value='Hibernate']")
609
- end
610
- end
611
-
612
- describe "using add_jpa_facet with eclipselink configured in persistence.xml" do
613
- before do
614
- write "src/main/resources/META-INF/persistence.xml", "org.eclipse.persistence.jpa.PersistenceProvider"
615
- write "src/main/resources/META-INF/orm.xml"
616
-
617
- @foo = define "foo" do
618
- iml.add_jpa_facet
619
- end
620
- invoke_generate_task
621
- end
622
-
623
- it "generates a jpa facet with default settings" do
624
- doc = xml_document(@foo._("foo.iml"))
625
- facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
626
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled', @value='true']")
627
- doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name', @value='EclipseLink']")
628
- end
629
- end
630
-
631
- describe "using add_ejb_facet" do
632
- before do
633
- write "src/main/java/com/bin/foo.java"
634
- write "src/main/resources/WEB-INF/ejb-jar.xml"
635
-
636
- @foo = define "foo" do
637
- iml.add_ejb_facet
638
- end
639
- invoke_generate_task
640
- end
641
-
642
- it "generates an ejb facet with appropriate deployment descriptors" do
643
- doc = xml_document(@foo._("foo.iml"))
644
- ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
645
- deployment_descriptor_xpath = "#{ejb_facet_xpath}/configuration/descriptors/deploymentDescriptor"
646
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/src/main/resources/WEB-INF/ejb-jar.xml']")
647
- end
648
-
649
- it "generates an ejb facet with derived ejbRoots" do
650
- doc = xml_document(@foo._("foo.iml"))
651
- ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
652
- doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/src/main/java']")
653
- doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/src/main/resources']")
654
- end
655
- end
656
-
657
- describe "using add_ejb_facet specifying parameters" do
658
- before do
659
- @foo = define "foo" do
660
- iml.add_ejb_facet(:ejb_roots => ["generated/main/java","generated/main/resources"],
661
- :deployment_descriptors => ["generated/main/resources/WEB-INF/ejb-jar.xml"])
662
- end
663
- invoke_generate_task
664
- end
665
-
666
- it "generates an ejb facet with appropriate deployment descriptors" do
667
- doc = xml_document(@foo._("foo.iml"))
668
- ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
669
- deployment_descriptor_xpath = "#{ejb_facet_xpath}/configuration/descriptors/deploymentDescriptor"
670
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/generated/main/resources/WEB-INF/ejb-jar.xml']")
671
- end
672
-
673
- it "generates an ejb facet with derived ejbRoots" do
674
- doc = xml_document(@foo._("foo.iml"))
675
- ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
676
- doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/generated/main/java']")
677
- doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/generated/main/resources']")
678
- end
679
- end
680
-
681
- describe "using add_ejb_facet derived from main_source_directories" do
682
- before do
683
- write "src/main/resources2/WEB-INF/ejb-jar.xml"
684
- @foo = define "foo" do
685
- iml.main_source_directories << "src/main/resources2"
686
- iml.add_ejb_facet
687
- end
688
- invoke_generate_task
689
- end
690
-
691
- it "generates an ejb facet with appropriate deployment descriptors" do
692
- doc = xml_document(@foo._("foo.iml"))
693
- ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
694
- deployment_descriptor_xpath = "#{ejb_facet_xpath}/configuration/descriptors/deploymentDescriptor"
695
- doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/src/main/resources2/WEB-INF/ejb-jar.xml']")
696
- end
697
- end
698
-
699
- describe "using add_jruby_facet" do
700
- before do
701
-
702
- @foo = define "foo" do
703
- iml.add_jruby_facet
704
- end
705
- invoke_generate_task
706
- end
707
-
708
- it "generates a jruby facet with appropriate sdk" do
709
- doc = xml_document(@foo._("foo.iml"))
710
- jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
711
- doc.should have_xpath("#{jruby_facet_xpath}/configuration/JRUBY_FACET_CONFIG_ID[@NAME='JRUBY_SDK_NAME', VALUE='jruby-1.6.7.2']")
712
- end
713
-
714
- it "generates a jruby facet with appropriate paths" do
715
- doc = xml_document(@foo._("foo.iml"))
716
- jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
717
- prefix = "#{jruby_facet_xpath}/configuration"
718
- doc.should have_xpath("#{prefix}/LOAD_PATH[@number='0']")
719
- doc.should have_xpath("#{prefix}/I18N_FOLDERS[@number='0']")
720
- end
721
- end
722
-
723
- describe "using add_jruby_facet with .ruby-version specified" do
724
- before do
725
-
726
- write ".ruby-version", "jruby-1.7.2"
727
-
728
- @foo = define "foo" do
729
- iml.add_jruby_facet
730
- end
731
- invoke_generate_task
732
- end
733
-
734
- it "generates a jruby facet with appropriate sdk" do
735
- doc = xml_document(@foo._("foo.iml"))
736
- jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
737
- doc.should have_xpath("#{jruby_facet_xpath}/configuration/JRUBY_FACET_CONFIG_ID[@NAME='JRUBY_SDK_NAME', VALUE='rbenv: jruby-1.7.2']")
738
- end
739
-
740
- it "generates a jruby facet with appropriate paths" do
741
- doc = xml_document(@foo._("foo.iml"))
742
- jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
743
- prefix = "#{jruby_facet_xpath}/configuration"
744
- doc.should have_xpath("#{prefix}/LOAD_PATH[@number='0']")
745
- doc.should have_xpath("#{prefix}/I18N_FOLDERS[@number='0']")
746
- end
747
- end
748
-
749
- describe "with add_data_source" do
750
- before do
751
- artifact("org.postgresql:postgresql:jar:9.not-a-version") { |task| write task.name }
752
- @foo = define "foo" do
753
- ipr.add_data_source("Postgres",
754
- :driver => 'org.postgresql.Driver',
755
- :url => "jdbc:postgresql://127.0.0.1:5432/MyDb",
756
- :username => "MyDBUser",
757
- :password => "secreto",
758
- :dialect => "PostgreSQL",
759
- :classpath => ["org.postgresql:postgresql:jar:9.not-a-version"])
760
- end
761
- invoke_generate_task
762
- end
763
-
764
- it "generates a data source manager with specified data source" do
765
- doc = xml_document(@foo._("foo.ipr"))
766
- prefix_xpath = "/project/component[@name='DataSourceManagerImpl', @format='xml', @hash='3208837817']/data-source"
767
- doc.should have_nodes(prefix_xpath, 1)
768
- ds_path = "#{prefix_xpath}[@source='LOCAL', @name='Postgres']"
769
- doc.should have_xpath(ds_path)
770
- doc.should have_xpath("#{ds_path}/synchronize/text() = 'true'")
771
- doc.should have_xpath("#{ds_path}/jdbc-driver/text() = 'org.postgresql.Driver'")
772
- doc.should have_xpath("#{ds_path}/jdbc-url/text() = 'jdbc:postgresql://127.0.0.1:5432/MyDb'")
773
- doc.should have_xpath("#{ds_path}/user-name/text() = 'MyDBUser'")
774
- doc.should have_xpath("#{ds_path}/user-password/text() = 'dfd9dfcfdfc9dfd8dfcfdfdedfc5'")
775
- doc.should have_xpath("#{ds_path}/default-dialect/text() = 'PostgreSQL'")
776
- doc.should have_xpath("#{ds_path}/libraries/library/url/text() = '$MAVEN_REPOSITORY$/org/postgresql/postgresql/9.not-a-version/postgresql-9.not-a-version.jar'")
777
- end
778
- end
779
-
780
- describe "with add_postgres_data_source" do
781
- before do
782
- ENV["USER"] = "Bob"
783
- artifact("org.postgresql:postgresql:jar:9.2-1003-jdbc4") { |task| write task.name }
784
- @foo = define "foo" do
785
- ipr.add_postgres_data_source("Postgres", :database => 'MyDb')
786
- end
787
- invoke_generate_task
788
- end
789
-
790
- it "generates a data source manager with specified data source" do
791
- doc = xml_document(@foo._("foo.ipr"))
792
- prefix_xpath = "/project/component[@name='DataSourceManagerImpl', @format='xml', @hash='3208837817']/data-source"
793
- doc.should have_nodes(prefix_xpath, 1)
794
- ds_path = "#{prefix_xpath}[@source='LOCAL', @name='Postgres']"
795
- doc.should have_xpath(ds_path)
796
- doc.should have_xpath("#{ds_path}/synchronize/text() = 'true'")
797
- doc.should have_xpath("#{ds_path}/jdbc-driver/text() = 'org.postgresql.Driver'")
798
- doc.should have_xpath("#{ds_path}/jdbc-url/text() = 'jdbc:postgresql://127.0.0.1:5432/MyDb'")
799
- doc.should have_xpath("#{ds_path}/user-name/text() = 'Bob'")
800
- doc.should have_xpath("#{ds_path}/default-dialect/text() = 'PostgreSQL'")
801
- doc.should have_xpath("#{ds_path}/libraries/library/url/text() = '$MAVEN_REPOSITORY$/org/postgresql/postgresql/9.2-1003-jdbc4/postgresql-9.2-1003-jdbc4.jar'")
802
- end
803
- end
804
-
805
- describe "with add_sql_server_data_source" do
806
- before do
807
- ENV["USER"] = "Bob"
808
- artifact('net.sourceforge.jtds:jtds:jar:1.2.7') { |task| write task.name }
809
- @foo = define "foo" do
810
- ipr.add_sql_server_data_source("SqlServer", :database => 'MyDb')
811
- end
812
- invoke_generate_task
813
- end
814
-
815
- it "generates a data source manager with specified data source" do
816
- doc = xml_document(@foo._("foo.ipr"))
817
- prefix_xpath = "/project/component[@name='DataSourceManagerImpl', @format='xml', @hash='3208837817']/data-source"
818
- doc.should have_nodes(prefix_xpath, 1)
819
- ds_path = "#{prefix_xpath}[@source='LOCAL', @name='SqlServer']"
820
- doc.should have_xpath(ds_path)
821
-
822
- doc.should have_xpath("#{ds_path}/synchronize/text() = 'true'")
823
- doc.should have_xpath("#{ds_path}/jdbc-driver/text() = 'net.sourceforge.jtds.jdbc.Driver'")
824
- doc.should have_xpath("#{ds_path}/jdbc-url/text() = 'jdbc:jtds:sqlserver://127.0.0.1:1433/MyDb'")
825
- doc.should have_xpath("#{ds_path}/user-name/text() = 'Bob'")
826
- doc.should have_xpath("#{ds_path}/default-dialect/text() = 'TSQL'")
827
- doc.should have_xpath("#{ds_path}/libraries/library/url/text() = '$MAVEN_REPOSITORY$/net/sourceforge/jtds/1.2.7/jtds-1.2.7.jar'")
828
- end
829
- end
830
-
831
- describe "with artifacts added to root project" do
832
- before do
833
- @foo = define "foo" do
834
- ipr.add_artifact("MyFancy.jar", "jar") do |xml|
835
- xml.tag!('output-path', project._(:artifacts, "MyFancy.jar"))
836
- xml.element :id => "module-output", :name => "foo"
837
- end
838
- ipr.add_artifact("MyOtherFancy.jar", "jar") do |xml|
839
- xml.tag!('output-path', project._(:artifacts, "MyOtherFancy.jar"))
840
- xml.element :id => "module-output", :name => "foo"
841
- end
842
- end
843
- invoke_generate_task
844
- end
845
-
846
- it "generates an IPR with multiple jar artifacts" do
847
- doc = xml_document(@foo._("foo.ipr"))
848
- facet_xpath = "/project/component[@name='ArtifactManager']/artifact"
849
- doc.should have_nodes(facet_xpath, 2)
850
- doc.should have_xpath("#{facet_xpath}[@type='jar', @name='MyFancy.jar']")
851
- doc.should have_xpath("#{facet_xpath}[@type='jar', @name='MyOtherFancy.jar']")
852
- end
853
- end
854
-
855
- describe "that uses add_jar_artifact with no overrides" do
856
- before do
857
- write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
858
- artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
859
-
860
- @foo = define "foo" do
861
- project.version = '1.0'
862
- define "bar" do
863
- compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
864
- package :war
865
- end
866
- ipr.add_jar_artifact(project("bar"))
867
- end
868
- invoke_generate_task
869
- end
870
-
871
- it "generates an IPR with a jar artifact" do
872
- doc = xml_document(@foo._("foo.ipr"))
873
- base_xpath = "/project/component[@name='ArtifactManager']/artifact"
874
- facet_xpath = "#{base_xpath}[@type='jar' and @name='bar.jar' and @build-on-make='false']"
875
- doc.should have_xpath(facet_xpath)
876
-
877
- doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
878
- doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='module-output' and @name='bar']")
879
- end
880
- end
881
-
882
- describe "that uses add_jar_artifact with overrides" do
883
- before do
884
- write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
885
- artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
886
-
887
- @foo = define "foo" do
888
- project.version = '1.0'
889
- define "bar" do
890
- compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
891
- package :war
892
- end
893
- ipr.add_jar_artifact(project,
894
- :name => 'bar',
895
- :output_dir => _('bink'),
896
- :build_on_make => true,
897
- :ejb_module_names => ['x'],
898
- :jpa_module_names => ['p'],
899
- :dependencies => [project('bar')])
900
- end
901
- invoke_generate_task
902
- end
903
-
904
- it "generates an IPR with a jar artifact" do
905
- doc = xml_document(@foo._("foo.ipr"))
906
- base_xpath = "/project/component[@name='ArtifactManager']/artifact"
907
- facet_xpath = "#{base_xpath}[@type='jar' and @name='bar.jar' and @build-on-make='true']"
908
- doc.should have_xpath(facet_xpath)
909
-
910
- doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/bink")
911
- doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='module-output' and @name='bar']")
912
- doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='jpa-descriptors' and @facet='p/jpa/JPA']")
913
- doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='javaee-facet-resources' and @facet='x/ejb/EJB']")
914
- end
915
- end
916
-
917
- describe "that uses add_exploded_ejb_artifact with overrides" do
918
- before do
919
- write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
920
- artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
921
-
922
- @foo = define "foo" do
923
- project.version = '1.0'
924
- define "bar" do
925
- compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
926
- package :jar
927
- end
928
- ipr.add_exploded_ejb_artifact(project("bar"),
929
- :ejb_module_names => ['x'],
930
- :jpa_module_names => ['p'])
931
- end
932
- invoke_generate_task
933
- end
934
-
935
- it "generates an IPR with an ejb artifact" do
936
- doc = xml_document(@foo._("foo.ipr"))
937
- base_xpath = "/project/component[@name='ArtifactManager']/artifact"
938
- facet_xpath = "#{base_xpath}[@type='exploded-ejb' and @name='bar' and @build-on-make='false']"
939
- doc.should have_xpath(facet_xpath)
940
- doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
941
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='module-output' and @name='bar']")
942
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='jpa-descriptors' and @facet='p/jpa/JPA']")
943
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='x/ejb/EJB']")
944
- end
945
- end
946
-
947
- describe "that uses add_exploded_ejb_artifact with no overrides" do
948
- before do
949
- write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
950
- artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
951
-
952
- @foo = define "foo" do
953
- project.version = '1.0'
954
- define "bar" do
955
- compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
956
- package :war
957
- end
958
- ipr.add_exploded_ejb_artifact(project("bar"))
959
- end
960
- invoke_generate_task
961
- end
962
-
963
- it "generates an IPR with an ejb artifact" do
964
- doc = xml_document(@foo._("foo.ipr"))
965
- base_xpath = "/project/component[@name='ArtifactManager']/artifact"
966
- facet_xpath = "#{base_xpath}[@type='exploded-ejb' and @name='bar' and @build-on-make='false']"
967
- doc.should have_xpath(facet_xpath)
968
-
969
- doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
970
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='module-output' and @name='bar']")
971
- end
972
- end
973
-
974
-
975
- describe "that uses add_exploded_war_artifact with no overrides" do
976
- before do
977
- write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
978
- artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
979
-
980
- @foo = define "foo" do
981
- project.version = '1.0'
982
- define "bar" do
983
- compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
984
- package :war
985
- end
986
- ipr.add_exploded_war_artifact(project("bar"))
987
- end
988
- invoke_generate_task
989
- end
990
-
991
- it "generates an IPR with a war artifact" do
992
- doc = xml_document(@foo._("foo.ipr"))
993
- base_xpath = "/project/component[@name='ArtifactManager']/artifact"
994
- facet_xpath = "#{base_xpath}[@type='exploded-war' and @name='bar' and @build-on-make='false']"
995
- doc.should have_xpath(facet_xpath)
996
-
997
- doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
998
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory', @name='classes']/element[@id='module-output' and @name='bar']")
999
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory', @name='lib']/element[@id='file-copy' and @path='$MAVEN_REPOSITORY$/net/sourceforge/jtds/jtds/1.2.7.XX/jtds-1.2.7.XX.jar']")
1000
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='bar/web/Web']")
1001
- end
1002
- end
1003
-
1004
- describe "that uses add_exploded_war_artifact with overrides" do
1005
- before do
1006
- write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
1007
- artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
1008
-
1009
- @foo = define "foo" do
1010
- project.version = '1.0'
1011
- define "bar" do
1012
- compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
1013
- package :war
1014
- end
1015
- ipr.add_exploded_war_artifact(project,
1016
- :name => 'gar',
1017
- :war_module_names => ['x','y'],
1018
- :gwt_module_names => ['p','q'],
1019
- :artifacts => ['baz','biz'],
1020
- :dependencies => ['net.sourceforge.jtds:jtds:jar:1.2.7.XX', project('bar')])
1021
- end
1022
- invoke_generate_task
1023
- end
1024
-
1025
- it "generates an IPR with a war artifact" do
1026
- doc = xml_document(@foo._("foo.ipr"))
1027
- base_xpath = "/project/component[@name='ArtifactManager']/artifact"
1028
- facet_xpath = "#{base_xpath}[@type='exploded-war' @name='MyFancy.jar', @build-on-make='false']"
1029
- doc.should have_xpath(facet_xpath)
1030
-
1031
- doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/gar")
1032
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory', @name='classes']/element[@id='module-output' and @name='bar']")
1033
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory', @name='lib']/element[@id='file-copy' and @path='$MAVEN_REPOSITORY$/net/sourceforge/jtds/jtds/1.2.7.XX/jtds-1.2.7.XX.jar']")
1034
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='x/web/Web']")
1035
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='y/web/Web']")
1036
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='gwt-compiler-output' and @facet='p/gwt/GWT']")
1037
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='gwt-compiler-output' and @facet='q/gwt/GWT']")
1038
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory', @name='lib']/element[@id='artifact' and @artifact-name='baz.jar']")
1039
- doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory', @name='lib']/element[@id='artifact' and @artifact-name='biz.jar']")
1040
- end
1041
- end
1042
-
1043
- describe "with configurations added to root project" do
1044
- before do
1045
- @foo = define "foo" do
1046
- ipr.add_configuration("Run Contacts.html", "GWT.ConfigurationType", "GWT Configuration") do |xml|
1047
- xml.module(:name => project.iml.id)
1048
- xml.option(:name => "RUN_PAGE", :value => "Contacts.html")
1049
- xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
1050
- xml.option(:name => "compilerMaxHeapSize", :value => "512")
1051
-
1052
- xml.RunnerSettings(:RunnerId => "Run")
1053
- xml.ConfigurationWrapper(:RunnerId => "Run")
1054
- xml.tag! :method
1055
- end
1056
- ipr.add_configuration("Run Planner.html", "GWT.ConfigurationType", "GWT Configuration") do |xml|
1057
- xml.module(:name => project.iml.id)
1058
- xml.option(:name => "RUN_PAGE", :value => "Planner.html")
1059
- xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
1060
- xml.option(:name => "compilerMaxHeapSize", :value => "512")
1061
-
1062
- xml.RunnerSettings(:RunnerId => "Run")
1063
- xml.ConfigurationWrapper(:RunnerId => "Run")
1064
- xml.tag! :method
1065
- end
1066
- end
1067
- invoke_generate_task
1068
- end
1069
-
1070
- it "generates an IPR with multiple configurations" do
1071
- doc = xml_document(@foo._("foo.ipr"))
1072
- facet_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
1073
- doc.should have_nodes(facet_xpath, 2)
1074
- doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType', @name='Run Contacts.html']")
1075
- doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType', @name='Run Planner.html']")
1076
- end
1077
- end
1078
-
1079
- describe "with default configuration added to root project" do
1080
- before do
1081
- @foo = define "foo" do
1082
- ipr.add_default_configuration("GWT.ConfigurationType", "GWT Configuration") do |xml|
1083
- xml.module(:name => project.iml.id)
1084
- xml.option(:name => "RUN_PAGE", :value => "Planner.html")
1085
- xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
1086
- xml.option(:name => "compilerMaxHeapSize", :value => "512")
1087
-
1088
- xml.RunnerSettings(:RunnerId => "Run")
1089
- xml.ConfigurationWrapper(:RunnerId => "Run")
1090
- xml.tag! :method
1091
- end
1092
- end
1093
- invoke_generate_task
1094
- end
1095
-
1096
- it "generates an IPR with default configuration" do
1097
- doc = xml_document(@foo._("foo.ipr"))
1098
- facet_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
1099
- doc.should have_nodes(facet_xpath, 1)
1100
- doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType' AND @factoryName='GWT Configuration' AND @default='true']")
1101
- end
1102
- end
1103
-
1104
- describe "with iml.group specified" do
1105
- before do
1106
- @foo = define "foo" do
1107
- iml.group = true
1108
- define 'bar' do
1109
- define 'baz' do
1110
-
1111
- end
1112
- end
1113
- define 'rab' do
1114
- iml.group = "MyGroup"
1115
- end
1116
- end
1117
- invoke_generate_task
1118
- end
1119
-
1120
- it "generate an IPR with correct group references" do
1121
- doc = xml_document(@foo._("foo.ipr"))
1122
- doc.should have_nodes("#{xpath_to_module}", 4)
1123
- module_ref = "$PROJECT_DIR$/foo.iml"
1124
- doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
1125
- module_ref = "$PROJECT_DIR$/rab/rab.iml"
1126
- doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}' @group = 'MyGroup']")
1127
- module_ref = "$PROJECT_DIR$/bar/bar.iml"
1128
- doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}' @group = 'foo']")
1129
- module_ref = "$PROJECT_DIR$/bar/baz/baz.iml"
1130
- doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}' @group = 'foo/bar']")
1131
- end
1132
- end
1133
-
1134
- describe "with a single project definition" do
1135
- describe "and default naming" do
1136
- before do
1137
- @foo = define "foo"
1138
- invoke_generate_task
1139
- end
1140
-
1141
- it "generates a single IPR" do
1142
- Dir[@foo._("**/*.ipr")].should have(1).entry
1143
- end
1144
-
1145
- it "generate an IPR in the root directory" do
1146
- File.should be_exist(@foo._("foo.ipr"))
1147
- end
1148
-
1149
- it "generates a single IML" do
1150
- Dir[@foo._("**/*.iml")].should have(1).entry
1151
- end
1152
-
1153
- it "generates an IML in the root directory" do
1154
- File.should be_exist(@foo._("foo.iml"))
1155
- end
1156
-
1157
- it "generate an IPR with the reference to correct module file" do
1158
- File.should be_exist(@foo._("foo.ipr"))
1159
- doc = xml_document(@foo._("foo.ipr"))
1160
- module_ref = "$PROJECT_DIR$/foo.iml"
1161
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
1162
- end
1163
- end
1164
-
1165
- describe "with no_iml generation disabled" do
1166
- before do
1167
- @foo = define "foo" do
1168
- project.no_iml
1169
- end
1170
- invoke_generate_task
1171
- end
1172
-
1173
- it "generates no IML" do
1174
- Dir[@foo._("**/*.iml")].should have(0).entry
1175
- end
1176
-
1177
- it "generate an IPR with no references" do
1178
- File.should be_exist(@foo._("foo.ipr"))
1179
- doc = xml_document(@foo._("foo.ipr"))
1180
- doc.should have_nodes("#{xpath_to_module}", 0)
1181
- end
1182
- end
1183
-
1184
- describe "with ipr generation disabled" do
1185
- before do
1186
- @foo = define "foo" do
1187
- project.no_ipr
1188
- end
1189
- invoke_generate_task
1190
- end
1191
-
1192
- it "generates a single IML" do
1193
- Dir[@foo._("**/*.iml")].should have(1).entry
1194
- end
1195
-
1196
- it "generate no IPR" do
1197
- File.should_not be_exist(@foo._("foo.ipr"))
1198
- end
1199
- end
1200
-
1201
- describe "and id overrides" do
1202
- before do
1203
- @foo = define "foo" do
1204
- ipr.id = 'fooble'
1205
- iml.id = 'feap'
1206
- define "bar" do
1207
- iml.id = "baz"
1208
- end
1209
- end
1210
- invoke_generate_task
1211
- end
1212
-
1213
- it "generate an IPR in the root directory" do
1214
- File.should be_exist(@foo._("fooble.ipr"))
1215
- end
1216
-
1217
- it "generates an IML in the root directory" do
1218
- File.should be_exist(@foo._("feap.iml"))
1219
- end
1220
-
1221
- it "generates an IML in the subproject directory" do
1222
- File.should be_exist(@foo._("bar/baz.iml"))
1223
- end
1224
-
1225
- it "generate an IPR with the reference to correct module file" do
1226
- File.should be_exist(@foo._("fooble.ipr"))
1227
- doc = xml_document(@foo._("fooble.ipr"))
1228
- module_ref = "$PROJECT_DIR$/feap.iml"
1229
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
1230
- end
1231
- end
1232
-
1233
- describe "and a suffix defined" do
1234
- before do
1235
- @foo = define "foo" do
1236
- ipr.suffix = '-ipr-suffix'
1237
- iml.suffix = '-iml-suffix'
1238
- end
1239
- invoke_generate_task
1240
- end
1241
-
1242
- it "generate an IPR in the root directory" do
1243
- File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
1244
- end
1245
-
1246
- it "generates an IML in the root directory" do
1247
- File.should be_exist(@foo._("foo-iml-suffix.iml"))
1248
- end
1249
-
1250
- it "generate an IPR with the reference to correct module file" do
1251
- File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
1252
- doc = xml_document(@foo._("foo-ipr-suffix.ipr"))
1253
- doc.should have_nodes("#{xpath_to_module}", 1)
1254
- module_ref = "$PROJECT_DIR$/foo-iml-suffix.iml"
1255
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
1256
- end
1257
- end
1258
- end
1259
-
1260
- describe "with a subproject" do
1261
- before do
1262
- @foo = define "foo" do
1263
- define 'bar'
1264
- end
1265
- invoke_generate_task
1266
- end
1267
-
1268
- it "creates the subproject directory" do
1269
- File.should be_exist(@foo._("bar"))
1270
- end
1271
-
1272
- it "generates an IML in the subproject directory" do
1273
- File.should be_exist(@foo._("bar/bar.iml"))
1274
- end
1275
-
1276
- it "generate an IPR with the reference to correct module file" do
1277
- File.should be_exist(@foo._("foo.ipr"))
1278
- doc = xml_document(@foo._("foo.ipr"))
1279
- doc.should have_nodes("#{xpath_to_module}", 2)
1280
- module_ref = "$PROJECT_DIR$/foo.iml"
1281
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
1282
- module_ref = "$PROJECT_DIR$/bar/bar.iml"
1283
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
1284
- end
1285
- end
1286
-
1287
- describe "with base_dir specified" do
1288
- before do
1289
- @foo = define "foo" do
1290
- define('bar', :base_dir => 'fe') do
1291
- define('baz', :base_dir => 'fi') do
1292
- define('foe')
1293
- end
1294
- define('fum')
1295
- end
1296
- end
1297
- invoke_generate_task
1298
- end
1299
-
1300
- it "generates a subproject IML in the specified directory" do
1301
- File.should be_exist(@foo._("fe/bar.iml"))
1302
- end
1303
-
1304
- it "generates a sub-subproject IML in the specified directory" do
1305
- File.should be_exist(@foo._("fi/baz.iml"))
1306
- end
1307
-
1308
- it "generates a sub-sub-subproject IML that inherits the specified directory" do
1309
- File.should be_exist(@foo._("fi/foe/foe.iml"))
1310
- end
1311
-
1312
- it "generates a sub-subproject IML that inherits the specified directory" do
1313
- File.should be_exist(@foo._("fe/fum/fum.iml"))
1314
- end
1315
-
1316
- it "generate an IPR with the references to correct module files" do
1317
- doc = xml_document(@foo._("foo.ipr"))
1318
- doc.should have_nodes("#{xpath_to_module}", 5)
1319
- ["foo.iml", "fe/bar.iml", "fi/baz.iml", "fi/foe/foe.iml", "fe/fum/fum.iml"].each do |module_ref|
1320
- doc.should have_nodes("#{xpath_to_module}[@fileurl='file://$PROJECT_DIR$/#{module_ref}', @filepath='$PROJECT_DIR$/#{module_ref}']", 1)
1321
- end
1322
- end
1323
- end
1324
-
1325
- describe "with extensive intermodule dependencies" do
1326
- before do
1327
- mkdir_p 'foo/src/main/resources'
1328
- mkdir_p 'foo/src/main/java/foo'
1329
- touch 'foo/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
1330
- artifact('group:id:jar:1.0') { |t| write t.to_s }
1331
- define "root" do
1332
- repositories.remote << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/'
1333
- project.version = "2.5.2"
1334
- define 'foo' do
1335
- resources.from _(:source, :main, :resources)
1336
- compile.with 'group:id:jar:1.0'
1337
- test.using(:junit)
1338
- package(:jar)
1339
- end
1340
-
1341
- define 'bar' do
1342
- # internally transitive dependencies on foo, both runtime and test
1343
- compile.with project('root:foo'), project('root:foo').compile.dependencies
1344
- test.using(:junit).with [project('root:foo').test.compile.target,
1345
- project('root:foo').test.resources.target,
1346
- project('root:foo').test.compile.dependencies].compact
1347
- package(:jar)
1348
- end
1349
- end
1350
-
1351
- invoke_generate_task
1352
- @bar_iml = xml_document(project('root:bar')._('bar.iml'))
1353
- @bar_lib_urls = @bar_iml.get_elements("//orderEntry[@type='module-library']/library/CLASSES/root").collect do |root|
1354
- root.attribute('url').to_s
1355
- end
1356
- end
1357
-
1358
- it "depends on the associated module exactly once" do
1359
- @bar_iml.should have_nodes("//orderEntry[@type='module', @module-name='foo', @exported=""]", 1)
1360
- end
1361
-
1362
- it "does not depend on the other project's packaged JAR" do
1363
- @bar_lib_urls.grep(%r{#{project('root:foo').packages.first}}).should == []
1364
- end
1365
-
1366
- it "does not depend on the the other project's target/classes directory" do
1367
- @bar_lib_urls.grep(%r{foo/target/classes}).should == []
1368
- end
1369
-
1370
- it "does not depend on the the other project's target/resources directory" do
1371
- @bar_lib_urls.grep(%r{file://\$MODULE_DIR\$/../foo/target/resources}).size.should == 0
1372
- end
1373
- end
1374
-
1375
- describe "with a single project definition" do
1376
- before do
1377
- @foo = define "foo"
1378
- end
1379
-
1380
- it "informs the user about generating IPR" do
1381
- lambda { invoke_generate_task }.should show_info(/Writing (.+)\/foo\.ipr/)
1382
- end
1383
-
1384
- it "informs the user about generating IML" do
1385
- lambda { invoke_generate_task }.should show_info(/Writing (.+)\/foo\.iml/)
1386
- end
1387
- end
1388
- describe "with a subproject" do
1389
- before do
1390
- @foo = define "foo" do
1391
- define 'bar'
1392
- end
1393
- end
1394
-
1395
- it "informs the user about generating subporoject IML" do
1396
- lambda { invoke_generate_task }.should show_info(/Writing (.+)\/bar\/bar\.iml/)
1397
- end
1398
- end
1399
-
1400
- describe "with compile.options.source = '1.6'" do
1401
-
1402
- before do
1403
- @foo = define "foo" do
1404
- compile.options.source = '1.5'
1405
- end
1406
- invoke_generate_task
1407
- end
1408
-
1409
- it "generate an ProjectRootManager with 1.5 jdk specified" do
1410
- #raise File.read(@foo._("foo.ipr"))
1411
- xml_document(@foo._("foo.ipr")).
1412
- should have_xpath("/project/component[@name='ProjectRootManager' and @project-jdk-name = '1.5' and @languageLevel = 'JDK_1_5']")
1413
- end
1414
-
1415
- it "generates a ProjectDetails component with the projectName option set" do
1416
- xml_document(@foo._("foo.ipr")).
1417
- should have_xpath("/project/component[@name='ProjectDetails']/option[@name = 'projectName' and @value = 'foo']")
1418
- end
1419
- end
1420
-
1421
- describe "with compile.options.source = '1.6'" do
1422
- before do
1423
- @foo = define "foo" do
1424
- compile.options.source = '1.6'
1425
- end
1426
- invoke_generate_task
1427
- end
1428
-
1429
- it "generate an ProjectRootManager with 1.6 jdk specified" do
1430
- xml_document(@foo._("foo.ipr")).
1431
- should have_xpath("/project/component[@name='ProjectRootManager' and @project-jdk-name = '1.6' and @languageLevel = 'JDK_1_6']")
1432
- end
1433
- end
1434
-
1435
- describe "with iml.skip_content! specified" do
1436
- before do
1437
- @foo = define "foo" do
1438
- iml.skip_content!
1439
- end
1440
- invoke_generate_task
1441
- end
1442
-
1443
- it "generate an IML with no content section" do
1444
- doc = xml_document(@foo._(root_module_filename(@foo)))
1445
- doc.should_not have_xpath("/module/component[@name='NewModuleRootManager']/content")
1446
- end
1447
- end
1448
-
1449
- describe "with iml.skip_content! not specified and standard layout" do
1450
- before do
1451
- @foo = define "foo" do
1452
- end
1453
- invoke_generate_task
1454
- end
1455
-
1456
- it "generate an IML with content section" do
1457
- root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content")
1458
- end
1459
-
1460
- it "generate an exclude in content section for reports" do
1461
- root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
1462
- end
1463
-
1464
- it "generate an exclude in content section for target" do
1465
- root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
1466
- end
1467
- end
1468
-
1469
- describe "with subprojects" do
1470
- before do
1471
- @foo = define "foo" do
1472
- define "bar" do
1473
- compile.from _(:source, :main, :bar)
1474
- end
1475
- end
1476
- invoke_generate_task
1477
- @bar_doc = xml_document(project('foo:bar')._('bar.iml'))
1478
- end
1479
-
1480
- it "generates the correct source directories" do
1481
- @bar_doc.should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/main/bar']")
1482
- end
1483
-
1484
- it "generates the correct exclude directories" do
1485
- @bar_doc.should have_xpath("//content/excludeFolder[@url='file://$MODULE_DIR$/target']")
1486
- end
1487
- end
1488
-
1489
- describe "with overrides" do
1490
- before do
1491
- @foo = define "foo" do
1492
- compile.from _(:source, :main, :bar)
1493
- iml.main_source_directories << _(:source, :main, :baz)
1494
- iml.test_source_directories << _(:source, :test, :foo)
1495
- end
1496
- invoke_generate_task
1497
- end
1498
-
1499
- it "generates the correct main source directories" do
1500
- root_module_xml(@foo).should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/main/baz' and @isTestSource='false']")
1501
- end
1502
-
1503
- it "generates the correct test source directories" do
1504
- root_module_xml(@foo).should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/test/foo' and @isTestSource='true']")
1505
- end
1506
- end
1507
-
1508
- describe "with report dir outside content" do
1509
- before do
1510
- layout = Layout::Default.new
1511
- layout[:reports] = "../reports"
1512
-
1513
- @foo = define "foo", :layout => layout do
1514
- end
1515
- invoke_generate_task
1516
- end
1517
-
1518
- it "generate an exclude in content section for target" do
1519
- root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
1520
- end
1521
-
1522
- it "generates an content section without an exclude for report dir" do
1523
- root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
1524
- end
1525
- end
1526
-
1527
- describe "with target dir outside content" do
1528
- before do
1529
- layout = Layout::Default.new
1530
- layout[:target] = "../target"
1531
- layout[:target, :main] = "../target"
1532
-
1533
- @foo = define "foo", :layout => layout do
1534
- end
1535
- invoke_generate_task
1536
- end
1537
-
1538
- it "generate an exclude in content section for reports" do
1539
- root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
1540
- end
1541
-
1542
- it "generates an content section without an exclude for target dir" do
1543
- root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
1544
- end
1545
- end
1546
-
1547
- describe "templates" do
1548
-
1549
- def ipr_template
1550
- return <<PROJECT_XML
1551
- <?xml version="1.0" encoding="UTF-8"?>
1552
- <project version="4">
1553
- <component name="SvnBranchConfigurationManager">
1554
- <option name="mySupportsUserInfoFilter" value="false" />
1555
- </component>
1556
- </project>
1557
- PROJECT_XML
1558
- end
1559
-
1560
- def ipr_existing
1561
- return <<PROJECT_XML
1562
- <?xml version="1.0" encoding="UTF-8"?>
1563
- <project version="4">
1564
- <component name="AntConfiguration">
1565
- <defaultAnt bundledAnt="true" />
1566
- </component>
1567
- <component name="SvnBranchConfigurationManager">
1568
- <option name="mySupportsUserInfoFilter" value="true" />
1569
- </component>
1570
- <component name="ProjectModuleManager">
1571
- <modules>
1572
- <module fileurl="file://$PROJECT_DIR$/existing.iml" filepath="$PROJECT_DIR$/existing.iml" />
1573
- </modules>
1574
- </component>
1575
- </project>
1576
- PROJECT_XML
1577
- end
1578
-
1579
- def ipr_from_template_xpath
1580
- "/project/component[@name='SvnBranchConfigurationManager']/option[@name = 'mySupportsUserInfoFilter' and @value = 'false']"
1581
- end
1582
-
1583
- def ipr_from_existing_xpath
1584
- "/project/component[@name='AntConfiguration']"
1585
- end
1586
-
1587
- def ipr_from_existing_shadowing_template_xpath
1588
- "/project/component[@name='SvnBranchConfigurationManager']/option[@name = 'mySupportsUserInfoFilter' and @value = 'true']"
1589
- end
1590
-
1591
- def ipr_from_existing_shadowing_generated_xpath
1592
- "/project/component[@name='ProjectModuleManager']/modules/module[@fileurl = 'file://$PROJECT_DIR$/existing.iml']"
1593
- end
1594
-
1595
- def ipr_from_generated_xpath
1596
- "/project/component[@name='ProjectModuleManager']/modules/module[@fileurl = 'file://$PROJECT_DIR$/foo.iml']"
1597
- end
1598
-
1599
- def iml_template
1600
- return <<PROJECT_XML
1601
- <?xml version="1.0" encoding="UTF-8"?>
1602
- <module type="JAVA_MODULE" version="4">
1603
- <component name="FacetManager">
1604
- <facet type="JRUBY" name="JRuby">
1605
- <configuration number="0">
1606
- <JRUBY_FACET_CONFIG_ID NAME="JRUBY_SDK_NAME" VALUE="JRuby SDK 1.4.0RC1" />
1607
- </configuration>
1608
- </facet>
1609
- </component>
1610
- </module>
1611
- PROJECT_XML
1612
- end
1613
-
1614
- def iml_existing
1615
- return <<PROJECT_XML
1616
- <?xml version="1.0" encoding="UTF-8"?>
1617
- <module type="JAVA_MODULE" version="4">
1618
- <component name="FunkyPlugin"/>
1619
- <component name="FacetManager">
1620
- <facet type="SCALA" name="Scala"/>
1621
- </component>
1622
- <component name="NewModuleRootManager" inherit-compiler-output="true">
1623
- <exclude-output />
1624
- <content url="file://$MODULE_DIR$"/>
1625
- <orderEntry type="inheritedJdk" />
1626
- <orderEntry type="sourceFolder" forTests="false" />
1627
- <orderEntry type="module" module-name="buildr-bnd" exported="" />
1628
- </component>
1629
- </module>
1630
- PROJECT_XML
1631
- end
1632
-
1633
- def iml_from_template_xpath
1634
- "/module/component[@name='FacetManager']/facet[@type = 'JRUBY']"
1635
- end
1636
-
1637
- def iml_from_existing_xpath
1638
- "/module/component[@name='FunkyPlugin']"
1639
- end
1640
-
1641
- def iml_from_existing_shadowing_template_xpath
1642
- "/module/component[@name='FacetManager']/facet[@type = 'SCALA']"
1643
- end
1644
-
1645
- def iml_from_existing_shadowing_generated_xpath
1646
- "/module/component[@name='NewModuleRootManager']/orderEntry[@module-name = 'buildr-bnd']"
1647
- end
1648
-
1649
- def iml_from_generated_xpath
1650
- "/module/component[@name='NewModuleRootManager']/orderEntry[@type = 'module-library']"
1651
- end
1652
-
1653
- describe "with existing project files" do
1654
- before do
1655
- write "foo.ipr", ipr_existing
1656
- write "foo.iml", iml_existing
1657
- artifact('group:id:jar:1.0') { |t| write t.to_s }
1658
- @foo = define "foo" do
1659
- ipr.template = nil
1660
- iml.template = nil
1661
- compile.with 'group:id:jar:1.0'
1662
- end
1663
- invoke_generate_task
1664
- end
1665
-
1666
- it "replaces ProjectModuleManager component in existing ipr file" do
1667
- xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
1668
- xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_generated_xpath)
1669
- end
1670
-
1671
- it "merges component in existing ipr file" do
1672
- xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_existing_xpath)
1673
- end
1674
-
1675
- def iml_from_generated_xpath
1676
- "/module/component[@name='NewModuleRootManager']/orderEntry[@type = 'module-library']"
1677
- end
1678
-
1679
- it "replaces NewModuleRootManager component in existing iml file" do
1680
- xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
1681
- xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_generated_xpath)
1682
- end
1683
-
1684
- it "merges component in existing iml file" do
1685
- xml_document(@foo._("foo.iml")).should have_xpath(iml_from_existing_xpath)
1686
- end
1687
- end
1688
-
1689
- describe "with an iml template" do
1690
- before do
1691
- write "module.template.iml", iml_template
1692
- artifact('group:id:jar:1.0') { |t| write t.to_s }
1693
- @foo = define "foo" do
1694
- ipr.template = nil
1695
- iml.template = "module.template.iml"
1696
- compile.with 'group:id:jar:1.0'
1697
- end
1698
- invoke_generate_task
1699
- end
1700
-
1701
- it "replaces generated components" do
1702
- xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
1703
- end
1704
-
1705
- it "merges component in iml template" do
1706
- xml_document(@foo._("foo.iml")).should have_xpath(iml_from_template_xpath)
1707
- end
1708
- end
1709
-
1710
- describe "with an iml template and existing iml" do
1711
- before do
1712
- write "module.template.iml", iml_template
1713
- write "foo.iml", iml_existing
1714
- artifact('group:id:jar:1.0') { |t| write t.to_s }
1715
- @foo = define "foo" do
1716
- ipr.template = nil
1717
- iml.template = "module.template.iml"
1718
- compile.with 'group:id:jar:1.0'
1719
- end
1720
- invoke_generate_task
1721
- end
1722
-
1723
- it "replaces generated components" do
1724
- xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
1725
- end
1726
-
1727
- it "merges component in iml template" do
1728
- xml_document(@foo._("foo.iml")).should have_xpath(iml_from_template_xpath)
1729
- end
1730
-
1731
- it "merges components not in iml template and not generated by task" do
1732
- xml_document(@foo._("foo.iml")).should have_xpath(iml_from_existing_xpath)
1733
- xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_template_xpath)
1734
- xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_generated_xpath)
1735
- end
1736
- end
1737
-
1738
- describe "with an ipr template" do
1739
- before do
1740
- write "project.template.iml", ipr_template
1741
- artifact('group:id:jar:1.0') { |t| write t.to_s }
1742
- @foo = define "foo" do
1743
- ipr.template = "project.template.iml"
1744
- iml.template = nil
1745
- compile.with 'group:id:jar:1.0'
1746
- end
1747
- invoke_generate_task
1748
- end
1749
-
1750
- it "replaces generated component in ipr template" do
1751
- xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
1752
- end
1753
-
1754
- it "merges component in ipr template" do
1755
- xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_template_xpath)
1756
- end
1757
- end
1758
-
1759
- describe "with an ipr template and existing ipr" do
1760
- before do
1761
- write "project.template.iml", ipr_template
1762
- write "foo.ipr", ipr_existing
1763
- artifact('group:id:jar:1.0') { |t| write t.to_s }
1764
- @foo = define "foo" do
1765
- ipr.template = "project.template.iml"
1766
- iml.template = nil
1767
- compile.with 'group:id:jar:1.0'
1768
- end
1769
- invoke_generate_task
1770
- end
1771
-
1772
- it "replaces generated component in ipr template" do
1773
- xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
1774
- end
1775
-
1776
- it "merges component in ipr template" do
1777
- xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_template_xpath)
1778
- end
1779
-
1780
- it "merges components not in ipr template and not generated by task" do
1781
- xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_existing_xpath)
1782
- xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_generated_xpath)
1783
- xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_template_xpath)
1784
- end
1785
- end
1786
- end
1787
- end
1788
-
1789
- describe "Buildr::IntellijIdea::IdeaModule" do
1790
-
1791
- describe "with no settings" do
1792
- before do
1793
- @foo = define "foo"
1794
- end
1795
-
1796
- it "has correct default iml.type setting" do
1797
- @foo.iml.type.should == "JAVA_MODULE"
1798
- end
1799
-
1800
- it "has correct default iml.local_repository_env_override setting" do
1801
- @foo.iml.local_repository_env_override.should == "MAVEN_REPOSITORY"
1802
- end
1803
- end
1804
-
1805
- describe "settings inherited in subprojects" do
1806
- before do
1807
- mkdir_p 'bar'
1808
- @foo = define "foo" do
1809
- iml.type = "FOO_MODULE_TYPE"
1810
- define 'bar'
1811
- end
1812
- invoke_generate_task
1813
- end
1814
-
1815
- it "generates root IML with specified type" do
1816
- module_file = root_module_filename(@foo)
1817
- File.should be_exist(module_file)
1818
- File.read(module_file).should =~ /FOO_MODULE_TYPE/
1819
- end
1820
-
1821
- it "generates subproject IML with inherited type" do
1822
- module_file = subproject_module_filename(@foo, "bar")
1823
- File.should be_exist(module_file)
1824
- File.read(module_file).should =~ /FOO_MODULE_TYPE/
1825
- end
1826
-
1827
- end
1828
-
1829
- describe "with local_repository_env_override = nil" do
1830
- if Buildr::Util.win_os?
1831
- describe "base_directory on different drive on windows" do
1832
- before do
1833
- @foo = define "foo", :base_dir => "C:/bar" do
1834
- iml.local_repository_env_override = nil
1835
- end
1836
- end
1837
-
1838
- it "generates relative paths correctly" do
1839
- @foo.iml.send(:resolve_path, "E:/foo").should eql('E:/foo')
1840
- end
1841
- end
1842
-
1843
- describe "base_directory on same drive on windows" do
1844
- before do
1845
- @foo = define "foo", :base_dir => "C:/bar" do
1846
- iml.local_repository_env_override = nil
1847
- end
1848
- end
1849
-
1850
- it "generates relative paths correctly" do
1851
- @foo.iml.send(:resolve_path, "C:/foo").should eql('$MODULE_DIR$/../foo')
1852
- end
1853
- end
1854
- end
1855
- end
1856
- end
1857
-
1858
- describe "project extension" do
1859
- it "provides an 'idea' task" do
1860
- Rake::Task.tasks.detect { |task| task.to_s == "idea" }.should_not be_nil
1861
- end
1862
-
1863
- it "documents the 'idea' task" do
1864
- Rake::Task.tasks.detect { |task| task.to_s == "idea" }.comment.should_not be_nil
1865
- end
1866
-
1867
- it "provides an 'idea:clean' task" do
1868
- Rake::Task.tasks.detect { |task| task.to_s == "idea:clean" }.should_not be_nil
1869
- end
1870
-
1871
- it "documents the 'idea:clean' task" do
1872
- Rake::Task.tasks.detect { |task| task.to_s == "idea:clean" }.comment.should_not be_nil
1873
- end
1874
-
1875
- describe "#no_iml" do
1876
- it "makes #iml? false" do
1877
- @foo = define "foo" do
1878
- project.no_iml
1879
- end
1880
- @foo.iml?.should be_false
1881
- end
1882
- end
1883
-
1884
- describe "#iml" do
1885
- before do
1886
- define "foo" do
1887
- iml.suffix = "-top"
1888
-
1889
- define "bar" do
1890
- iml.suffix = "-mid"
1891
-
1892
- define "baz" do
1893
- end
1894
- end
1895
- end
1896
- end
1897
-
1898
- it "inherits the direct parent's IML settings" do
1899
- project('foo:bar:baz').iml.suffix.should == "-mid"
1900
- end
1901
-
1902
- it "does not modify the parent's IML settings" do
1903
- project('foo').iml.suffix.should == "-top"
1904
- end
1905
-
1906
- it "works even when the parent has no IML" do
1907
- lambda {
1908
- define "a" do
1909
- project.no_iml
1910
- define "b" do
1911
- iml.suffix = "-alone"
1912
- end
1913
- end
1914
- }.should_not raise_error
1915
- end
1916
-
1917
- it "inherits from the first ancestor which has an IML" do
1918
- define "a" do
1919
- iml.suffix = "-a"
1920
- define "b" do
1921
- iml.suffix = "-b"
1922
- define "c" do
1923
- project.no_iml
1924
- define "d" do
1925
- project.no_iml
1926
- define "e" do
1927
- project.no_iml
1928
- define "f" do
1929
- end
1930
- end
1931
- end
1932
- end
1933
- end
1934
- end
1935
-
1936
- project("a:b:c:d:e:f").iml.suffix.should == "-b"
1937
- end
1938
- end
1939
- end
1940
-
1941
- end
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.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'xpath_matchers'))
19
+
20
+ def ensure_facet_xpath(doc, type, name)
21
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
22
+ doc.should have_xpath(facet_xpath)
23
+ web_facet_xpath = "#{facet_xpath}[@type='#{type}' and @name='#{name}']"
24
+ doc.should have_xpath(web_facet_xpath)
25
+ web_facet_xpath
26
+ end
27
+
28
+ describe Buildr::IntellijIdea do
29
+
30
+ def invoke_generate_task
31
+ task('idea').invoke
32
+ end
33
+
34
+ def invoke_clean_task
35
+ task('idea:clean').invoke
36
+ end
37
+
38
+ def root_project_filename(project)
39
+ project._("#{project.name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.ipr")
40
+ end
41
+
42
+ def root_project_xml(project)
43
+ xml_document(root_project_filename(project))
44
+ end
45
+
46
+ def root_module_filename(project)
47
+ project._("#{project.name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.iml")
48
+ end
49
+
50
+ def root_module_xml(project)
51
+ xml_document(root_module_filename(project))
52
+ end
53
+
54
+ def subproject_module_filename(project, sub_project_name)
55
+ project._("#{sub_project_name}/#{sub_project_name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.iml")
56
+ end
57
+
58
+ def subproject_module_xml(project, sub_project_name)
59
+ xml_document(subproject_module_filename(project, sub_project_name))
60
+ end
61
+
62
+ def xml_document(filename)
63
+ File.should be_exist(filename)
64
+ REXML::Document.new(File.read(filename))
65
+ end
66
+
67
+ def xpath_to_module
68
+ "/project/component[@name='ProjectModuleManager']/modules/module"
69
+ end
70
+
71
+ describe "idea:clean" do
72
+ before do
73
+ write "foo.ipr"
74
+ write "foo.iml"
75
+ write "other.ipr"
76
+ write "other.iml"
77
+ mkdir_p 'bar'
78
+ write "bar/bar.iml"
79
+ write "bar/other.ipr"
80
+ write "bar/other.iml"
81
+
82
+ @foo = define "foo" do
83
+ define "bar"
84
+ end
85
+ invoke_clean_task
86
+ end
87
+
88
+ it "should remove the ipr file" do
89
+ File.exists?("foo.ipr").should be_false
90
+ end
91
+
92
+ it "should remove the project iml file" do
93
+ File.exists?("foo.iml").should be_false
94
+ end
95
+
96
+ it "should remove the subproject iml file" do
97
+ File.exists?("foo.iml").should be_false
98
+ end
99
+
100
+ it "should not remove other iml and ipr files" do
101
+ File.exists?("other.ipr").should be_true
102
+ File.exists?("other.iml").should be_true
103
+ File.exists?("bar/other.ipr").should be_true
104
+ File.exists?("bar/other.iml").should be_true
105
+ end
106
+ end
107
+
108
+ describe "idea task" do
109
+
110
+ def order_entry_xpath
111
+ "/module/component[@name='NewModuleRootManager']/orderEntry"
112
+ end
113
+
114
+ describe "with a single dependency" do
115
+ describe "of type compile" do
116
+ before do
117
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
118
+ @foo = define "foo" do
119
+ compile.with 'group:id:jar:1.0'
120
+ end
121
+ invoke_generate_task
122
+ end
123
+
124
+ it "generates one exported 'module-library' orderEntry in IML" do
125
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported='']/library/CLASSES/root", 1)
126
+ end
127
+ end
128
+
129
+ describe "with iml.main_dependencies override" do
130
+ before do
131
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
132
+ @foo = define "foo" do
133
+ iml.main_dependencies << 'group:id:jar:1.0'
134
+ end
135
+ invoke_generate_task
136
+ end
137
+
138
+ it "generates one exported 'module-library' orderEntry in IML" do
139
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @scope='TEST']/library/CLASSES/root", 1)
140
+ end
141
+ end
142
+
143
+ describe "of type test" do
144
+ before do
145
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
146
+ @foo = define "foo" do
147
+ test.with 'group:id:jar:1.0'
148
+ end
149
+ invoke_generate_task
150
+ end
151
+
152
+ it "generates one non-exported test scope 'module-library' orderEntry in IML" do
153
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported]/library/CLASSES/root", 0)
154
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @scope='TEST']/library/CLASSES/root", 1)
155
+ end
156
+ end
157
+
158
+ describe "with iml.test_dependencies override" do
159
+ before do
160
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
161
+ @foo = define "foo" do
162
+ iml.test_dependencies << 'group:id:jar:1.0'
163
+ end
164
+ invoke_generate_task
165
+ end
166
+
167
+ it "generates one non-exported 'module-library' orderEntry in IML" do
168
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported]/library/CLASSES/root", 0)
169
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library']/library/CLASSES/root", 1)
170
+ end
171
+ end
172
+
173
+ describe "with sources artifact present" do
174
+ before do
175
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
176
+ artifact('group:id:jar:sources:1.0') { |t| write t.to_s }
177
+ @foo = define "foo" do
178
+ compile.with 'group:id:jar:1.0'
179
+ end
180
+ invoke_generate_task
181
+ end
182
+
183
+ it "generates 'module-library' orderEntry in IML with SOURCES specified" do
184
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported='']/library/SOURCES/root", 1)
185
+ end
186
+ end
187
+
188
+ describe "with local_repository_env_override set to nil" do
189
+ before do
190
+ Buildr.repositories.instance_eval do
191
+ @local = @remote = @release_to = nil
192
+ end
193
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
194
+ @foo = define "foo" do
195
+ iml.local_repository_env_override = nil
196
+ compile.with 'group:id:jar:1.0'
197
+ end
198
+ invoke_generate_task
199
+ end
200
+
201
+ it "generates orderEntry with absolute path for classes jar" do
202
+ root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
203
+ "jar://$MODULE_DIR$/home/.m2/repository/group/id/1.0/id-1.0.jar!/")
204
+ end
205
+ end
206
+ describe "with local_repository_env_override set to MAVEN_REPOSITORY" do
207
+ before do
208
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
209
+ @foo = define "foo" do
210
+ iml.local_repository_env_override = 'MAVEN_REPOSITORY'
211
+ compile.with 'group:id:jar:1.0'
212
+ end
213
+ invoke_generate_task
214
+ end
215
+
216
+ it "generates orderEntry with absolute path for classes jar" do
217
+ root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
218
+ "jar://$MAVEN_REPOSITORY$/group/id/1.0/id-1.0.jar!/")
219
+ end
220
+ end
221
+ end
222
+
223
+ describe "with multiple dependencies" do
224
+ before do
225
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
226
+ artifact('group:id2:jar:1.0') { |t| write t.to_s }
227
+ @foo = define "foo" do
228
+ compile.with 'group:id:jar:1.0', 'group:id2:jar:1.0'
229
+ end
230
+ invoke_generate_task
231
+ end
232
+
233
+ it "generates multiple 'module-library' orderEntry in IML" do
234
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library']", 2)
235
+ end
236
+ end
237
+
238
+ describe "with a single non artifact dependency" do
239
+ before do
240
+ @foo = define "foo" do
241
+ filename = _("foo-dep.jar")
242
+ File.open(filename, "wb") { |t| write "Hello" }
243
+ compile.with filename
244
+ end
245
+ invoke_generate_task
246
+ end
247
+
248
+ it "generates one exported 'module-library' orderEntry in IML" do
249
+ root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
250
+ "jar://$MODULE_DIR$/foo-dep.jar!/")
251
+ end
252
+ end
253
+
254
+ describe "with extra_modules specified" do
255
+ before do
256
+ @foo = define "foo" do
257
+ ipr.extra_modules << 'other.iml'
258
+ ipr.extra_modules << 'other_other.iml'
259
+ end
260
+ invoke_generate_task
261
+ end
262
+
263
+ it "generate an IPR with extra modules specified" do
264
+ doc = xml_document(@foo._("foo.ipr"))
265
+ doc.should have_nodes("#{xpath_to_module}", 3)
266
+ module_ref = "$PROJECT_DIR$/foo.iml"
267
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']")
268
+ module_ref = "$PROJECT_DIR$/other.iml"
269
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']")
270
+ module_ref = "$PROJECT_DIR$/other_other.iml"
271
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']")
272
+ end
273
+ end
274
+
275
+ describe "with web and webservice facet added to root project" do
276
+ before do
277
+ @foo = define "foo" do
278
+ iml.add_facet("Web", "web") do |facet|
279
+ facet.configuration do |conf|
280
+ conf.descriptors do |desc|
281
+ desc.deploymentDescriptor :name => 'web.xml',
282
+ :url => "file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml",
283
+ :optional => "false", :version => "2.4"
284
+ end
285
+ conf.webroots do |webroots|
286
+ webroots.root :url => "file://$MODULE_DIR$/src/main/webapp", :relative => "/"
287
+ end
288
+ end
289
+ end
290
+ iml.add_facet("WebServices Client", "WebServicesClient") do |facet|
291
+ facet.configuration "ws.engine" => "Glassfish / JAX-WS 2.X RI / Metro 1.X / JWSDP 2.0"
292
+ end
293
+ define 'bar'
294
+ end
295
+ invoke_generate_task
296
+ end
297
+
298
+ it "generates an IML for root project with a web and webservice facet" do
299
+ doc = xml_document(@foo._("foo.iml"))
300
+ ensure_facet_xpath(doc, 'web', 'Web')
301
+ ensure_facet_xpath(doc, 'WebServicesClient', 'WebServices Client')
302
+ end
303
+ end
304
+
305
+ describe "using add_gwt_facet" do
306
+ before do
307
+ @foo = define "foo" do
308
+ iml.add_gwt_facet("com.biz.MyModule" => true, "com.biz.MyOtherModule" => false)
309
+ end
310
+ invoke_generate_task
311
+ end
312
+
313
+ it "generates a gwt facet with default settings" do
314
+ doc = xml_document(@foo._("foo.iml"))
315
+ facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
316
+ setting_xpath = "#{facet_xpath}/configuration/setting"
317
+ doc.should have_xpath("#{setting_xpath}[@name='gwtSdkUrl', value='file://$GWT_TOOLS$']")
318
+ doc.should have_xpath("#{setting_xpath}[@name='gwtScriptOutputStyle', value='PRETTY']")
319
+ doc.should have_xpath("#{setting_xpath}[@name='compilerParameters', value='-draftCompile -localWorkers 2 -strict']")
320
+ doc.should have_xpath("#{setting_xpath}[@name='compilerParameters', value='-draftCompile -localWorkers 2 -strict']")
321
+ doc.should have_xpath("#{setting_xpath}[@name='compilerMaxHeapSize', value='512']")
322
+ doc.should have_xpath("#{setting_xpath}[@name='webFacet', value='Web']")
323
+ end
324
+
325
+ it "generates a gwt facet with specified modules" do
326
+ doc = xml_document(@foo._("foo.iml"))
327
+ facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
328
+ prefix = "#{facet_xpath}/configuration/packaging/module"
329
+ doc.should have_xpath("#{prefix}[@name='com.biz.MyModule' and @enabled='true']")
330
+ doc.should have_xpath("#{prefix}[@name='com.biz.MyOtherModule' and @enabled='false']")
331
+ end
332
+ end
333
+
334
+ describe "using add_gwt_facet that detects gwt sdk" do
335
+ before do
336
+ artifact('com.google.gwt:gwt-dev:jar:2.5.1-not-a-release') { |task| write task.name }
337
+ @foo = define "foo" do
338
+ compile.with 'com.google.gwt:gwt-dev:jar:2.5.1-not-a-release'
339
+ iml.add_gwt_facet("com.biz.MyModule" => true)
340
+ end
341
+ invoke_generate_task
342
+ end
343
+
344
+ it "generates a gwt facet with detected gwt sdk settings" do
345
+ doc = xml_document(@foo._("foo.iml"))
346
+ facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
347
+ setting_xpath = "#{facet_xpath}/configuration/setting"
348
+ doc.should have_xpath("#{setting_xpath}[@name='gwtSdkType', value='maven']")
349
+ doc.should have_xpath("#{setting_xpath}[@name='gwtSdkUrl', value='$MAVEN_REPOSITORY$/com/google/gwt/gwt-dev/2.5.1-not-a-release']")
350
+ end
351
+ end
352
+
353
+ describe "using add_gwt_facet that specifies gwt sdk" do
354
+ before do
355
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
356
+ @foo = define "foo" do
357
+ iml.add_gwt_facet({"com.biz.MyModule" => true},:gwt_dev_artifact => 'com.example:library:jar:2.0')
358
+ end
359
+ invoke_generate_task
360
+ end
361
+
362
+ it "generates a gwt facet with detected gwt sdk settings" do
363
+ doc = xml_document(@foo._("foo.iml"))
364
+ facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
365
+ setting_xpath = "#{facet_xpath}/configuration/setting"
366
+ doc.should have_xpath("#{setting_xpath}[@name='gwtSdkType', value='maven']")
367
+ doc.should have_xpath("#{setting_xpath}[@name='gwtSdkUrl', value='$MAVEN_REPOSITORY$/com/google/gwt/gwt-dev/2.5.1']")
368
+ end
369
+ end
370
+
371
+ describe "using add_gwt_facet that specifies settings" do
372
+ before do
373
+ @foo = define "foo" do
374
+ iml.add_gwt_facet({"com.biz.MyModule" => true, "com.biz.MyOtherModule" => false},
375
+ :settings => {:gwtScriptOutputStyle => 'OTHER', :compilerMaxHeapSize => 1024, :zang => 'zang'})
376
+ end
377
+ invoke_generate_task
378
+ end
379
+
380
+ it "generates a gwt facet with specified settings" do
381
+ doc = xml_document(@foo._("foo.iml"))
382
+ facet_xpath = ensure_facet_xpath(doc, 'gwt', 'GWT')
383
+ setting_xpath = "#{facet_xpath}/configuration/setting"
384
+ doc.should have_xpath("#{setting_xpath}[@name='zang', value='zang']")
385
+ doc.should have_xpath("#{setting_xpath}[@name='gwtScriptOutputStyle', value='OTHER']")
386
+ doc.should have_xpath("#{setting_xpath}[@name='compilerMaxHeapSize', value='1024']")
387
+ end
388
+ end
389
+
390
+ describe "using add_web_facet with jsf and idea version 12" do
391
+ before do
392
+ write "src/main/webapp/WEB-INF/web.xml"
393
+ write "src/main/webapp/WEB-INF/faces-config.xml"
394
+
395
+ @foo = define "foo" do
396
+ ipr.version = "12"
397
+ iml.add_web_facet
398
+ end
399
+ invoke_generate_task
400
+ end
401
+
402
+ it "generates a web facet with jsf facet auto-detected" do
403
+ doc = xml_document(@foo._("foo.iml"))
404
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
405
+ doc.should have_xpath("#{web_facet_xpath}/facet[@type='jsf' and @name='JSF']")
406
+ end
407
+ end
408
+
409
+ describe "using add_web_facet should default to no jsf" do
410
+ before do
411
+ write "src/main/webapp/WEB-INF/web.xml"
412
+
413
+ @foo = define "foo" do
414
+ iml.add_web_facet
415
+ end
416
+ invoke_generate_task
417
+ end
418
+
419
+ it "does not generate a web facet with jsf facet" do
420
+ doc = xml_document(@foo._("foo.iml"))
421
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
422
+ doc.should_not have_xpath("#{web_facet_xpath}/facet[@type='jsf' and @name='JSF']")
423
+ end
424
+ end
425
+
426
+ describe "using add_web_facet with jsf and idea version 13" do
427
+ before do
428
+ write "src/main/webapp/WEB-INF/web.xml"
429
+ write "src/main/webapp/WEB-INF/faces-config.xml"
430
+
431
+ @foo = define "foo" do
432
+ ipr.version = "13"
433
+ iml.add_web_facet
434
+ end
435
+ invoke_generate_task
436
+ end
437
+
438
+ it "does not generate a web facet with jsf facet" do
439
+ doc = xml_document(@foo._("foo.iml"))
440
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
441
+ doc.should_not have_xpath("#{web_facet_xpath}/facet[@type='jsf' and @name='JSF']")
442
+ end
443
+ end
444
+
445
+ describe "using add_web_facet with jsf and idea version 13 and jsf 'enabled'" do
446
+ before do
447
+ write "src/main/webapp/WEB-INF/web.xml"
448
+ write "src/main/webapp/WEB-INF/faces-config.xml"
449
+
450
+ @foo = define "foo" do
451
+ ipr.version = "13"
452
+ iml.add_web_facet(:enable_jsf => true)
453
+ end
454
+ invoke_generate_task
455
+ end
456
+
457
+ it "does not generate a web facet with jsf facet" do
458
+ doc = xml_document(@foo._("foo.iml"))
459
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
460
+ doc.should_not have_xpath("#{web_facet_xpath}/facet[@type='jsf' and @name='JSF']")
461
+ end
462
+ end
463
+
464
+ describe "using add_web_facet" do
465
+ before do
466
+ write "src/main/webapp/WEB-INF/web.xml"
467
+ write "src/main/webapp/WEB-INF/glassfish-web.xml"
468
+ write "src/main/webapp/WEB-INF/context.xml"
469
+
470
+ @foo = define "foo" do
471
+ iml.add_web_facet
472
+ end
473
+ invoke_generate_task
474
+ end
475
+
476
+ it "generates a web facet with appropriate deployment descriptors" do
477
+ doc = xml_document(@foo._("foo.iml"))
478
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
479
+ deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
480
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='web.xml', url='file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml']")
481
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='glassfish-web.xml', url='file://$MODULE_DIR$/src/main/webapp/WEB-INF/glassfish-web.xml']")
482
+ end
483
+
484
+ it "generates a web facet with derived webroots" do
485
+ doc = xml_document(@foo._("foo.iml"))
486
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
487
+ doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/webapp' and @relative='/']")
488
+ end
489
+ end
490
+
491
+ describe "using add_web_facet with specified parameters" do
492
+ before do
493
+ @foo = define "foo" do
494
+ iml.add_web_facet(:deployment_descriptors => ["src/main/webapp2/WEB-INF/web.xml"],
495
+ :webroots => {"src/main/webapp2" => "/", "src/main/css" => "/css"})
496
+ end
497
+ invoke_generate_task
498
+ end
499
+
500
+ it "generates a web facet with appropriate deployment descriptors" do
501
+ doc = xml_document(@foo._("foo.iml"))
502
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
503
+ deployment_descriptor_xpath = "#{web_facet_xpath}/configuration/descriptors/deploymentDescriptor"
504
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='web.xml', url='file://$MODULE_DIR$/src/main/webapp2/WEB-INF/web.xml']")
505
+ end
506
+
507
+ it "generates a web facet with specified webroots" do
508
+ doc = xml_document(@foo._("foo.iml"))
509
+ web_facet_xpath = ensure_facet_xpath(doc, 'web', 'Web')
510
+ doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/webapp2' and @relative='/']")
511
+ doc.should have_xpath("#{web_facet_xpath}/configuration/webroots/root[@url='file://$MODULE_DIR$/src/main/css' and @relative='/css']")
512
+ end
513
+ end
514
+
515
+ describe "using add_jpa_facet" do
516
+ before do
517
+ write "src/main/resources/META-INF/persistence.xml", "org.hibernate.ejb.HibernatePersistence"
518
+ write "src/main/resources/META-INF/orm.xml"
519
+
520
+ @foo = define "foo" do
521
+ iml.add_jpa_facet
522
+ end
523
+ invoke_generate_task
524
+ end
525
+
526
+ it "generates a jpa facet with appropriate deployment descriptors" do
527
+ doc = xml_document(@foo._("foo.iml"))
528
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
529
+ deployment_descriptor_xpath = "#{facet_xpath}/configuration/deploymentDescriptor"
530
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='persistence.xml', url='file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml']")
531
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='orm.xml', url='file://$MODULE_DIR$/src/main/resources/META-INF/orm.xml']")
532
+ end
533
+
534
+ it "generates a jpa facet with default settings" do
535
+ doc = xml_document(@foo._("foo.iml"))
536
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
537
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled' and @value='true']")
538
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name' and @value='Hibernate']")
539
+ end
540
+ end
541
+
542
+ describe "using add_jpa_facet specifying parameters" do
543
+ before do
544
+ write "src/main/resources2/META-INF/persistence.xml"
545
+ write "src/main/resources2/META-INF/orm.xml"
546
+
547
+ @foo = define "foo" do
548
+ iml.add_jpa_facet(:provider_enabled => 'Hibernate',
549
+ :deployment_descriptors => ["src/main/resources2/META-INF/persistence.xml",
550
+ "src/main/resources2/META-INF/orm.xml"])
551
+ end
552
+ invoke_generate_task
553
+ end
554
+
555
+ it "generates a jpa facet with appropriate deployment descriptors" do
556
+ doc = xml_document(@foo._("foo.iml"))
557
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
558
+ deployment_descriptor_xpath = "#{facet_xpath}/configuration/deploymentDescriptor"
559
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='persistence.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/persistence.xml']")
560
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='orm.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/orm.xml']")
561
+ end
562
+
563
+ it "generates a jpa facet with default settings" do
564
+ doc = xml_document(@foo._("foo.iml"))
565
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
566
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled' and @value='true']")
567
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name' and @value='Hibernate']")
568
+ end
569
+ end
570
+
571
+ describe "using add_jpa_facet derived from main_source_directories" do
572
+ before do
573
+ write "src/main/resources2/META-INF/persistence.xml"
574
+ write "src/main/resources2/META-INF/orm.xml"
575
+
576
+ @foo = define "foo" do
577
+ iml.main_source_directories << "src/main/resources2"
578
+ iml.add_jpa_facet
579
+
580
+ end
581
+ invoke_generate_task
582
+ end
583
+
584
+ it "generates a jpa facet with appropriate deployment descriptors" do
585
+ doc = xml_document(@foo._("foo.iml"))
586
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
587
+ deployment_descriptor_xpath = "#{facet_xpath}/configuration/deploymentDescriptor"
588
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='persistence.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/persistence.xml']")
589
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='orm.xml', url='file://$MODULE_DIR$/src/main/resources2/META-INF/orm.xml']")
590
+ end
591
+ end
592
+
593
+ describe "using add_jpa_facet with hibernate configured in persistence.xml" do
594
+ before do
595
+ write "src/main/resources/META-INF/persistence.xml", "org.hibernate.ejb.HibernatePersistence"
596
+ write "src/main/resources/META-INF/orm.xml"
597
+
598
+ @foo = define "foo" do
599
+ iml.add_jpa_facet
600
+ end
601
+ invoke_generate_task
602
+ end
603
+
604
+ it "generates a jpa facet with default settings" do
605
+ doc = xml_document(@foo._("foo.iml"))
606
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
607
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled' and @value='true']")
608
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name' and @value='Hibernate']")
609
+ end
610
+ end
611
+
612
+ describe "using add_jpa_facet with eclipselink configured in persistence.xml" do
613
+ before do
614
+ write "src/main/resources/META-INF/persistence.xml", "org.eclipse.persistence.jpa.PersistenceProvider"
615
+ write "src/main/resources/META-INF/orm.xml"
616
+
617
+ @foo = define "foo" do
618
+ iml.add_jpa_facet
619
+ end
620
+ invoke_generate_task
621
+ end
622
+
623
+ it "generates a jpa facet with default settings" do
624
+ doc = xml_document(@foo._("foo.iml"))
625
+ facet_xpath = ensure_facet_xpath(doc, 'jpa', 'JPA')
626
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='validation-enabled' and @value='true']")
627
+ doc.should have_xpath("#{facet_xpath}/configuration/setting[@name='provider-name' and @value='EclipseLink']")
628
+ end
629
+ end
630
+
631
+ describe "using add_ejb_facet" do
632
+ before do
633
+ write "src/main/java/com/bin/foo.java"
634
+ write "src/main/resources/WEB-INF/ejb-jar.xml"
635
+
636
+ @foo = define "foo" do
637
+ iml.add_ejb_facet
638
+ end
639
+ invoke_generate_task
640
+ end
641
+
642
+ it "generates an ejb facet with appropriate deployment descriptors" do
643
+ doc = xml_document(@foo._("foo.iml"))
644
+ ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
645
+ deployment_descriptor_xpath = "#{ejb_facet_xpath}/configuration/descriptors/deploymentDescriptor"
646
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/src/main/resources/WEB-INF/ejb-jar.xml']")
647
+ end
648
+
649
+ it "generates an ejb facet with derived ejbRoots" do
650
+ doc = xml_document(@foo._("foo.iml"))
651
+ ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
652
+ doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/src/main/java']")
653
+ doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/src/main/resources']")
654
+ end
655
+ end
656
+
657
+ describe "using add_ejb_facet specifying parameters" do
658
+ before do
659
+ @foo = define "foo" do
660
+ iml.add_ejb_facet(:ejb_roots => ["generated/main/java","generated/main/resources"],
661
+ :deployment_descriptors => ["generated/main/resources/WEB-INF/ejb-jar.xml"])
662
+ end
663
+ invoke_generate_task
664
+ end
665
+
666
+ it "generates an ejb facet with appropriate deployment descriptors" do
667
+ doc = xml_document(@foo._("foo.iml"))
668
+ ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
669
+ deployment_descriptor_xpath = "#{ejb_facet_xpath}/configuration/descriptors/deploymentDescriptor"
670
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/generated/main/resources/WEB-INF/ejb-jar.xml']")
671
+ end
672
+
673
+ it "generates an ejb facet with derived ejbRoots" do
674
+ doc = xml_document(@foo._("foo.iml"))
675
+ ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
676
+ doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/generated/main/java']")
677
+ doc.should have_xpath("#{ejb_facet_xpath}/configuration/ejbRoots/root[@url='file://$MODULE_DIR$/generated/main/resources']")
678
+ end
679
+ end
680
+
681
+ describe "using add_ejb_facet derived from main_source_directories" do
682
+ before do
683
+ write "src/main/resources2/WEB-INF/ejb-jar.xml"
684
+ @foo = define "foo" do
685
+ iml.main_source_directories << "src/main/resources2"
686
+ iml.add_ejb_facet
687
+ end
688
+ invoke_generate_task
689
+ end
690
+
691
+ it "generates an ejb facet with appropriate deployment descriptors" do
692
+ doc = xml_document(@foo._("foo.iml"))
693
+ ejb_facet_xpath = ensure_facet_xpath(doc, 'ejb', 'EJB')
694
+ deployment_descriptor_xpath = "#{ejb_facet_xpath}/configuration/descriptors/deploymentDescriptor"
695
+ doc.should have_xpath("#{deployment_descriptor_xpath}[@name='ejb-jar.xml', url='file://$MODULE_DIR$/src/main/resources2/WEB-INF/ejb-jar.xml']")
696
+ end
697
+ end
698
+
699
+ describe "using add_jruby_facet" do
700
+ before do
701
+
702
+ @foo = define "foo" do
703
+ iml.add_jruby_facet
704
+ end
705
+ invoke_generate_task
706
+ end
707
+
708
+ it "generates a jruby facet with appropriate sdk" do
709
+ doc = xml_document(@foo._("foo.iml"))
710
+ jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
711
+ doc.should have_xpath("#{jruby_facet_xpath}/configuration/JRUBY_FACET_CONFIG_ID[@NAME='JRUBY_SDK_NAME', VALUE='jruby-1.6.7.2']")
712
+ end
713
+
714
+ it "generates a jruby facet with appropriate paths" do
715
+ doc = xml_document(@foo._("foo.iml"))
716
+ jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
717
+ prefix = "#{jruby_facet_xpath}/configuration"
718
+ doc.should have_xpath("#{prefix}/LOAD_PATH[@number='0']")
719
+ doc.should have_xpath("#{prefix}/I18N_FOLDERS[@number='0']")
720
+ end
721
+ end
722
+
723
+ describe "using add_jruby_facet with .ruby-version specified" do
724
+ before do
725
+
726
+ write ".ruby-version", "jruby-1.7.2"
727
+
728
+ @foo = define "foo" do
729
+ iml.add_jruby_facet
730
+ end
731
+ invoke_generate_task
732
+ end
733
+
734
+ it "generates a jruby facet with appropriate sdk" do
735
+ doc = xml_document(@foo._("foo.iml"))
736
+ jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
737
+ doc.should have_xpath("#{jruby_facet_xpath}/configuration/JRUBY_FACET_CONFIG_ID[@NAME='JRUBY_SDK_NAME', VALUE='rbenv: jruby-1.7.2']")
738
+ end
739
+
740
+ it "generates a jruby facet with appropriate paths" do
741
+ doc = xml_document(@foo._("foo.iml"))
742
+ jruby_facet_xpath = ensure_facet_xpath(doc, 'JRUBY', 'JRuby')
743
+ prefix = "#{jruby_facet_xpath}/configuration"
744
+ doc.should have_xpath("#{prefix}/LOAD_PATH[@number='0']")
745
+ doc.should have_xpath("#{prefix}/I18N_FOLDERS[@number='0']")
746
+ end
747
+ end
748
+
749
+ describe "with add_data_source" do
750
+ before do
751
+ artifact("org.postgresql:postgresql:jar:9.not-a-version") { |task| write task.name }
752
+ @foo = define "foo" do
753
+ ipr.add_data_source("Postgres",
754
+ :driver => 'org.postgresql.Driver',
755
+ :url => "jdbc:postgresql://127.0.0.1:5432/MyDb",
756
+ :username => "MyDBUser",
757
+ :password => "secreto",
758
+ :dialect => "PostgreSQL",
759
+ :classpath => ["org.postgresql:postgresql:jar:9.not-a-version"])
760
+ end
761
+ invoke_generate_task
762
+ end
763
+
764
+ it "generates a data source manager with specified data source" do
765
+ doc = xml_document(@foo._("foo.ipr"))
766
+ prefix_xpath = "/project/component[@name='DataSourceManagerImpl' and @format='xml' and @hash='3208837817']/data-source"
767
+ doc.should have_nodes(prefix_xpath, 1)
768
+ ds_path = "#{prefix_xpath}[@source='LOCAL' and @name='Postgres']"
769
+ doc.should have_xpath(ds_path)
770
+ doc.should have_xpath("#{ds_path}/synchronize/text() = 'true'")
771
+ doc.should have_xpath("#{ds_path}/jdbc-driver/text() = 'org.postgresql.Driver'")
772
+ doc.should have_xpath("#{ds_path}/jdbc-url/text() = 'jdbc:postgresql://127.0.0.1:5432/MyDb'")
773
+ doc.should have_xpath("#{ds_path}/user-name/text() = 'MyDBUser'")
774
+ doc.should have_xpath("#{ds_path}/user-password/text() = 'dfd9dfcfdfc9dfd8dfcfdfdedfc5'")
775
+ doc.should have_xpath("#{ds_path}/default-dialect/text() = 'PostgreSQL'")
776
+ doc.should have_xpath("#{ds_path}/libraries/library/url/text() = '$MAVEN_REPOSITORY$/org/postgresql/postgresql/9.not-a-version/postgresql-9.not-a-version.jar'")
777
+ end
778
+ end
779
+
780
+ describe "with add_postgres_data_source" do
781
+ before do
782
+ ENV["USER"] = "Bob"
783
+ artifact("org.postgresql:postgresql:jar:9.2-1003-jdbc4") { |task| write task.name }
784
+ @foo = define "foo" do
785
+ ipr.add_postgres_data_source("Postgres", :database => 'MyDb')
786
+ end
787
+ invoke_generate_task
788
+ end
789
+
790
+ it "generates a data source manager with specified data source" do
791
+ doc = xml_document(@foo._("foo.ipr"))
792
+ prefix_xpath = "/project/component[@name='DataSourceManagerImpl' and @format='xml' and @hash='3208837817']/data-source"
793
+ doc.should have_nodes(prefix_xpath, 1)
794
+ ds_path = "#{prefix_xpath}[@source='LOCAL' and @name='Postgres']"
795
+ doc.should have_xpath(ds_path)
796
+ doc.should have_xpath("#{ds_path}/synchronize/text() = 'true'")
797
+ doc.should have_xpath("#{ds_path}/jdbc-driver/text() = 'org.postgresql.Driver'")
798
+ doc.should have_xpath("#{ds_path}/jdbc-url/text() = 'jdbc:postgresql://127.0.0.1:5432/MyDb'")
799
+ doc.should have_xpath("#{ds_path}/user-name/text() = 'Bob'")
800
+ doc.should have_xpath("#{ds_path}/default-dialect/text() = 'PostgreSQL'")
801
+ doc.should have_xpath("#{ds_path}/libraries/library/url/text() = '$MAVEN_REPOSITORY$/org/postgresql/postgresql/9.2-1003-jdbc4/postgresql-9.2-1003-jdbc4.jar'")
802
+ end
803
+ end
804
+
805
+ describe "with add_sql_server_data_source" do
806
+ before do
807
+ ENV["USER"] = "Bob"
808
+ artifact('net.sourceforge.jtds:jtds:jar:1.2.7') { |task| write task.name }
809
+ @foo = define "foo" do
810
+ ipr.add_sql_server_data_source("SqlServer", :database => 'MyDb')
811
+ end
812
+ invoke_generate_task
813
+ end
814
+
815
+ it "generates a data source manager with specified data source" do
816
+ doc = xml_document(@foo._("foo.ipr"))
817
+ prefix_xpath = "/project/component[@name='DataSourceManagerImpl' and @format='xml' and @hash='3208837817']/data-source"
818
+ doc.should have_nodes(prefix_xpath, 1)
819
+ ds_path = "#{prefix_xpath}[@source='LOCAL' and @name='SqlServer']"
820
+ doc.should have_xpath(ds_path)
821
+
822
+ doc.should have_xpath("#{ds_path}/synchronize/text() = 'true'")
823
+ doc.should have_xpath("#{ds_path}/jdbc-driver/text() = 'net.sourceforge.jtds.jdbc.Driver'")
824
+ doc.should have_xpath("#{ds_path}/jdbc-url/text() = 'jdbc:jtds:sqlserver://127.0.0.1:1433/MyDb'")
825
+ doc.should have_xpath("#{ds_path}/user-name/text() = 'Bob'")
826
+ doc.should have_xpath("#{ds_path}/default-dialect/text() = 'TSQL'")
827
+ doc.should have_xpath("#{ds_path}/libraries/library/url/text() = '$MAVEN_REPOSITORY$/net/sourceforge/jtds/1.2.7/jtds-1.2.7.jar'")
828
+ end
829
+ end
830
+
831
+ describe "with artifacts added to root project" do
832
+ before do
833
+ @foo = define "foo" do
834
+ ipr.add_artifact("MyFancy.jar", "jar") do |xml|
835
+ xml.tag!('output-path', project._(:artifacts, "MyFancy.jar"))
836
+ xml.element :id => "module-output", :name => "foo"
837
+ end
838
+ ipr.add_artifact("MyOtherFancy.jar", "jar") do |xml|
839
+ xml.tag!('output-path', project._(:artifacts, "MyOtherFancy.jar"))
840
+ xml.element :id => "module-output", :name => "foo"
841
+ end
842
+ end
843
+ invoke_generate_task
844
+ end
845
+
846
+ it "generates an IPR with multiple jar artifacts" do
847
+ doc = xml_document(@foo._("foo.ipr"))
848
+ facet_xpath = "/project/component[@name='ArtifactManager']/artifact"
849
+ doc.should have_nodes(facet_xpath, 2)
850
+ doc.should have_xpath("#{facet_xpath}[@type='jar' and @name='MyFancy.jar']")
851
+ doc.should have_xpath("#{facet_xpath}[@type='jar' and @name='MyOtherFancy.jar']")
852
+ end
853
+ end
854
+
855
+ describe "that uses add_jar_artifact with no overrides" do
856
+ before do
857
+ write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
858
+ artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
859
+
860
+ @foo = define "foo" do
861
+ project.version = '1.0'
862
+ define "bar" do
863
+ compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
864
+ package :war
865
+ end
866
+ ipr.add_jar_artifact(project("bar"))
867
+ end
868
+ invoke_generate_task
869
+ end
870
+
871
+ it "generates an IPR with a jar artifact" do
872
+ doc = xml_document(@foo._("foo.ipr"))
873
+ base_xpath = "/project/component[@name='ArtifactManager']/artifact"
874
+ facet_xpath = "#{base_xpath}[@type='jar' and @name='bar.jar' and @build-on-make='false']"
875
+ doc.should have_xpath(facet_xpath)
876
+
877
+ doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
878
+ doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='module-output' and @name='bar']")
879
+ end
880
+ end
881
+
882
+ describe "that uses add_jar_artifact with overrides" do
883
+ before do
884
+ write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
885
+ artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
886
+
887
+ @foo = define "foo" do
888
+ project.version = '1.0'
889
+ define "bar" do
890
+ compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
891
+ package :war
892
+ end
893
+ ipr.add_jar_artifact(project,
894
+ :name => 'bar',
895
+ :output_dir => _('bink'),
896
+ :build_on_make => true,
897
+ :ejb_module_names => ['x'],
898
+ :jpa_module_names => ['p'],
899
+ :dependencies => [project('bar')])
900
+ end
901
+ invoke_generate_task
902
+ end
903
+
904
+ it "generates an IPR with a jar artifact" do
905
+ doc = xml_document(@foo._("foo.ipr"))
906
+ base_xpath = "/project/component[@name='ArtifactManager']/artifact"
907
+ facet_xpath = "#{base_xpath}[@type='jar' and @name='bar.jar' and @build-on-make='true']"
908
+ doc.should have_xpath(facet_xpath)
909
+
910
+ doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/bink")
911
+ doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='module-output' and @name='bar']")
912
+ doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='jpa-descriptors' and @facet='p/jpa/JPA']")
913
+ doc.should have_xpath("#{facet_xpath}/root[@id='archive' and @name='bar.jar']/element[@id='javaee-facet-resources' and @facet='x/ejb/EJB']")
914
+ end
915
+ end
916
+
917
+ describe "that uses add_exploded_ejb_artifact with overrides" do
918
+ before do
919
+ write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
920
+ artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
921
+
922
+ @foo = define "foo" do
923
+ project.version = '1.0'
924
+ define "bar" do
925
+ compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
926
+ package :jar
927
+ end
928
+ ipr.add_exploded_ejb_artifact(project("bar"),
929
+ :ejb_module_names => ['x'],
930
+ :jpa_module_names => ['p'])
931
+ end
932
+ invoke_generate_task
933
+ end
934
+
935
+ it "generates an IPR with an ejb artifact" do
936
+ doc = xml_document(@foo._("foo.ipr"))
937
+ base_xpath = "/project/component[@name='ArtifactManager']/artifact"
938
+ facet_xpath = "#{base_xpath}[@type='exploded-ejb' and @name='bar' and @build-on-make='false']"
939
+ doc.should have_xpath(facet_xpath)
940
+ doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
941
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='module-output' and @name='bar']")
942
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='jpa-descriptors' and @facet='p/jpa/JPA']")
943
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='x/ejb/EJB']")
944
+ end
945
+ end
946
+
947
+ describe "that uses add_exploded_ejb_artifact with no overrides" do
948
+ before do
949
+ write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
950
+ artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
951
+
952
+ @foo = define "foo" do
953
+ project.version = '1.0'
954
+ define "bar" do
955
+ compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
956
+ package :war
957
+ end
958
+ ipr.add_exploded_ejb_artifact(project("bar"))
959
+ end
960
+ invoke_generate_task
961
+ end
962
+
963
+ it "generates an IPR with an ejb artifact" do
964
+ doc = xml_document(@foo._("foo.ipr"))
965
+ base_xpath = "/project/component[@name='ArtifactManager']/artifact"
966
+ facet_xpath = "#{base_xpath}[@type='exploded-ejb' and @name='bar' and @build-on-make='false']"
967
+ doc.should have_xpath(facet_xpath)
968
+
969
+ doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
970
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='module-output' and @name='bar']")
971
+ end
972
+ end
973
+
974
+
975
+ describe "that uses add_exploded_war_artifact with no overrides" do
976
+ before do
977
+ write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
978
+ artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
979
+
980
+ @foo = define "foo" do
981
+ project.version = '1.0'
982
+ define "bar" do
983
+ compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
984
+ package :war
985
+ end
986
+ ipr.add_exploded_war_artifact(project("bar"))
987
+ end
988
+ invoke_generate_task
989
+ end
990
+
991
+ it "generates an IPR with a war artifact" do
992
+ doc = xml_document(@foo._("foo.ipr"))
993
+ base_xpath = "/project/component[@name='ArtifactManager']/artifact"
994
+ facet_xpath = "#{base_xpath}[@type='exploded-war' and @name='bar' and @build-on-make='false']"
995
+ doc.should have_xpath(facet_xpath)
996
+
997
+ doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/bar")
998
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory' and @name='classes']/element[@id='module-output' and @name='bar']")
999
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory' and @name='lib']/element[@id='file-copy' and @path='$MAVEN_REPOSITORY$/net/sourceforge/jtds/jtds/1.2.7.XX/jtds-1.2.7.XX.jar']")
1000
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='bar/web/Web']")
1001
+ end
1002
+ end
1003
+
1004
+ describe "that uses add_exploded_war_artifact with overrides" do
1005
+ before do
1006
+ write 'foo/bar/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
1007
+ artifact('net.sourceforge.jtds:jtds:jar:1.2.7.XX') { |task| write task.name }
1008
+
1009
+ @foo = define "foo" do
1010
+ project.version = '1.0'
1011
+ define "bar" do
1012
+ compile.with 'net.sourceforge.jtds:jtds:jar:1.2.7.XX'
1013
+ package :war
1014
+ end
1015
+ ipr.add_exploded_war_artifact(project,
1016
+ :name => 'gar',
1017
+ :war_module_names => ['x','y'],
1018
+ :gwt_module_names => ['p','q'],
1019
+ :artifacts => ['baz','biz'],
1020
+ :dependencies => ['net.sourceforge.jtds:jtds:jar:1.2.7.XX', project('bar')])
1021
+ end
1022
+ invoke_generate_task
1023
+ end
1024
+
1025
+ it "generates an IPR with a war artifact" do
1026
+ doc = xml_document(@foo._("foo.ipr"))
1027
+ base_xpath = "/project/component[@name='ArtifactManager']/artifact"
1028
+ facet_xpath = "#{base_xpath}[@type='exploded-war' @name='MyFancy.jar' and @build-on-make='false']"
1029
+ doc.should have_xpath(facet_xpath)
1030
+
1031
+ doc.should have_xpath("#{facet_xpath}/output-path/text() = $PROJECT_DIR$/artifacts/gar")
1032
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory' and @name='classes']/element[@id='module-output' and @name='bar']")
1033
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory' and @name='lib']/element[@id='file-copy' and @path='$MAVEN_REPOSITORY$/net/sourceforge/jtds/jtds/1.2.7.XX/jtds-1.2.7.XX.jar']")
1034
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='x/web/Web']")
1035
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='javaee-facet-resources' and @facet='y/web/Web']")
1036
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='gwt-compiler-output' and @facet='p/gwt/GWT']")
1037
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='gwt-compiler-output' and @facet='q/gwt/GWT']")
1038
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory' and @name='lib']/element[@id='artifact' and @artifact-name='baz.jar']")
1039
+ doc.should have_xpath("#{facet_xpath}/root[@id='root']/element[@id='directory' and @name='WEB-INF']/element[@id='directory' and @name='lib']/element[@id='artifact' and @artifact-name='biz.jar']")
1040
+ end
1041
+ end
1042
+
1043
+ describe "with configurations added to root project" do
1044
+ before do
1045
+ @foo = define "foo" do
1046
+ ipr.add_configuration("Run Contacts.html", "GWT.ConfigurationType", "GWT Configuration") do |xml|
1047
+ xml.module(:name => project.iml.id)
1048
+ xml.option(:name => "RUN_PAGE", :value => "Contacts.html")
1049
+ xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
1050
+ xml.option(:name => "compilerMaxHeapSize", :value => "512")
1051
+
1052
+ xml.RunnerSettings(:RunnerId => "Run")
1053
+ xml.ConfigurationWrapper(:RunnerId => "Run")
1054
+ xml.tag! :method
1055
+ end
1056
+ ipr.add_configuration("Run Planner.html", "GWT.ConfigurationType", "GWT Configuration") do |xml|
1057
+ xml.module(:name => project.iml.id)
1058
+ xml.option(:name => "RUN_PAGE", :value => "Planner.html")
1059
+ xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
1060
+ xml.option(:name => "compilerMaxHeapSize", :value => "512")
1061
+
1062
+ xml.RunnerSettings(:RunnerId => "Run")
1063
+ xml.ConfigurationWrapper(:RunnerId => "Run")
1064
+ xml.tag! :method
1065
+ end
1066
+ end
1067
+ invoke_generate_task
1068
+ end
1069
+
1070
+ it "generates an IPR with multiple configurations" do
1071
+ doc = xml_document(@foo._("foo.ipr"))
1072
+ facet_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
1073
+ doc.should have_nodes(facet_xpath, 2)
1074
+ doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType' and @name='Run Contacts.html']")
1075
+ doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType' and @name='Run Planner.html']")
1076
+ end
1077
+ end
1078
+
1079
+ describe "with default configuration added to root project" do
1080
+ before do
1081
+ @foo = define "foo" do
1082
+ ipr.add_default_configuration("GWT.ConfigurationType", "GWT Configuration") do |xml|
1083
+ xml.module(:name => project.iml.id)
1084
+ xml.option(:name => "RUN_PAGE", :value => "Planner.html")
1085
+ xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
1086
+ xml.option(:name => "compilerMaxHeapSize", :value => "512")
1087
+
1088
+ xml.RunnerSettings(:RunnerId => "Run")
1089
+ xml.ConfigurationWrapper(:RunnerId => "Run")
1090
+ xml.tag! :method
1091
+ end
1092
+ end
1093
+ invoke_generate_task
1094
+ end
1095
+
1096
+ it "generates an IPR with default configuration" do
1097
+ doc = xml_document(@foo._("foo.ipr"))
1098
+ facet_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
1099
+ doc.should have_nodes(facet_xpath, 1)
1100
+ doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType' and @factoryName='GWT Configuration' and @default='true']")
1101
+ end
1102
+ end
1103
+
1104
+ describe "with add_default_testng_configuration using defaults" do
1105
+ before do
1106
+ @foo = define "foo" do
1107
+ ipr.add_default_testng_configuration
1108
+ end
1109
+ invoke_generate_task
1110
+ end
1111
+
1112
+ it "generates an IPR with default configuration" do
1113
+ doc = xml_document(@foo._("foo.ipr"))
1114
+ configurations_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
1115
+ doc.should have_nodes(configurations_xpath, 1)
1116
+ configuration_xpath = "#{configurations_xpath}[@type='TestNG' and @factoryName='TestNG' and @default='true']"
1117
+ doc.should have_xpath(configuration_xpath)
1118
+ doc.should have_xpath("#{configuration_xpath}/option[@name='VM_PARAMETERS' and @value='-ea']")
1119
+ doc.should have_xpath("#{configuration_xpath}/option[@name='WORKING_DIRECTORY' and @value='$PROJECT_DIR$']")
1120
+ end
1121
+ end
1122
+
1123
+ describe "with add_default_testng_configuration specifying values" do
1124
+ before do
1125
+ @foo = define "foo" do
1126
+ ipr.add_default_testng_configuration(:dir => 'C:/blah', :jvm_args => '-ea -Dtest.db.url=xxxx')
1127
+ end
1128
+ invoke_generate_task
1129
+ end
1130
+
1131
+ it "generates an IPR with default configuration" do
1132
+ doc = xml_document(@foo._("foo.ipr"))
1133
+ configurations_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
1134
+ doc.should have_nodes(configurations_xpath, 1)
1135
+ configuration_xpath = "#{configurations_xpath}[@type='TestNG' and @factoryName='TestNG' and @default='true']"
1136
+ doc.should have_xpath(configuration_xpath)
1137
+ doc.should have_xpath("#{configuration_xpath}/option[@name='VM_PARAMETERS' and @value='-ea -Dtest.db.url=xxxx']")
1138
+ doc.should have_xpath("#{configuration_xpath}/option[@name='WORKING_DIRECTORY' and @value='C:/blah']")
1139
+ end
1140
+ end
1141
+
1142
+ describe "with iml.group specified" do
1143
+ before do
1144
+ @foo = define "foo" do
1145
+ iml.group = true
1146
+ define 'bar' do
1147
+ define 'baz' do
1148
+
1149
+ end
1150
+ end
1151
+ define 'rab' do
1152
+ iml.group = "MyGroup"
1153
+ end
1154
+ end
1155
+ invoke_generate_task
1156
+ end
1157
+
1158
+ it "generate an IPR with correct group references" do
1159
+ doc = xml_document(@foo._("foo.ipr"))
1160
+ doc.should have_nodes("#{xpath_to_module}", 4)
1161
+ module_ref = "$PROJECT_DIR$/foo.iml"
1162
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']")
1163
+ module_ref = "$PROJECT_DIR$/rab/rab.iml"
1164
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}' @group = 'MyGroup']")
1165
+ module_ref = "$PROJECT_DIR$/bar/bar.iml"
1166
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}' @group = 'foo']")
1167
+ module_ref = "$PROJECT_DIR$/bar/baz/baz.iml"
1168
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}' @group = 'foo/bar']")
1169
+ end
1170
+ end
1171
+
1172
+ describe "with a single project definition" do
1173
+ describe "and default naming" do
1174
+ before do
1175
+ @foo = define "foo"
1176
+ invoke_generate_task
1177
+ end
1178
+
1179
+ it "generates a single IPR" do
1180
+ Dir[@foo._("**/*.ipr")].should have(1).entry
1181
+ end
1182
+
1183
+ it "generate an IPR in the root directory" do
1184
+ File.should be_exist(@foo._("foo.ipr"))
1185
+ end
1186
+
1187
+ it "generates a single IML" do
1188
+ Dir[@foo._("**/*.iml")].should have(1).entry
1189
+ end
1190
+
1191
+ it "generates an IML in the root directory" do
1192
+ File.should be_exist(@foo._("foo.iml"))
1193
+ end
1194
+
1195
+ it "generate an IPR with the reference to correct module file" do
1196
+ File.should be_exist(@foo._("foo.ipr"))
1197
+ doc = xml_document(@foo._("foo.ipr"))
1198
+ module_ref = "$PROJECT_DIR$/foo.iml"
1199
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']", 1)
1200
+ end
1201
+ end
1202
+
1203
+ describe "with no_iml generation disabled" do
1204
+ before do
1205
+ @foo = define "foo" do
1206
+ project.no_iml
1207
+ end
1208
+ invoke_generate_task
1209
+ end
1210
+
1211
+ it "generates no IML" do
1212
+ Dir[@foo._("**/*.iml")].should have(0).entry
1213
+ end
1214
+
1215
+ it "generate an IPR with no references" do
1216
+ File.should be_exist(@foo._("foo.ipr"))
1217
+ doc = xml_document(@foo._("foo.ipr"))
1218
+ doc.should have_nodes("#{xpath_to_module}", 0)
1219
+ end
1220
+ end
1221
+
1222
+ describe "with ipr generation disabled" do
1223
+ before do
1224
+ @foo = define "foo" do
1225
+ project.no_ipr
1226
+ end
1227
+ invoke_generate_task
1228
+ end
1229
+
1230
+ it "generates a single IML" do
1231
+ Dir[@foo._("**/*.iml")].should have(1).entry
1232
+ end
1233
+
1234
+ it "generate no IPR" do
1235
+ File.should_not be_exist(@foo._("foo.ipr"))
1236
+ end
1237
+ end
1238
+
1239
+ describe "and id overrides" do
1240
+ before do
1241
+ @foo = define "foo" do
1242
+ ipr.id = 'fooble'
1243
+ iml.id = 'feap'
1244
+ define "bar" do
1245
+ iml.id = "baz"
1246
+ end
1247
+ end
1248
+ invoke_generate_task
1249
+ end
1250
+
1251
+ it "generate an IPR in the root directory" do
1252
+ File.should be_exist(@foo._("fooble.ipr"))
1253
+ end
1254
+
1255
+ it "generates an IML in the root directory" do
1256
+ File.should be_exist(@foo._("feap.iml"))
1257
+ end
1258
+
1259
+ it "generates an IML in the subproject directory" do
1260
+ File.should be_exist(@foo._("bar/baz.iml"))
1261
+ end
1262
+
1263
+ it "generate an IPR with the reference to correct module file" do
1264
+ File.should be_exist(@foo._("fooble.ipr"))
1265
+ doc = xml_document(@foo._("fooble.ipr"))
1266
+ module_ref = "$PROJECT_DIR$/feap.iml"
1267
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']", 1)
1268
+ end
1269
+ end
1270
+
1271
+ describe "and a suffix defined" do
1272
+ before do
1273
+ @foo = define "foo" do
1274
+ ipr.suffix = '-ipr-suffix'
1275
+ iml.suffix = '-iml-suffix'
1276
+ end
1277
+ invoke_generate_task
1278
+ end
1279
+
1280
+ it "generate an IPR in the root directory" do
1281
+ File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
1282
+ end
1283
+
1284
+ it "generates an IML in the root directory" do
1285
+ File.should be_exist(@foo._("foo-iml-suffix.iml"))
1286
+ end
1287
+
1288
+ it "generate an IPR with the reference to correct module file" do
1289
+ File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
1290
+ doc = xml_document(@foo._("foo-ipr-suffix.ipr"))
1291
+ doc.should have_nodes("#{xpath_to_module}", 1)
1292
+ module_ref = "$PROJECT_DIR$/foo-iml-suffix.iml"
1293
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']", 1)
1294
+ end
1295
+ end
1296
+ end
1297
+
1298
+ describe "with a subproject" do
1299
+ before do
1300
+ @foo = define "foo" do
1301
+ define 'bar'
1302
+ end
1303
+ invoke_generate_task
1304
+ end
1305
+
1306
+ it "creates the subproject directory" do
1307
+ File.should be_exist(@foo._("bar"))
1308
+ end
1309
+
1310
+ it "generates an IML in the subproject directory" do
1311
+ File.should be_exist(@foo._("bar/bar.iml"))
1312
+ end
1313
+
1314
+ it "generate an IPR with the reference to correct module file" do
1315
+ File.should be_exist(@foo._("foo.ipr"))
1316
+ doc = xml_document(@foo._("foo.ipr"))
1317
+ doc.should have_nodes("#{xpath_to_module}", 2)
1318
+ module_ref = "$PROJECT_DIR$/foo.iml"
1319
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']", 1)
1320
+ module_ref = "$PROJECT_DIR$/bar/bar.iml"
1321
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}' and @filepath='#{module_ref}']", 1)
1322
+ end
1323
+ end
1324
+
1325
+ describe "with base_dir specified" do
1326
+ before do
1327
+ @foo = define "foo" do
1328
+ define('bar', :base_dir => 'fe') do
1329
+ define('baz', :base_dir => 'fi') do
1330
+ define('foe')
1331
+ end
1332
+ define('fum')
1333
+ end
1334
+ end
1335
+ invoke_generate_task
1336
+ end
1337
+
1338
+ it "generates a subproject IML in the specified directory" do
1339
+ File.should be_exist(@foo._("fe/bar.iml"))
1340
+ end
1341
+
1342
+ it "generates a sub-subproject IML in the specified directory" do
1343
+ File.should be_exist(@foo._("fi/baz.iml"))
1344
+ end
1345
+
1346
+ it "generates a sub-sub-subproject IML that inherits the specified directory" do
1347
+ File.should be_exist(@foo._("fi/foe/foe.iml"))
1348
+ end
1349
+
1350
+ it "generates a sub-subproject IML that inherits the specified directory" do
1351
+ File.should be_exist(@foo._("fe/fum/fum.iml"))
1352
+ end
1353
+
1354
+ it "generate an IPR with the references to correct module files" do
1355
+ doc = xml_document(@foo._("foo.ipr"))
1356
+ doc.should have_nodes("#{xpath_to_module}", 5)
1357
+ ["foo.iml", "fe/bar.iml", "fi/baz.iml", "fi/foe/foe.iml", "fe/fum/fum.iml"].each do |module_ref|
1358
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://$PROJECT_DIR$/#{module_ref}' and @filepath='$PROJECT_DIR$/#{module_ref}']", 1)
1359
+ end
1360
+ end
1361
+ end
1362
+
1363
+ describe "with extensive intermodule dependencies" do
1364
+ before do
1365
+ mkdir_p 'foo/src/main/resources'
1366
+ mkdir_p 'foo/src/main/java/foo'
1367
+ touch 'foo/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
1368
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
1369
+ define "root" do
1370
+ repositories.remote << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/'
1371
+ project.version = "2.5.2"
1372
+ define 'foo' do
1373
+ resources.from _(:source, :main, :resources)
1374
+ compile.with 'group:id:jar:1.0'
1375
+ test.using(:junit)
1376
+ package(:jar)
1377
+ end
1378
+
1379
+ define 'bar' do
1380
+ # internally transitive dependencies on foo, both runtime and test
1381
+ compile.with project('root:foo'), project('root:foo').compile.dependencies
1382
+ test.using(:junit).with [project('root:foo').test.compile.target,
1383
+ project('root:foo').test.resources.target,
1384
+ project('root:foo').test.compile.dependencies].compact
1385
+ package(:jar)
1386
+ end
1387
+ end
1388
+
1389
+ invoke_generate_task
1390
+ @bar_iml = xml_document(project('root:bar')._('bar.iml'))
1391
+ @bar_lib_urls = @bar_iml.get_elements("//orderEntry[@type='module-library']/library/CLASSES/root").collect do |root|
1392
+ root.attribute('url').to_s
1393
+ end
1394
+ end
1395
+
1396
+ it "depends on the associated module exactly once" do
1397
+ @bar_iml.should have_nodes("//orderEntry[@type='module' and @module-name='foo' and @exported=""]", 1)
1398
+ end
1399
+
1400
+ it "does not depend on the other project's packaged JAR" do
1401
+ @bar_lib_urls.grep(%r{#{project('root:foo').packages.first}}).should == []
1402
+ end
1403
+
1404
+ it "does not depend on the the other project's target/classes directory" do
1405
+ @bar_lib_urls.grep(%r{foo/target/classes}).should == []
1406
+ end
1407
+
1408
+ it "does not depend on the the other project's target/resources directory" do
1409
+ @bar_lib_urls.grep(%r{file://\$MODULE_DIR\$/../foo/target/resources}).size.should == 0
1410
+ end
1411
+ end
1412
+
1413
+ describe "with a single project definition" do
1414
+ before do
1415
+ @foo = define "foo"
1416
+ end
1417
+
1418
+ it "informs the user about generating IPR" do
1419
+ lambda { invoke_generate_task }.should show_info(/Writing (.+)\/foo\.ipr/)
1420
+ end
1421
+
1422
+ it "informs the user about generating IML" do
1423
+ lambda { invoke_generate_task }.should show_info(/Writing (.+)\/foo\.iml/)
1424
+ end
1425
+ end
1426
+ describe "with a subproject" do
1427
+ before do
1428
+ @foo = define "foo" do
1429
+ define 'bar'
1430
+ end
1431
+ end
1432
+
1433
+ it "informs the user about generating subporoject IML" do
1434
+ lambda { invoke_generate_task }.should show_info(/Writing (.+)\/bar\/bar\.iml/)
1435
+ end
1436
+ end
1437
+
1438
+ describe "with compile.options.source = '1.6'" do
1439
+
1440
+ before do
1441
+ @foo = define "foo" do
1442
+ compile.options.source = '1.5'
1443
+ end
1444
+ invoke_generate_task
1445
+ end
1446
+
1447
+ it "generate an ProjectRootManager with 1.5 jdk specified" do
1448
+ #raise File.read(@foo._("foo.ipr"))
1449
+ xml_document(@foo._("foo.ipr")).
1450
+ should have_xpath("/project/component[@name='ProjectRootManager' and @project-jdk-name = '1.5' and @languageLevel = 'JDK_1_5']")
1451
+ end
1452
+
1453
+ it "generates a ProjectDetails component with the projectName option set" do
1454
+ xml_document(@foo._("foo.ipr")).
1455
+ should have_xpath("/project/component[@name='ProjectDetails']/option[@name = 'projectName' and @value = 'foo']")
1456
+ end
1457
+ end
1458
+
1459
+ describe "with compile.options.source = '1.6'" do
1460
+ before do
1461
+ @foo = define "foo" do
1462
+ compile.options.source = '1.6'
1463
+ end
1464
+ invoke_generate_task
1465
+ end
1466
+
1467
+ it "generate an ProjectRootManager with 1.6 jdk specified" do
1468
+ xml_document(@foo._("foo.ipr")).
1469
+ should have_xpath("/project/component[@name='ProjectRootManager' and @project-jdk-name = '1.6' and @languageLevel = 'JDK_1_6']")
1470
+ end
1471
+ end
1472
+
1473
+ describe "with iml.skip_content! specified" do
1474
+ before do
1475
+ @foo = define "foo" do
1476
+ iml.skip_content!
1477
+ end
1478
+ invoke_generate_task
1479
+ end
1480
+
1481
+ it "generate an IML with no content section" do
1482
+ doc = xml_document(@foo._(root_module_filename(@foo)))
1483
+ doc.should_not have_xpath("/module/component[@name='NewModuleRootManager']/content")
1484
+ end
1485
+ end
1486
+
1487
+ describe "with iml.skip_content! not specified and standard layout" do
1488
+ before do
1489
+ @foo = define "foo" do
1490
+ end
1491
+ invoke_generate_task
1492
+ end
1493
+
1494
+ it "generate an IML with content section" do
1495
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content")
1496
+ end
1497
+
1498
+ it "generate an exclude in content section for reports" do
1499
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
1500
+ end
1501
+
1502
+ it "generate an exclude in content section for target" do
1503
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
1504
+ end
1505
+ end
1506
+
1507
+ describe "with subprojects" do
1508
+ before do
1509
+ @foo = define "foo" do
1510
+ define "bar" do
1511
+ compile.from _(:source, :main, :bar)
1512
+ end
1513
+ end
1514
+ invoke_generate_task
1515
+ @bar_doc = xml_document(project('foo:bar')._('bar.iml'))
1516
+ end
1517
+
1518
+ it "generates the correct source directories" do
1519
+ @bar_doc.should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/main/bar']")
1520
+ end
1521
+
1522
+ it "generates the correct exclude directories" do
1523
+ @bar_doc.should have_xpath("//content/excludeFolder[@url='file://$MODULE_DIR$/target']")
1524
+ end
1525
+ end
1526
+
1527
+ describe "with overrides" do
1528
+ before do
1529
+ @foo = define "foo" do
1530
+ compile.from _(:source, :main, :bar)
1531
+ iml.main_source_directories << _(:source, :main, :baz)
1532
+ iml.test_source_directories << _(:source, :test, :foo)
1533
+ end
1534
+ invoke_generate_task
1535
+ end
1536
+
1537
+ it "generates the correct main source directories" do
1538
+ root_module_xml(@foo).should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/main/baz' and @isTestSource='false']")
1539
+ end
1540
+
1541
+ it "generates the correct test source directories" do
1542
+ root_module_xml(@foo).should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/test/foo' and @isTestSource='true']")
1543
+ end
1544
+ end
1545
+
1546
+ describe "with report dir outside content" do
1547
+ before do
1548
+ layout = Layout::Default.new
1549
+ layout[:reports] = "../reports"
1550
+
1551
+ @foo = define "foo", :layout => layout do
1552
+ end
1553
+ invoke_generate_task
1554
+ end
1555
+
1556
+ it "generate an exclude in content section for target" do
1557
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
1558
+ end
1559
+
1560
+ it "generates an content section without an exclude for report dir" do
1561
+ root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
1562
+ end
1563
+ end
1564
+
1565
+ describe "with target dir outside content" do
1566
+ before do
1567
+ layout = Layout::Default.new
1568
+ layout[:target] = "../target"
1569
+ layout[:target, :main] = "../target"
1570
+
1571
+ @foo = define "foo", :layout => layout do
1572
+ end
1573
+ invoke_generate_task
1574
+ end
1575
+
1576
+ it "generate an exclude in content section for reports" do
1577
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
1578
+ end
1579
+
1580
+ it "generates an content section without an exclude for target dir" do
1581
+ root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
1582
+ end
1583
+ end
1584
+
1585
+ describe "templates" do
1586
+
1587
+ def ipr_template
1588
+ return <<PROJECT_XML
1589
+ <?xml version="1.0" encoding="UTF-8"?>
1590
+ <project version="4">
1591
+ <component name="SvnBranchConfigurationManager">
1592
+ <option name="mySupportsUserInfoFilter" value="false" />
1593
+ </component>
1594
+ </project>
1595
+ PROJECT_XML
1596
+ end
1597
+
1598
+ def ipr_existing
1599
+ return <<PROJECT_XML
1600
+ <?xml version="1.0" encoding="UTF-8"?>
1601
+ <project version="4">
1602
+ <component name="AntConfiguration">
1603
+ <defaultAnt bundledAnt="true" />
1604
+ </component>
1605
+ <component name="SvnBranchConfigurationManager">
1606
+ <option name="mySupportsUserInfoFilter" value="true" />
1607
+ </component>
1608
+ <component name="ProjectModuleManager">
1609
+ <modules>
1610
+ <module fileurl="file://$PROJECT_DIR$/existing.iml" filepath="$PROJECT_DIR$/existing.iml" />
1611
+ </modules>
1612
+ </component>
1613
+ </project>
1614
+ PROJECT_XML
1615
+ end
1616
+
1617
+ def ipr_from_template_xpath
1618
+ "/project/component[@name='SvnBranchConfigurationManager']/option[@name = 'mySupportsUserInfoFilter' and @value = 'false']"
1619
+ end
1620
+
1621
+ def ipr_from_existing_xpath
1622
+ "/project/component[@name='AntConfiguration']"
1623
+ end
1624
+
1625
+ def ipr_from_existing_shadowing_template_xpath
1626
+ "/project/component[@name='SvnBranchConfigurationManager']/option[@name = 'mySupportsUserInfoFilter' and @value = 'true']"
1627
+ end
1628
+
1629
+ def ipr_from_existing_shadowing_generated_xpath
1630
+ "/project/component[@name='ProjectModuleManager']/modules/module[@fileurl = 'file://$PROJECT_DIR$/existing.iml']"
1631
+ end
1632
+
1633
+ def ipr_from_generated_xpath
1634
+ "/project/component[@name='ProjectModuleManager']/modules/module[@fileurl = 'file://$PROJECT_DIR$/foo.iml']"
1635
+ end
1636
+
1637
+ def iml_template
1638
+ return <<PROJECT_XML
1639
+ <?xml version="1.0" encoding="UTF-8"?>
1640
+ <module type="JAVA_MODULE" version="4">
1641
+ <component name="FacetManager">
1642
+ <facet type="JRUBY" name="JRuby">
1643
+ <configuration number="0">
1644
+ <JRUBY_FACET_CONFIG_ID NAME="JRUBY_SDK_NAME" VALUE="JRuby SDK 1.4.0RC1" />
1645
+ </configuration>
1646
+ </facet>
1647
+ </component>
1648
+ </module>
1649
+ PROJECT_XML
1650
+ end
1651
+
1652
+ def iml_existing
1653
+ return <<PROJECT_XML
1654
+ <?xml version="1.0" encoding="UTF-8"?>
1655
+ <module type="JAVA_MODULE" version="4">
1656
+ <component name="FunkyPlugin"/>
1657
+ <component name="FacetManager">
1658
+ <facet type="SCALA" name="Scala"/>
1659
+ </component>
1660
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
1661
+ <exclude-output />
1662
+ <content url="file://$MODULE_DIR$"/>
1663
+ <orderEntry type="inheritedJdk" />
1664
+ <orderEntry type="sourceFolder" forTests="false" />
1665
+ <orderEntry type="module" module-name="buildr-bnd" exported="" />
1666
+ </component>
1667
+ </module>
1668
+ PROJECT_XML
1669
+ end
1670
+
1671
+ def iml_from_template_xpath
1672
+ "/module/component[@name='FacetManager']/facet[@type = 'JRUBY']"
1673
+ end
1674
+
1675
+ def iml_from_existing_xpath
1676
+ "/module/component[@name='FunkyPlugin']"
1677
+ end
1678
+
1679
+ def iml_from_existing_shadowing_template_xpath
1680
+ "/module/component[@name='FacetManager']/facet[@type = 'SCALA']"
1681
+ end
1682
+
1683
+ def iml_from_existing_shadowing_generated_xpath
1684
+ "/module/component[@name='NewModuleRootManager']/orderEntry[@module-name = 'buildr-bnd']"
1685
+ end
1686
+
1687
+ def iml_from_generated_xpath
1688
+ "/module/component[@name='NewModuleRootManager']/orderEntry[@type = 'module-library']"
1689
+ end
1690
+
1691
+ describe "with existing project files" do
1692
+ before do
1693
+ write "foo.ipr", ipr_existing
1694
+ write "foo.iml", iml_existing
1695
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
1696
+ @foo = define "foo" do
1697
+ ipr.template = nil
1698
+ iml.template = nil
1699
+ compile.with 'group:id:jar:1.0'
1700
+ end
1701
+ invoke_generate_task
1702
+ end
1703
+
1704
+ it "replaces ProjectModuleManager component in existing ipr file" do
1705
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
1706
+ xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_generated_xpath)
1707
+ end
1708
+
1709
+ it "merges component in existing ipr file" do
1710
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_existing_xpath)
1711
+ end
1712
+
1713
+ def iml_from_generated_xpath
1714
+ "/module/component[@name='NewModuleRootManager']/orderEntry[@type = 'module-library']"
1715
+ end
1716
+
1717
+ it "replaces NewModuleRootManager component in existing iml file" do
1718
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
1719
+ xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_generated_xpath)
1720
+ end
1721
+
1722
+ it "merges component in existing iml file" do
1723
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_existing_xpath)
1724
+ end
1725
+ end
1726
+
1727
+ describe "with an iml template" do
1728
+ before do
1729
+ write "module.template.iml", iml_template
1730
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
1731
+ @foo = define "foo" do
1732
+ ipr.template = nil
1733
+ iml.template = "module.template.iml"
1734
+ compile.with 'group:id:jar:1.0'
1735
+ end
1736
+ invoke_generate_task
1737
+ end
1738
+
1739
+ it "replaces generated components" do
1740
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
1741
+ end
1742
+
1743
+ it "merges component in iml template" do
1744
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_template_xpath)
1745
+ end
1746
+ end
1747
+
1748
+ describe "with an iml template and existing iml" do
1749
+ before do
1750
+ write "module.template.iml", iml_template
1751
+ write "foo.iml", iml_existing
1752
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
1753
+ @foo = define "foo" do
1754
+ ipr.template = nil
1755
+ iml.template = "module.template.iml"
1756
+ compile.with 'group:id:jar:1.0'
1757
+ end
1758
+ invoke_generate_task
1759
+ end
1760
+
1761
+ it "replaces generated components" do
1762
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
1763
+ end
1764
+
1765
+ it "merges component in iml template" do
1766
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_template_xpath)
1767
+ end
1768
+
1769
+ it "merges components not in iml template and not generated by task" do
1770
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_existing_xpath)
1771
+ xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_template_xpath)
1772
+ xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_generated_xpath)
1773
+ end
1774
+ end
1775
+
1776
+ describe "with an ipr template" do
1777
+ before do
1778
+ write "project.template.iml", ipr_template
1779
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
1780
+ @foo = define "foo" do
1781
+ ipr.template = "project.template.iml"
1782
+ iml.template = nil
1783
+ compile.with 'group:id:jar:1.0'
1784
+ end
1785
+ invoke_generate_task
1786
+ end
1787
+
1788
+ it "replaces generated component in ipr template" do
1789
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
1790
+ end
1791
+
1792
+ it "merges component in ipr template" do
1793
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_template_xpath)
1794
+ end
1795
+ end
1796
+
1797
+ describe "with an ipr template and existing ipr" do
1798
+ before do
1799
+ write "project.template.iml", ipr_template
1800
+ write "foo.ipr", ipr_existing
1801
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
1802
+ @foo = define "foo" do
1803
+ ipr.template = "project.template.iml"
1804
+ iml.template = nil
1805
+ compile.with 'group:id:jar:1.0'
1806
+ end
1807
+ invoke_generate_task
1808
+ end
1809
+
1810
+ it "replaces generated component in ipr template" do
1811
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
1812
+ end
1813
+
1814
+ it "merges component in ipr template" do
1815
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_template_xpath)
1816
+ end
1817
+
1818
+ it "merges components not in ipr template and not generated by task" do
1819
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_existing_xpath)
1820
+ xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_generated_xpath)
1821
+ xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_template_xpath)
1822
+ end
1823
+ end
1824
+ end
1825
+ end
1826
+
1827
+ describe "Buildr::IntellijIdea::IdeaModule" do
1828
+
1829
+ describe "with no settings" do
1830
+ before do
1831
+ @foo = define "foo"
1832
+ end
1833
+
1834
+ it "has correct default iml.type setting" do
1835
+ @foo.iml.type.should == "JAVA_MODULE"
1836
+ end
1837
+
1838
+ it "has correct default iml.local_repository_env_override setting" do
1839
+ @foo.iml.local_repository_env_override.should == "MAVEN_REPOSITORY"
1840
+ end
1841
+ end
1842
+
1843
+ describe "settings inherited in subprojects" do
1844
+ before do
1845
+ mkdir_p 'bar'
1846
+ @foo = define "foo" do
1847
+ iml.type = "FOO_MODULE_TYPE"
1848
+ define 'bar'
1849
+ end
1850
+ invoke_generate_task
1851
+ end
1852
+
1853
+ it "generates root IML with specified type" do
1854
+ module_file = root_module_filename(@foo)
1855
+ File.should be_exist(module_file)
1856
+ File.read(module_file).should =~ /FOO_MODULE_TYPE/
1857
+ end
1858
+
1859
+ it "generates subproject IML with inherited type" do
1860
+ module_file = subproject_module_filename(@foo, "bar")
1861
+ File.should be_exist(module_file)
1862
+ File.read(module_file).should =~ /FOO_MODULE_TYPE/
1863
+ end
1864
+
1865
+ end
1866
+
1867
+ describe "with local_repository_env_override = nil" do
1868
+ if Buildr::Util.win_os?
1869
+ describe "base_directory on different drive on windows" do
1870
+ before do
1871
+ @foo = define "foo", :base_dir => "C:/bar" do
1872
+ iml.local_repository_env_override = nil
1873
+ end
1874
+ end
1875
+
1876
+ it "generates relative paths correctly" do
1877
+ @foo.iml.send(:resolve_path, "E:/foo").should eql('E:/foo')
1878
+ end
1879
+ end
1880
+
1881
+ describe "base_directory on same drive on windows" do
1882
+ before do
1883
+ @foo = define "foo", :base_dir => "C:/bar" do
1884
+ iml.local_repository_env_override = nil
1885
+ end
1886
+ end
1887
+
1888
+ it "generates relative paths correctly" do
1889
+ @foo.iml.send(:resolve_path, "C:/foo").should eql('$MODULE_DIR$/../foo')
1890
+ end
1891
+ end
1892
+ end
1893
+ end
1894
+ end
1895
+
1896
+ describe "project extension" do
1897
+ it "provides an 'idea' task" do
1898
+ Rake::Task.tasks.detect { |task| task.to_s == "idea" }.should_not be_nil
1899
+ end
1900
+
1901
+ it "documents the 'idea' task" do
1902
+ Rake::Task.tasks.detect { |task| task.to_s == "idea" }.comment.should_not be_nil
1903
+ end
1904
+
1905
+ it "provides an 'idea:clean' task" do
1906
+ Rake::Task.tasks.detect { |task| task.to_s == "idea:clean" }.should_not be_nil
1907
+ end
1908
+
1909
+ it "documents the 'idea:clean' task" do
1910
+ Rake::Task.tasks.detect { |task| task.to_s == "idea:clean" }.comment.should_not be_nil
1911
+ end
1912
+
1913
+ describe "#no_iml" do
1914
+ it "makes #iml? false" do
1915
+ @foo = define "foo" do
1916
+ project.no_iml
1917
+ end
1918
+ @foo.iml?.should be_false
1919
+ end
1920
+ end
1921
+
1922
+ describe "#iml" do
1923
+ before do
1924
+ define "foo" do
1925
+ iml.suffix = "-top"
1926
+
1927
+ define "bar" do
1928
+ iml.suffix = "-mid"
1929
+
1930
+ define "baz" do
1931
+ end
1932
+ end
1933
+ end
1934
+ end
1935
+
1936
+ it "inherits the direct parent's IML settings" do
1937
+ project('foo:bar:baz').iml.suffix.should == "-mid"
1938
+ end
1939
+
1940
+ it "does not modify the parent's IML settings" do
1941
+ project('foo').iml.suffix.should == "-top"
1942
+ end
1943
+
1944
+ it "works even when the parent has no IML" do
1945
+ lambda {
1946
+ define "a" do
1947
+ project.no_iml
1948
+ define "b" do
1949
+ iml.suffix = "-alone"
1950
+ end
1951
+ end
1952
+ }.should_not raise_error
1953
+ end
1954
+
1955
+ it "inherits from the first ancestor which has an IML" do
1956
+ define "a" do
1957
+ iml.suffix = "-a"
1958
+ define "b" do
1959
+ iml.suffix = "-b"
1960
+ define "c" do
1961
+ project.no_iml
1962
+ define "d" do
1963
+ project.no_iml
1964
+ define "e" do
1965
+ project.no_iml
1966
+ define "f" do
1967
+ end
1968
+ end
1969
+ end
1970
+ end
1971
+ end
1972
+ end
1973
+
1974
+ project("a:b:c:d:e:f").iml.suffix.should == "-b"
1975
+ end
1976
+ end
1977
+ end
1978
+
1979
+ end