buildr-gemjar 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/.braids +8 -0
  2. data/.gitignore +5 -0
  3. data/.rvmrc +1 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +20 -0
  7. data/README.md +98 -0
  8. data/Rakefile +8 -0
  9. data/buildr-gemjar.gemspec +42 -0
  10. data/lib/buildr-gemjar.rb +162 -0
  11. data/lib/buildr-gemjar/version.rb +3 -0
  12. data/meta.rakefile +30 -0
  13. data/spec/buildr-gemjar/version_spec.rb +11 -0
  14. data/spec/buildr-gemjar_spec.rb +179 -0
  15. data/spec/repo_builder.rb +59 -0
  16. data/spec/spec_helper.rb +44 -0
  17. data/vendor/buildr/.gitignore +17 -0
  18. data/vendor/buildr/CHANGELOG +1283 -0
  19. data/vendor/buildr/Gemfile +4 -0
  20. data/vendor/buildr/LICENSE +176 -0
  21. data/vendor/buildr/NOTICE +26 -0
  22. data/vendor/buildr/README.rdoc +134 -0
  23. data/vendor/buildr/Rakefile +44 -0
  24. data/vendor/buildr/_buildr +35 -0
  25. data/vendor/buildr/_jbuildr +35 -0
  26. data/vendor/buildr/addon/buildr/antlr.rb +65 -0
  27. data/vendor/buildr/addon/buildr/bnd.rb +147 -0
  28. data/vendor/buildr/addon/buildr/cobertura.rb +22 -0
  29. data/vendor/buildr/addon/buildr/drb.rb +281 -0
  30. data/vendor/buildr/addon/buildr/emma.rb +22 -0
  31. data/vendor/buildr/addon/buildr/hibernate.rb +149 -0
  32. data/vendor/buildr/addon/buildr/javacc.rb +85 -0
  33. data/vendor/buildr/addon/buildr/jaxb_xjc.rb +72 -0
  34. data/vendor/buildr/addon/buildr/jdepend.rb +60 -0
  35. data/vendor/buildr/addon/buildr/jetty.rb +248 -0
  36. data/vendor/buildr/addon/buildr/jibx.rb +86 -0
  37. data/vendor/buildr/addon/buildr/nailgun.rb +221 -0
  38. data/vendor/buildr/addon/buildr/openjpa.rb +88 -0
  39. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  40. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  41. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  42. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  43. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  44. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  45. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  46. data/vendor/buildr/addon/buildr/protobuf.rb +88 -0
  47. data/vendor/buildr/addon/buildr/xmlbeans.rb +93 -0
  48. data/vendor/buildr/all-in-one/_buildr +19 -0
  49. data/vendor/buildr/all-in-one/buildr +368 -0
  50. data/vendor/buildr/all-in-one/buildr.cmd +1 -0
  51. data/vendor/buildr/bin/buildr +19 -0
  52. data/vendor/buildr/buildr.buildfile +58 -0
  53. data/vendor/buildr/buildr.gemspec +74 -0
  54. data/vendor/buildr/doc/_config.yml +1 -0
  55. data/vendor/buildr/doc/_layouts/default.html +90 -0
  56. data/vendor/buildr/doc/_layouts/preface.html +22 -0
  57. data/vendor/buildr/doc/artifacts.textile +217 -0
  58. data/vendor/buildr/doc/building.textile +276 -0
  59. data/vendor/buildr/doc/contributing.textile +268 -0
  60. data/vendor/buildr/doc/css/default.css +236 -0
  61. data/vendor/buildr/doc/css/print.css +101 -0
  62. data/vendor/buildr/doc/css/syntax.css +23 -0
  63. data/vendor/buildr/doc/download.textile +138 -0
  64. data/vendor/buildr/doc/extending.textile +212 -0
  65. data/vendor/buildr/doc/images/1442160941-frontcover.jpg +0 -0
  66. data/vendor/buildr/doc/images/asf-logo.gif +0 -0
  67. data/vendor/buildr/doc/images/asf-logo.png +0 -0
  68. data/vendor/buildr/doc/images/buildr-hires.png +0 -0
  69. data/vendor/buildr/doc/images/buildr.png +0 -0
  70. data/vendor/buildr/doc/images/favicon.png +0 -0
  71. data/vendor/buildr/doc/images/growl-icon.tiff +0 -0
  72. data/vendor/buildr/doc/images/note.png +0 -0
  73. data/vendor/buildr/doc/images/project-structure.png +0 -0
  74. data/vendor/buildr/doc/images/tip.png +0 -0
  75. data/vendor/buildr/doc/images/zbuildr.png +0 -0
  76. data/vendor/buildr/doc/images/zbuildr.tif +0 -0
  77. data/vendor/buildr/doc/index.textile +69 -0
  78. data/vendor/buildr/doc/installing.textile +284 -0
  79. data/vendor/buildr/doc/languages.textile +599 -0
  80. data/vendor/buildr/doc/mailing_lists.textile +29 -0
  81. data/vendor/buildr/doc/more_stuff.textile +845 -0
  82. data/vendor/buildr/doc/packaging.textile +618 -0
  83. data/vendor/buildr/doc/preface.textile +54 -0
  84. data/vendor/buildr/doc/projects.textile +276 -0
  85. data/vendor/buildr/doc/quick_start.textile +210 -0
  86. data/vendor/buildr/doc/releasing.textile +117 -0
  87. data/vendor/buildr/doc/scripts/buildr-git.rb +512 -0
  88. data/vendor/buildr/doc/scripts/gitflow.rb +296 -0
  89. data/vendor/buildr/doc/scripts/install-jruby.sh +44 -0
  90. data/vendor/buildr/doc/scripts/install-linux.sh +73 -0
  91. data/vendor/buildr/doc/scripts/install-osx.sh +52 -0
  92. data/vendor/buildr/doc/settings_profiles.textile +287 -0
  93. data/vendor/buildr/doc/testing.textile +247 -0
  94. data/vendor/buildr/etc/KEYS +189 -0
  95. data/vendor/buildr/lib/buildr.rb +44 -0
  96. data/vendor/buildr/lib/buildr/clojure.rb +34 -0
  97. data/vendor/buildr/lib/buildr/clojure/shell.rb +52 -0
  98. data/vendor/buildr/lib/buildr/core.rb +34 -0
  99. data/vendor/buildr/lib/buildr/core/application.rb +700 -0
  100. data/vendor/buildr/lib/buildr/core/build.rb +516 -0
  101. data/vendor/buildr/lib/buildr/core/cc.rb +166 -0
  102. data/vendor/buildr/lib/buildr/core/checks.rb +253 -0
  103. data/vendor/buildr/lib/buildr/core/common.rb +151 -0
  104. data/vendor/buildr/lib/buildr/core/compile.rb +622 -0
  105. data/vendor/buildr/lib/buildr/core/doc.rb +276 -0
  106. data/vendor/buildr/lib/buildr/core/environment.rb +129 -0
  107. data/vendor/buildr/lib/buildr/core/filter.rb +404 -0
  108. data/vendor/buildr/lib/buildr/core/generate.rb +197 -0
  109. data/vendor/buildr/lib/buildr/core/help.rb +119 -0
  110. data/vendor/buildr/lib/buildr/core/jrebel.rb +42 -0
  111. data/vendor/buildr/lib/buildr/core/linux.rb +30 -0
  112. data/vendor/buildr/lib/buildr/core/osx.rb +46 -0
  113. data/vendor/buildr/lib/buildr/core/progressbar.rb +161 -0
  114. data/vendor/buildr/lib/buildr/core/project.rb +975 -0
  115. data/vendor/buildr/lib/buildr/core/run.rb +43 -0
  116. data/vendor/buildr/lib/buildr/core/shell.rb +137 -0
  117. data/vendor/buildr/lib/buildr/core/test.rb +843 -0
  118. data/vendor/buildr/lib/buildr/core/transports.rb +565 -0
  119. data/vendor/buildr/lib/buildr/core/util.rb +537 -0
  120. data/vendor/buildr/lib/buildr/groovy.rb +20 -0
  121. data/vendor/buildr/lib/buildr/groovy/bdd.rb +106 -0
  122. data/vendor/buildr/lib/buildr/groovy/compiler.rb +153 -0
  123. data/vendor/buildr/lib/buildr/groovy/doc.rb +76 -0
  124. data/vendor/buildr/lib/buildr/groovy/shell.rb +57 -0
  125. data/vendor/buildr/lib/buildr/ide.rb +19 -0
  126. data/vendor/buildr/lib/buildr/ide/eclipse.rb +427 -0
  127. data/vendor/buildr/lib/buildr/ide/eclipse/java.rb +53 -0
  128. data/vendor/buildr/lib/buildr/ide/eclipse/plugin.rb +71 -0
  129. data/vendor/buildr/lib/buildr/ide/eclipse/scala.rb +68 -0
  130. data/vendor/buildr/lib/buildr/ide/idea.rb +576 -0
  131. data/vendor/buildr/lib/buildr/java.rb +25 -0
  132. data/vendor/buildr/lib/buildr/java/ant.rb +94 -0
  133. data/vendor/buildr/lib/buildr/java/bdd.rb +460 -0
  134. data/vendor/buildr/lib/buildr/java/cobertura.rb +297 -0
  135. data/vendor/buildr/lib/buildr/java/commands.rb +223 -0
  136. data/vendor/buildr/lib/buildr/java/compiler.rb +135 -0
  137. data/vendor/buildr/lib/buildr/java/deprecated.rb +141 -0
  138. data/vendor/buildr/lib/buildr/java/doc.rb +86 -0
  139. data/vendor/buildr/lib/buildr/java/ecj.rb +69 -0
  140. data/vendor/buildr/lib/buildr/java/emma.rb +244 -0
  141. data/vendor/buildr/lib/buildr/java/external.rb +73 -0
  142. data/vendor/buildr/lib/buildr/java/jruby.rb +122 -0
  143. data/vendor/buildr/lib/buildr/java/jtestr_result.rb +295 -0
  144. data/vendor/buildr/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  145. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  146. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  147. data/vendor/buildr/lib/buildr/java/packaging.rb +734 -0
  148. data/vendor/buildr/lib/buildr/java/pom.rb +178 -0
  149. data/vendor/buildr/lib/buildr/java/rjb.rb +154 -0
  150. data/vendor/buildr/lib/buildr/java/test_result.rb +101 -0
  151. data/vendor/buildr/lib/buildr/java/tests.rb +362 -0
  152. data/vendor/buildr/lib/buildr/java/version_requirement.rb +172 -0
  153. data/vendor/buildr/lib/buildr/packaging.rb +25 -0
  154. data/vendor/buildr/lib/buildr/packaging/archive.rb +535 -0
  155. data/vendor/buildr/lib/buildr/packaging/artifact.rb +903 -0
  156. data/vendor/buildr/lib/buildr/packaging/artifact_namespace.rb +984 -0
  157. data/vendor/buildr/lib/buildr/packaging/artifact_search.rb +140 -0
  158. data/vendor/buildr/lib/buildr/packaging/gems.rb +105 -0
  159. data/vendor/buildr/lib/buildr/packaging/package.rb +249 -0
  160. data/vendor/buildr/lib/buildr/packaging/tar.rb +189 -0
  161. data/vendor/buildr/lib/buildr/packaging/version_requirement.rb +192 -0
  162. data/vendor/buildr/lib/buildr/packaging/zip.rb +178 -0
  163. data/vendor/buildr/lib/buildr/packaging/ziptask.rb +356 -0
  164. data/vendor/buildr/lib/buildr/resources/buildr.icns +0 -0
  165. data/vendor/buildr/lib/buildr/resources/completed.png +0 -0
  166. data/vendor/buildr/lib/buildr/resources/failed.png +0 -0
  167. data/vendor/buildr/lib/buildr/resources/icons-license.txt +17 -0
  168. data/vendor/buildr/lib/buildr/run.rb +195 -0
  169. data/vendor/buildr/lib/buildr/scala.rb +26 -0
  170. data/vendor/buildr/lib/buildr/scala/bdd.rb +118 -0
  171. data/vendor/buildr/lib/buildr/scala/compiler.rb +242 -0
  172. data/vendor/buildr/lib/buildr/scala/doc.rb +142 -0
  173. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  174. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  175. data/vendor/buildr/lib/buildr/scala/shell.rb +52 -0
  176. data/vendor/buildr/lib/buildr/scala/tests.rb +171 -0
  177. data/vendor/buildr/lib/buildr/shell.rb +185 -0
  178. data/vendor/buildr/lib/buildr/version.rb +18 -0
  179. data/vendor/buildr/rakelib/all-in-one.rake +113 -0
  180. data/vendor/buildr/rakelib/checks.rake +57 -0
  181. data/vendor/buildr/rakelib/doc.rake +137 -0
  182. data/vendor/buildr/rakelib/metrics.rake +39 -0
  183. data/vendor/buildr/rakelib/package.rake +73 -0
  184. data/vendor/buildr/rakelib/release.rake +161 -0
  185. data/vendor/buildr/rakelib/rspec.rake +101 -0
  186. data/vendor/buildr/rakelib/setup.rake +66 -0
  187. data/vendor/buildr/rakelib/stage.rake +220 -0
  188. data/vendor/buildr/spec/addon/bnd_spec.rb +330 -0
  189. data/vendor/buildr/spec/addon/drb_spec.rb +328 -0
  190. data/vendor/buildr/spec/addon/jaxb_xjc_spec.rb +125 -0
  191. data/vendor/buildr/spec/core/application_spec.rb +631 -0
  192. data/vendor/buildr/spec/core/build_spec.rb +837 -0
  193. data/vendor/buildr/spec/core/cc_spec.rb +224 -0
  194. data/vendor/buildr/spec/core/checks_spec.rb +519 -0
  195. data/vendor/buildr/spec/core/common_spec.rb +725 -0
  196. data/vendor/buildr/spec/core/compile_spec.rb +658 -0
  197. data/vendor/buildr/spec/core/doc_spec.rb +195 -0
  198. data/vendor/buildr/spec/core/extension_spec.rb +201 -0
  199. data/vendor/buildr/spec/core/generate_spec.rb +33 -0
  200. data/vendor/buildr/spec/core/project_spec.rb +772 -0
  201. data/vendor/buildr/spec/core/run_spec.rb +93 -0
  202. data/vendor/buildr/spec/core/shell_spec.rb +146 -0
  203. data/vendor/buildr/spec/core/test_spec.rb +1320 -0
  204. data/vendor/buildr/spec/core/transport_spec.rb +544 -0
  205. data/vendor/buildr/spec/core/util_spec.rb +141 -0
  206. data/vendor/buildr/spec/groovy/bdd_spec.rb +80 -0
  207. data/vendor/buildr/spec/groovy/compiler_spec.rb +251 -0
  208. data/vendor/buildr/spec/groovy/doc_spec.rb +65 -0
  209. data/vendor/buildr/spec/ide/eclipse_spec.rb +739 -0
  210. data/vendor/buildr/spec/ide/idea_spec.rb +1144 -0
  211. data/vendor/buildr/spec/java/ant_spec.rb +37 -0
  212. data/vendor/buildr/spec/java/bdd_spec.rb +374 -0
  213. data/vendor/buildr/spec/java/cobertura_spec.rb +112 -0
  214. data/vendor/buildr/spec/java/commands_spec.rb +93 -0
  215. data/vendor/buildr/spec/java/compiler_spec.rb +252 -0
  216. data/vendor/buildr/spec/java/doc_spec.rb +56 -0
  217. data/vendor/buildr/spec/java/ecj_spec.rb +115 -0
  218. data/vendor/buildr/spec/java/emma_spec.rb +121 -0
  219. data/vendor/buildr/spec/java/external_spec.rb +56 -0
  220. data/vendor/buildr/spec/java/java_spec.rb +132 -0
  221. data/vendor/buildr/spec/java/packaging_spec.rb +1270 -0
  222. data/vendor/buildr/spec/java/run_spec.rb +78 -0
  223. data/vendor/buildr/spec/java/test_coverage_helper.rb +257 -0
  224. data/vendor/buildr/spec/java/tests_spec.rb +497 -0
  225. data/vendor/buildr/spec/packaging/archive_spec.rb +775 -0
  226. data/vendor/buildr/spec/packaging/artifact_namespace_spec.rb +743 -0
  227. data/vendor/buildr/spec/packaging/artifact_spec.rb +1066 -0
  228. data/vendor/buildr/spec/packaging/packaging_helper.rb +63 -0
  229. data/vendor/buildr/spec/packaging/packaging_spec.rb +719 -0
  230. data/vendor/buildr/spec/sandbox.rb +165 -0
  231. data/vendor/buildr/spec/scala/bdd_spec.rb +124 -0
  232. data/vendor/buildr/spec/scala/compiler_spec.rb +289 -0
  233. data/vendor/buildr/spec/scala/doc_spec.rb +88 -0
  234. data/vendor/buildr/spec/scala/scala.rb +38 -0
  235. data/vendor/buildr/spec/scala/tests_spec.rb +283 -0
  236. data/vendor/buildr/spec/spec_helpers.rb +369 -0
  237. data/vendor/buildr/spec/version_requirement_spec.rb +143 -0
  238. data/vendor/buildr/spec/xpath_matchers.rb +121 -0
  239. data/vendor/buildr/tests/BUILDR-320/Buildfile +29 -0
  240. data/vendor/buildr/tests/JavaSystemProperty/Buildfile +18 -0
  241. data/vendor/buildr/tests/JavaSystemProperty/src/test/java/FooTest.java +24 -0
  242. data/vendor/buildr/tests/compile_with_parent/Buildfile +18 -0
  243. data/vendor/buildr/tests/compile_with_parent/child/src/main/java/Foo.java +23 -0
  244. data/vendor/buildr/tests/helloWorld/Buildfile +20 -0
  245. data/vendor/buildr/tests/helloWorld/src/main/java/HelloWorld.java +23 -0
  246. data/vendor/buildr/tests/integration_testing.rb +56 -0
  247. data/vendor/buildr/tests/junit3/Buildfile +9 -0
  248. data/vendor/buildr/tests/junit3/src/main/java/Foo.java +23 -0
  249. data/vendor/buildr/tests/junit3/src/test/java/FooTest.java +28 -0
  250. data/vendor/buildr/tests/package_war_as_jar/Buildfile +15 -0
  251. data/vendor/buildr/tests/package_war_as_jar/src/main/java/Foo.java +19 -0
  252. metadata +524 -0
@@ -0,0 +1,1144 @@
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
+ describe Buildr::IntellijIdea do
21
+
22
+ def invoke_generate_task
23
+ task('idea:generate').invoke
24
+ end
25
+
26
+ def invoke_clean_task
27
+ task('idea:clean').invoke
28
+ end
29
+
30
+ def root_project_filename(project)
31
+ project._("#{project.name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.ipr")
32
+ end
33
+
34
+ def root_project_xml(project)
35
+ xml_document(root_project_filename(project))
36
+ end
37
+
38
+ def root_module_filename(project)
39
+ project._("#{project.name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.iml")
40
+ end
41
+
42
+ def root_module_xml(project)
43
+ xml_document(root_module_filename(project))
44
+ end
45
+
46
+ def subproject_module_filename(project, sub_project_name)
47
+ project._("#{sub_project_name}/#{sub_project_name}#{Buildr::IntellijIdea::IdeaFile::DEFAULT_SUFFIX}.iml")
48
+ end
49
+
50
+ def subproject_module_xml(project, sub_project_name)
51
+ xml_document(subproject_module_filename(project, sub_project_name))
52
+ end
53
+
54
+ def xml_document(filename)
55
+ File.should be_exist(filename)
56
+ REXML::Document.new(File.read(filename))
57
+ end
58
+
59
+ def xpath_to_module
60
+ "/project/component[@name='ProjectModuleManager']/modules/module"
61
+ end
62
+
63
+ describe "idea:clean" do
64
+ before do
65
+ write "foo.ipr"
66
+ write "foo.iml"
67
+ write "other.ipr"
68
+ write "other.iml"
69
+ mkdir_p 'bar'
70
+ write "bar/bar.iml"
71
+ write "bar/other.ipr"
72
+ write "bar/other.iml"
73
+
74
+ @foo = define "foo" do
75
+ define "bar"
76
+ end
77
+ invoke_clean_task
78
+ end
79
+
80
+ it "should remove the ipr file" do
81
+ File.exists?("foo.ipr").should be_false
82
+ end
83
+
84
+ it "should remove the project iml file" do
85
+ File.exists?("foo.iml").should be_false
86
+ end
87
+
88
+ it "should remove the subproject iml file" do
89
+ File.exists?("foo.iml").should be_false
90
+ end
91
+
92
+ it "should not remove other iml and ipr files" do
93
+ File.exists?("other.ipr").should be_true
94
+ File.exists?("other.iml").should be_true
95
+ File.exists?("bar/other.ipr").should be_true
96
+ File.exists?("bar/other.iml").should be_true
97
+ end
98
+ end
99
+
100
+ describe "idea:generate" do
101
+
102
+ def order_entry_xpath
103
+ "/module/component[@name='NewModuleRootManager']/orderEntry"
104
+ end
105
+
106
+ describe "with a single dependency" do
107
+ describe "of type compile" do
108
+ before do
109
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
110
+ @foo = define "foo" do
111
+ compile.with 'group:id:jar:1.0'
112
+ end
113
+ invoke_generate_task
114
+ end
115
+
116
+ it "generates one exported 'module-library' orderEntry in IML" do
117
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library', @exported='']/library/CLASSES/root", 1)
118
+ end
119
+ end
120
+
121
+ describe "with iml.main_dependencies override" do
122
+ before do
123
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
124
+ @foo = define "foo" do
125
+ iml.main_dependencies << 'group:id:jar:1.0'
126
+ end
127
+ invoke_generate_task
128
+ end
129
+
130
+ it "generates one exported 'module-library' orderEntry in IML" do
131
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library', @exported='']/library/CLASSES/root", 1)
132
+ end
133
+ end
134
+
135
+ describe "of type test" do
136
+ before do
137
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
138
+ @foo = define "foo" do
139
+ test.with 'group:id:jar:1.0'
140
+ end
141
+ invoke_generate_task
142
+ end
143
+
144
+ it "generates one non-exported 'module-library' orderEntry in IML" do
145
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported]/library/CLASSES/root", 0)
146
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library']/library/CLASSES/root", 1)
147
+ end
148
+ end
149
+
150
+ describe "with iml.test_dependencies override" do
151
+ before do
152
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
153
+ @foo = define "foo" do
154
+ iml.test_dependencies << 'group:id:jar:1.0'
155
+ end
156
+ invoke_generate_task
157
+ end
158
+
159
+ it "generates one non-exported 'module-library' orderEntry in IML" do
160
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library' and @exported]/library/CLASSES/root", 0)
161
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library']/library/CLASSES/root", 1)
162
+ end
163
+ end
164
+
165
+ describe "with sources artifact present" do
166
+ before do
167
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
168
+ artifact('group:id:jar:sources:1.0') { |t| write t.to_s }
169
+ @foo = define "foo" do
170
+ compile.with 'group:id:jar:1.0'
171
+ end
172
+ invoke_generate_task
173
+ end
174
+
175
+ it "generates 'module-library' orderEntry in IML with SOURCES specified" do
176
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library', @exported='']/library/SOURCES/root", 1)
177
+ end
178
+ end
179
+
180
+ describe "with local_repository_env_override set to nil" do
181
+ before do
182
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
183
+ @foo = define "foo" do
184
+ iml.local_repository_env_override = nil
185
+ compile.with 'group:id:jar:1.0'
186
+ end
187
+ invoke_generate_task
188
+ end
189
+
190
+ it "generates orderEntry with absolute path for classes jar" do
191
+ root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
192
+ "jar://$MODULE_DIR$/home/.m2/repository/group/id/1.0/id-1.0.jar!/")
193
+ end
194
+ end
195
+ describe "with local_repository_env_override set to MAVEN_REPOSITORY" do
196
+ before do
197
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
198
+ @foo = define "foo" do
199
+ iml.local_repository_env_override = 'MAVEN_REPOSITORY'
200
+ compile.with 'group:id:jar:1.0'
201
+ end
202
+ invoke_generate_task
203
+ end
204
+
205
+ it "generates orderEntry with absolute path for classes jar" do
206
+ root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
207
+ "jar://$MAVEN_REPOSITORY$/group/id/1.0/id-1.0.jar!/")
208
+ end
209
+ end
210
+ end
211
+
212
+ describe "with multiple dependencies" do
213
+ before do
214
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
215
+ artifact('group:id2:jar:1.0') { |t| write t.to_s }
216
+ @foo = define "foo" do
217
+ compile.with 'group:id:jar:1.0', 'group:id2:jar:1.0'
218
+ end
219
+ invoke_generate_task
220
+ end
221
+
222
+ it "generates multiple 'module-library' orderEntry in IML" do
223
+ root_module_xml(@foo).should have_nodes("#{order_entry_xpath}[@type='module-library']", 2)
224
+ end
225
+ end
226
+
227
+ describe "with a single non artifact dependency" do
228
+ before do
229
+ @foo = define "foo" do
230
+ filename = _("foo-dep.jar")
231
+ File.open(filename, "wb") { |t| write "Hello" }
232
+ compile.with filename
233
+ end
234
+ invoke_generate_task
235
+ end
236
+
237
+ it "generates one exported 'module-library' orderEntry in IML" do
238
+ root_module_xml(@foo).should match_xpath("#{order_entry_xpath}/library/CLASSES/root/@url",
239
+ "jar://$MODULE_DIR$/foo-dep.jar!/")
240
+ end
241
+ end
242
+
243
+ describe "with extra_modules specified" do
244
+ before do
245
+ @foo = define "foo" do
246
+ ipr.extra_modules << 'other.iml'
247
+ ipr.extra_modules << 'other_other.iml'
248
+ end
249
+ invoke_generate_task
250
+ end
251
+
252
+ it "generate an IPR with extra modules specified" do
253
+ doc = xml_document(@foo._("foo.ipr"))
254
+ doc.should have_nodes("#{xpath_to_module}", 3)
255
+ module_ref = "$PROJECT_DIR$/foo.iml"
256
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
257
+ module_ref = "$PROJECT_DIR$/other.iml"
258
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
259
+ module_ref = "$PROJECT_DIR$/other_other.iml"
260
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
261
+ end
262
+ end
263
+
264
+ describe "with web and webservice facet added to root project" do
265
+ before do
266
+ @foo = define "foo" do
267
+ iml.add_facet("Web", "web") do |facet|
268
+ facet.configuration do |conf|
269
+ conf.descriptors do |desc|
270
+ desc.deploymentDescriptor :name => 'web.xml',
271
+ :url => "file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml",
272
+ :optional => "false", :version => "2.4"
273
+ end
274
+ conf.webroots do |webroots|
275
+ webroots.root :url => "file://$MODULE_DIR$/src/main/webapp", :relative => "/"
276
+ end
277
+ end
278
+ end
279
+ iml.add_facet("WebServices Client", "WebServicesClient") do |facet|
280
+ facet.configuration "ws.engine" => "Glassfish / JAX-WS 2.X RI / Metro 1.X / JWSDP 2.0"
281
+ end
282
+ define 'bar'
283
+ end
284
+ invoke_generate_task
285
+ end
286
+
287
+ it "generates an IML for root project with a web and webservice facet" do
288
+ doc = xml_document(@foo._("foo.iml"))
289
+ facet_xpath = "/module/component[@name='FacetManager']/facet"
290
+ doc.should have_nodes(facet_xpath, 2)
291
+ doc.should have_xpath("#{facet_xpath}[@type='web', @name='Web']")
292
+ doc.should have_xpath("#{facet_xpath}[@type='WebServicesClient', @name='WebServices Client']")
293
+ end
294
+ end
295
+
296
+ describe "with iml.group specified" do
297
+ before do
298
+ @foo = define "foo" do
299
+ iml.group = true
300
+ define 'bar' do
301
+ define 'baz' do
302
+
303
+ end
304
+ end
305
+ define 'rab' do
306
+ iml.group = "MyGroup"
307
+ end
308
+ end
309
+ invoke_generate_task
310
+ end
311
+
312
+ it "generate an IPR with correct group references" do
313
+ doc = xml_document(@foo._("foo.ipr"))
314
+ doc.should have_nodes("#{xpath_to_module}", 4)
315
+ module_ref = "$PROJECT_DIR$/foo.iml"
316
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']")
317
+ module_ref = "$PROJECT_DIR$/rab/rab.iml"
318
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}' @group = 'MyGroup']")
319
+ module_ref = "$PROJECT_DIR$/bar/bar.iml"
320
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}' @group = 'foo']")
321
+ module_ref = "$PROJECT_DIR$/bar/baz/baz.iml"
322
+ doc.should have_xpath("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}' @group = 'foo/bar']")
323
+ end
324
+ end
325
+
326
+ describe "with a single project definition" do
327
+ describe "and default naming" do
328
+ before do
329
+ @foo = define "foo"
330
+ invoke_generate_task
331
+ end
332
+
333
+ it "generates a single IPR" do
334
+ Dir[@foo._("**/*.ipr")].should have(1).entry
335
+ end
336
+
337
+ it "generate an IPR in the root directory" do
338
+ File.should be_exist(@foo._("foo.ipr"))
339
+ end
340
+
341
+ it "generates a single IML" do
342
+ Dir[@foo._("**/*.iml")].should have(1).entry
343
+ end
344
+
345
+ it "generates an IML in the root directory" do
346
+ File.should be_exist(@foo._("foo.iml"))
347
+ end
348
+
349
+ it "generate an IPR with the reference to correct module file" do
350
+ File.should be_exist(@foo._("foo.ipr"))
351
+ doc = xml_document(@foo._("foo.ipr"))
352
+ module_ref = "$PROJECT_DIR$/foo.iml"
353
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
354
+ end
355
+ end
356
+
357
+ describe "with no_iml generation disabled" do
358
+ before do
359
+ @foo = define "foo" do
360
+ project.no_iml
361
+ end
362
+ invoke_generate_task
363
+ end
364
+
365
+ it "generates no IML" do
366
+ Dir[@foo._("**/*.iml")].should have(0).entry
367
+ end
368
+
369
+ it "generate an IPR with no references" do
370
+ File.should be_exist(@foo._("foo.ipr"))
371
+ doc = xml_document(@foo._("foo.ipr"))
372
+ doc.should have_nodes("#{xpath_to_module}", 0)
373
+ end
374
+ end
375
+
376
+ describe "with ipr generation disabled" do
377
+ before do
378
+ @foo = define "foo" do
379
+ project.no_ipr
380
+ end
381
+ invoke_generate_task
382
+ end
383
+
384
+ it "generates a single IML" do
385
+ Dir[@foo._("**/*.iml")].should have(1).entry
386
+ end
387
+
388
+ it "generate no IPR" do
389
+ File.should_not be_exist(@foo._("foo.ipr"))
390
+ end
391
+ end
392
+
393
+ describe "and id overrides" do
394
+ before do
395
+ @foo = define "foo" do
396
+ ipr.id = 'fooble'
397
+ iml.id = 'feap'
398
+ define "bar" do
399
+ iml.id = "baz"
400
+ end
401
+ end
402
+ invoke_generate_task
403
+ end
404
+
405
+ it "generate an IPR in the root directory" do
406
+ File.should be_exist(@foo._("fooble.ipr"))
407
+ end
408
+
409
+ it "generates an IML in the root directory" do
410
+ File.should be_exist(@foo._("feap.iml"))
411
+ end
412
+
413
+ it "generates an IML in the subproject directory" do
414
+ File.should be_exist(@foo._("bar/baz.iml"))
415
+ end
416
+
417
+ it "generate an IPR with the reference to correct module file" do
418
+ File.should be_exist(@foo._("fooble.ipr"))
419
+ doc = xml_document(@foo._("fooble.ipr"))
420
+ module_ref = "$PROJECT_DIR$/feap.iml"
421
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
422
+ end
423
+ end
424
+
425
+ describe "and a suffix defined" do
426
+ before do
427
+ @foo = define "foo" do
428
+ ipr.suffix = '-ipr-suffix'
429
+ iml.suffix = '-iml-suffix'
430
+ end
431
+ invoke_generate_task
432
+ end
433
+
434
+ it "generate an IPR in the root directory" do
435
+ File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
436
+ end
437
+
438
+ it "generates an IML in the root directory" do
439
+ File.should be_exist(@foo._("foo-iml-suffix.iml"))
440
+ end
441
+
442
+ it "generate an IPR with the reference to correct module file" do
443
+ File.should be_exist(@foo._("foo-ipr-suffix.ipr"))
444
+ doc = xml_document(@foo._("foo-ipr-suffix.ipr"))
445
+ doc.should have_nodes("#{xpath_to_module}", 1)
446
+ module_ref = "$PROJECT_DIR$/foo-iml-suffix.iml"
447
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
448
+ end
449
+ end
450
+ end
451
+
452
+ describe "with a subproject" do
453
+ before do
454
+ @foo = define "foo" do
455
+ define 'bar'
456
+ end
457
+ invoke_generate_task
458
+ end
459
+
460
+ it "creates the subproject directory" do
461
+ File.should be_exist(@foo._("bar"))
462
+ end
463
+
464
+ it "generates an IML in the subproject directory" do
465
+ File.should be_exist(@foo._("bar/bar.iml"))
466
+ end
467
+
468
+ it "generate an IPR with the reference to correct module file" do
469
+ File.should be_exist(@foo._("foo.ipr"))
470
+ doc = xml_document(@foo._("foo.ipr"))
471
+ doc.should have_nodes("#{xpath_to_module}", 2)
472
+ module_ref = "$PROJECT_DIR$/foo.iml"
473
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
474
+ module_ref = "$PROJECT_DIR$/bar/bar.iml"
475
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://#{module_ref}', @filepath='#{module_ref}']", 1)
476
+ end
477
+ end
478
+
479
+ describe "with base_dir specified" do
480
+ before do
481
+ @foo = define "foo" do
482
+ define('bar', :base_dir => 'fe') do
483
+ define('baz', :base_dir => 'fi') do
484
+ define('foe')
485
+ end
486
+ define('fum')
487
+ end
488
+ end
489
+ invoke_generate_task
490
+ end
491
+
492
+ it "generates a subproject IML in the specified directory" do
493
+ File.should be_exist(@foo._("fe/bar.iml"))
494
+ end
495
+
496
+ it "generates a sub-subproject IML in the specified directory" do
497
+ File.should be_exist(@foo._("fi/baz.iml"))
498
+ end
499
+
500
+ it "generates a sub-sub-subproject IML that inherits the specified directory" do
501
+ File.should be_exist(@foo._("fi/foe/foe.iml"))
502
+ end
503
+
504
+ it "generates a sub-subproject IML that inherits the specified directory" do
505
+ File.should be_exist(@foo._("fe/fum/fum.iml"))
506
+ end
507
+
508
+ it "generate an IPR with the references to correct module files" do
509
+ doc = xml_document(@foo._("foo.ipr"))
510
+ doc.should have_nodes("#{xpath_to_module}", 5)
511
+ ["foo.iml", "fe/bar.iml", "fi/baz.iml", "fi/foe/foe.iml", "fe/fum/fum.iml"].each do |module_ref|
512
+ doc.should have_nodes("#{xpath_to_module}[@fileurl='file://$PROJECT_DIR$/#{module_ref}', @filepath='$PROJECT_DIR$/#{module_ref}']", 1)
513
+ end
514
+ end
515
+ end
516
+
517
+ describe "with extensive intermodule dependencies" do
518
+ before do
519
+ mkdir_p 'foo/src/main/resources'
520
+ mkdir_p 'foo/src/main/java/foo'
521
+ touch 'foo/src/main/java/foo/Foo.java' # needed so that buildr will treat as a java project
522
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
523
+ define "root" do
524
+ repositories.remote << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/'
525
+ project.version = "2.5.2"
526
+ define 'foo' do
527
+ resources.from _(:source, :main, :resources)
528
+ compile.with 'group:id:jar:1.0'
529
+ test.using(:junit)
530
+ package(:jar)
531
+ end
532
+
533
+ define 'bar' do
534
+ # internally transitive dependencies on foo, both runtime and test
535
+ compile.with project('root:foo'), project('root:foo').compile.dependencies
536
+ test.using(:junit).with [project('root:foo').test.compile.target,
537
+ project('root:foo').test.resources.target,
538
+ project('root:foo').test.compile.dependencies].compact
539
+ package(:jar)
540
+ end
541
+ end
542
+
543
+ invoke_generate_task
544
+ @bar_iml = xml_document(project('root:bar')._('bar.iml'))
545
+ @bar_lib_urls = @bar_iml.get_elements("//orderEntry[@type='module-library']/library/CLASSES/root").collect do |root|
546
+ root.attribute('url').to_s
547
+ end
548
+ end
549
+
550
+ it "depends on the associated module exactly once" do
551
+ @bar_iml.should have_nodes("//orderEntry[@type='module', @module-name='foo']", 1)
552
+ end
553
+
554
+ it "does not depend on the other project's packaged JAR" do
555
+ @bar_lib_urls.grep(%r{#{project('root:foo').packages.first}}).should == []
556
+ end
557
+
558
+ it "does not depend on the the other project's target/classes directory" do
559
+ @bar_lib_urls.grep(%r{foo/target/classes}).should == []
560
+ end
561
+
562
+ it "depends on the the other project's target/resources directory" do
563
+ @bar_lib_urls.grep(%r{file://\$MODULE_DIR\$/../foo/target/resources}).size.should == 1
564
+ end
565
+ end
566
+
567
+ describe "with a single project definition" do
568
+ before do
569
+ @foo = define "foo"
570
+ end
571
+
572
+ it "informs the user about generating IPR" do
573
+ lambda { invoke_generate_task }.should show_info(/Writing (.+)\/foo\.ipr/)
574
+ end
575
+
576
+ it "informs the user about generating IML" do
577
+ lambda { invoke_generate_task }.should show_info(/Writing (.+)\/foo\.iml/)
578
+ end
579
+ end
580
+ describe "with a subproject" do
581
+ before do
582
+ @foo = define "foo" do
583
+ define 'bar'
584
+ end
585
+ end
586
+
587
+ it "informs the user about generating subporoject IML" do
588
+ lambda { invoke_generate_task }.should show_info(/Writing (.+)\/bar\/bar\.iml/)
589
+ end
590
+ end
591
+
592
+ describe "with compile.options.source = '1.6'" do
593
+
594
+ before do
595
+ @foo = define "foo" do
596
+ compile.options.source = '1.5'
597
+ end
598
+ invoke_generate_task
599
+ end
600
+
601
+ it "generate an ProjectRootManager with 1.5 jdk specified" do
602
+ #raise File.read(@foo._("foo.ipr"))
603
+ xml_document(@foo._("foo.ipr")).
604
+ should have_xpath("/project/component[@name='ProjectRootManager' and @project-jdk-name = '1.5' and @languageLevel = 'JDK_1_5']")
605
+ end
606
+
607
+ it "generates a ProjectDetails component with the projectName option set" do
608
+ xml_document(@foo._("foo.ipr")).
609
+ should have_xpath("/project/component[@name='ProjectDetails']/option[@name = 'projectName' and @value = 'foo']")
610
+ end
611
+ end
612
+
613
+ describe "with compile.options.source = '1.6'" do
614
+ before do
615
+ @foo = define "foo" do
616
+ compile.options.source = '1.6'
617
+ end
618
+ invoke_generate_task
619
+ end
620
+
621
+ it "generate an ProjectRootManager with 1.6 jdk specified" do
622
+ xml_document(@foo._("foo.ipr")).
623
+ should have_xpath("/project/component[@name='ProjectRootManager' and @project-jdk-name = '1.6' and @languageLevel = 'JDK_1_6']")
624
+ end
625
+ end
626
+
627
+ describe "with iml.skip_content! specified" do
628
+ before do
629
+ @foo = define "foo" do
630
+ iml.skip_content!
631
+ end
632
+ invoke_generate_task
633
+ end
634
+
635
+ it "generate an IML with no content section" do
636
+ doc = xml_document(@foo._(root_module_filename(@foo)))
637
+ doc.should_not have_xpath("/module/component[@name='NewModuleRootManager']/content")
638
+ end
639
+ end
640
+
641
+ describe "with iml.skip_content! not specified and standard layout" do
642
+ before do
643
+ @foo = define "foo" do
644
+ end
645
+ invoke_generate_task
646
+ end
647
+
648
+ it "generate an IML with content section" do
649
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content")
650
+ end
651
+
652
+ it "generate an exclude in content section for reports" do
653
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
654
+ end
655
+
656
+ it "generate an exclude in content section for target" do
657
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
658
+ end
659
+ end
660
+
661
+ describe "with subprojects" do
662
+ before do
663
+ @foo = define "foo" do
664
+ define "bar" do
665
+ compile.from _(:source, :main, :bar)
666
+ end
667
+ end
668
+ invoke_generate_task
669
+ @bar_doc = xml_document(project('foo:bar')._('bar.iml'))
670
+ end
671
+
672
+ it "generates the correct source directories" do
673
+ @bar_doc.should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/main/bar']")
674
+ end
675
+
676
+ it "generates the correct exclude directories" do
677
+ @bar_doc.should have_xpath("//content/excludeFolder[@url='file://$MODULE_DIR$/target']")
678
+ end
679
+ end
680
+
681
+ describe "with overrides" do
682
+ before do
683
+ @foo = define "foo" do
684
+ compile.from _(:source, :main, :bar)
685
+ iml.main_source_directories << _(:source, :main, :baz)
686
+ iml.test_source_directories << _(:source, :test, :foo)
687
+ end
688
+ invoke_generate_task
689
+ end
690
+
691
+ it "generates the correct main source directories" do
692
+ root_module_xml(@foo).should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/main/baz' and @isTestSource='false']")
693
+ end
694
+
695
+ it "generates the correct test source directories" do
696
+ root_module_xml(@foo).should have_xpath("//content/sourceFolder[@url='file://$MODULE_DIR$/src/test/foo' and @isTestSource='true']")
697
+ end
698
+ end
699
+
700
+ describe "with report dir outside content" do
701
+ before do
702
+ layout = Layout::Default.new
703
+ layout[:reports] = "../reports"
704
+
705
+ @foo = define "foo", :layout => layout do
706
+ end
707
+ invoke_generate_task
708
+ end
709
+
710
+ it "generate an exclude in content section for target" do
711
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
712
+ end
713
+
714
+ it "generates an content section without an exclude for report dir" do
715
+ root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
716
+ end
717
+ end
718
+
719
+ describe "with target dir outside content" do
720
+ before do
721
+ layout = Layout::Default.new
722
+ layout[:target] = "../target"
723
+ layout[:target, :main] = "../target"
724
+
725
+ @foo = define "foo", :layout => layout do
726
+ end
727
+ invoke_generate_task
728
+ end
729
+
730
+ it "generate an exclude in content section for reports" do
731
+ root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
732
+ end
733
+
734
+ it "generates an content section without an exclude for target dir" do
735
+ root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
736
+ end
737
+ end
738
+
739
+ describe "templates" do
740
+
741
+ def ipr_template
742
+ return <<PROJECT_XML
743
+ <?xml version="1.0" encoding="UTF-8"?>
744
+ <project version="4">
745
+ <component name="SvnBranchConfigurationManager">
746
+ <option name="mySupportsUserInfoFilter" value="false" />
747
+ </component>
748
+ </project>
749
+ PROJECT_XML
750
+ end
751
+
752
+ def ipr_existing
753
+ return <<PROJECT_XML
754
+ <?xml version="1.0" encoding="UTF-8"?>
755
+ <project version="4">
756
+ <component name="AntConfiguration">
757
+ <defaultAnt bundledAnt="true" />
758
+ </component>
759
+ <component name="SvnBranchConfigurationManager">
760
+ <option name="mySupportsUserInfoFilter" value="true" />
761
+ </component>
762
+ <component name="ProjectModuleManager">
763
+ <modules>
764
+ <module fileurl="file://$PROJECT_DIR$/existing.iml" filepath="$PROJECT_DIR$/existing.iml" />
765
+ </modules>
766
+ </component>
767
+ </project>
768
+ PROJECT_XML
769
+ end
770
+
771
+ def ipr_from_template_xpath
772
+ "/project/component[@name='SvnBranchConfigurationManager']/option[@name = 'mySupportsUserInfoFilter' and @value = 'false']"
773
+ end
774
+
775
+ def ipr_from_existing_xpath
776
+ "/project/component[@name='AntConfiguration']"
777
+ end
778
+
779
+ def ipr_from_existing_shadowing_template_xpath
780
+ "/project/component[@name='SvnBranchConfigurationManager']/option[@name = 'mySupportsUserInfoFilter' and @value = 'true']"
781
+ end
782
+
783
+ def ipr_from_existing_shadowing_generated_xpath
784
+ "/project/component[@name='ProjectModuleManager']/modules/module[@fileurl = 'file://$PROJECT_DIR$/existing.iml']"
785
+ end
786
+
787
+ def ipr_from_generated_xpath
788
+ "/project/component[@name='ProjectModuleManager']/modules/module[@fileurl = 'file://$PROJECT_DIR$/foo.iml']"
789
+ end
790
+
791
+ def iml_template
792
+ return <<PROJECT_XML
793
+ <?xml version="1.0" encoding="UTF-8"?>
794
+ <module type="JAVA_MODULE" version="4">
795
+ <component name="FacetManager">
796
+ <facet type="JRUBY" name="JRuby">
797
+ <configuration number="0">
798
+ <JRUBY_FACET_CONFIG_ID NAME="JRUBY_SDK_NAME" VALUE="JRuby SDK 1.4.0RC1" />
799
+ </configuration>
800
+ </facet>
801
+ </component>
802
+ </module>
803
+ PROJECT_XML
804
+ end
805
+
806
+ def iml_existing
807
+ return <<PROJECT_XML
808
+ <?xml version="1.0" encoding="UTF-8"?>
809
+ <module type="JAVA_MODULE" version="4">
810
+ <component name="FunkyPlugin"/>
811
+ <component name="FacetManager">
812
+ <facet type="SCALA" name="Scala"/>
813
+ </component>
814
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
815
+ <exclude-output />
816
+ <content url="file://$MODULE_DIR$"/>
817
+ <orderEntry type="inheritedJdk" />
818
+ <orderEntry type="sourceFolder" forTests="false" />
819
+ <orderEntry type="module" module-name="buildr-bnd" exported="" />
820
+ </component>
821
+ </module>
822
+ PROJECT_XML
823
+ end
824
+
825
+ def iml_from_template_xpath
826
+ "/module/component[@name='FacetManager']/facet[@type = 'JRUBY']"
827
+ end
828
+
829
+ def iml_from_existing_xpath
830
+ "/module/component[@name='FunkyPlugin']"
831
+ end
832
+
833
+ def iml_from_existing_shadowing_template_xpath
834
+ "/module/component[@name='FacetManager']/facet[@type = 'SCALA']"
835
+ end
836
+
837
+ def iml_from_existing_shadowing_generated_xpath
838
+ "/module/component[@name='NewModuleRootManager']/orderEntry[@module-name = 'buildr-bnd']"
839
+ end
840
+
841
+ def iml_from_generated_xpath
842
+ "/module/component[@name='NewModuleRootManager']/orderEntry[@type = 'module-library']"
843
+ end
844
+
845
+ describe "with existing project files" do
846
+ before do
847
+ write "foo.ipr", ipr_existing
848
+ write "foo.iml", iml_existing
849
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
850
+ @foo = define "foo" do
851
+ ipr.template = nil
852
+ iml.template = nil
853
+ compile.with 'group:id:jar:1.0'
854
+ end
855
+ invoke_generate_task
856
+ end
857
+
858
+ it "replaces ProjectModuleManager component in existing ipr file" do
859
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
860
+ xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_generated_xpath)
861
+ end
862
+
863
+ it "merges component in existing ipr file" do
864
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_existing_xpath)
865
+ end
866
+
867
+ def iml_from_generated_xpath
868
+ "/module/component[@name='NewModuleRootManager']/orderEntry[@type = 'module-library']"
869
+ end
870
+
871
+ it "replaces NewModuleRootManager component in existing iml file" do
872
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
873
+ xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_generated_xpath)
874
+ end
875
+
876
+ it "merges component in existing iml file" do
877
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_existing_xpath)
878
+ end
879
+ end
880
+
881
+ describe "with an iml template" do
882
+ before do
883
+ write "module.template.iml", iml_template
884
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
885
+ @foo = define "foo" do
886
+ ipr.template = nil
887
+ iml.template = "module.template.iml"
888
+ compile.with 'group:id:jar:1.0'
889
+ end
890
+ invoke_generate_task
891
+ end
892
+
893
+ it "replaces generated components" do
894
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
895
+ end
896
+
897
+ it "merges component in iml template" do
898
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_template_xpath)
899
+ end
900
+ end
901
+
902
+ describe "with an iml template and existing iml" do
903
+ before do
904
+ write "module.template.iml", iml_template
905
+ write "foo.iml", iml_existing
906
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
907
+ @foo = define "foo" do
908
+ ipr.template = nil
909
+ iml.template = "module.template.iml"
910
+ compile.with 'group:id:jar:1.0'
911
+ end
912
+ invoke_generate_task
913
+ end
914
+
915
+ it "replaces generated components" do
916
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_generated_xpath)
917
+ end
918
+
919
+ it "merges component in iml template" do
920
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_template_xpath)
921
+ end
922
+
923
+ it "merges components not in iml template and not generated by task" do
924
+ xml_document(@foo._("foo.iml")).should have_xpath(iml_from_existing_xpath)
925
+ xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_template_xpath)
926
+ xml_document(@foo._("foo.iml")).should_not have_xpath(iml_from_existing_shadowing_generated_xpath)
927
+ end
928
+ end
929
+
930
+ describe "with an ipr template" do
931
+ before do
932
+ write "project.template.iml", ipr_template
933
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
934
+ @foo = define "foo" do
935
+ ipr.template = "project.template.iml"
936
+ iml.template = nil
937
+ compile.with 'group:id:jar:1.0'
938
+ end
939
+ invoke_generate_task
940
+ end
941
+
942
+ it "replaces generated component in ipr template" do
943
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
944
+ end
945
+
946
+ it "merges component in ipr template" do
947
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_template_xpath)
948
+ end
949
+ end
950
+
951
+ describe "with an ipr template and existing ipr" do
952
+ before do
953
+ write "project.template.iml", ipr_template
954
+ write "foo.ipr", ipr_existing
955
+ artifact('group:id:jar:1.0') { |t| write t.to_s }
956
+ @foo = define "foo" do
957
+ ipr.template = "project.template.iml"
958
+ iml.template = nil
959
+ compile.with 'group:id:jar:1.0'
960
+ end
961
+ invoke_generate_task
962
+ end
963
+
964
+ it "replaces generated component in ipr template" do
965
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_generated_xpath)
966
+ end
967
+
968
+ it "merges component in ipr template" do
969
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_template_xpath)
970
+ end
971
+
972
+ it "merges components not in ipr template and not generated by task" do
973
+ xml_document(@foo._("foo.ipr")).should have_xpath(ipr_from_existing_xpath)
974
+ xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_generated_xpath)
975
+ xml_document(@foo._("foo.ipr")).should_not have_xpath(ipr_from_existing_shadowing_template_xpath)
976
+ end
977
+ end
978
+ end
979
+ end
980
+
981
+ describe "Buildr::IntellijIdea::IdeaModule" do
982
+
983
+ describe "with no settings" do
984
+ before do
985
+ @foo = define "foo"
986
+ end
987
+
988
+ it "has correct default iml.type setting" do
989
+ @foo.iml.type.should == "JAVA_MODULE"
990
+ end
991
+
992
+ it "has correct default iml.local_repository_env_override setting" do
993
+ @foo.iml.local_repository_env_override.should == "MAVEN_REPOSITORY"
994
+ end
995
+ end
996
+
997
+ describe "settings inherited in subprojects" do
998
+ before do
999
+ mkdir_p 'bar'
1000
+ @foo = define "foo" do
1001
+ iml.type = "FOO_MODULE_TYPE"
1002
+ define 'bar'
1003
+ end
1004
+ invoke_generate_task
1005
+ end
1006
+
1007
+ it "generates root IML with specified type" do
1008
+ module_file = root_module_filename(@foo)
1009
+ File.should be_exist(module_file)
1010
+ File.read(module_file).should =~ /FOO_MODULE_TYPE/
1011
+ end
1012
+
1013
+ it "generates subproject IML with inherited type" do
1014
+ module_file = subproject_module_filename(@foo, "bar")
1015
+ File.should be_exist(module_file)
1016
+ File.read(module_file).should =~ /FOO_MODULE_TYPE/
1017
+ end
1018
+
1019
+ end
1020
+
1021
+ describe "with local_repository_env_override = nil" do
1022
+ describe "base_directory on different drive on windows" do
1023
+ before do
1024
+ @foo = define "foo", :base_dir => "C:/bar" do
1025
+ iml.local_repository_env_override = nil
1026
+ end
1027
+ end
1028
+
1029
+ it "generates relative paths correctly" do
1030
+ @foo.iml.send(:resolve_path, "E:/foo").should eql('E:/foo')
1031
+ end
1032
+ end
1033
+
1034
+ describe "base_directory on same drive on windows" do
1035
+ before do
1036
+ @foo = define "foo", :base_dir => "C:/bar" do
1037
+ iml.local_repository_env_override = nil
1038
+ end
1039
+ end
1040
+
1041
+ it "generates relative paths correctly" do
1042
+ @foo.iml.send(:resolve_path, "C:/foo").should eql('$MODULE_DIR$/../foo')
1043
+ end
1044
+ end
1045
+
1046
+ end
1047
+ end
1048
+
1049
+ describe "project extension" do
1050
+ it "provides an 'idea:generate' task" do
1051
+ Rake::Task.tasks.detect { |task| task.to_s == "idea:generate" }.should_not be_nil
1052
+ end
1053
+
1054
+ it "documents the 'idea:generate' task" do
1055
+ Rake::Task.tasks.detect { |task| task.to_s == "idea:generate" }.comment.should_not be_nil
1056
+ end
1057
+
1058
+ it "provides an 'idea:clean' task" do
1059
+ Rake::Task.tasks.detect { |task| task.to_s == "idea:clean" }.should_not be_nil
1060
+ end
1061
+
1062
+ it "documents the 'idea:clean' task" do
1063
+ Rake::Task.tasks.detect { |task| task.to_s == "idea:clean" }.comment.should_not be_nil
1064
+ end
1065
+
1066
+ it "removes the 'idea' task" do
1067
+ Rake::Task.tasks.detect { |task| task.to_s == "idea" }.should be_nil
1068
+ end
1069
+
1070
+ it "removes the 'idea7x' task" do
1071
+ Rake::Task.tasks.detect { |task| task.to_s == "idea7x" }.should be_nil
1072
+ end
1073
+
1074
+ it "removes the 'idea7x:clean' task" do
1075
+ Rake::Task.tasks.detect { |task| task.to_s == "idea7x:clean" }.should be_nil
1076
+ end
1077
+
1078
+ describe "#no_iml" do
1079
+ it "makes #iml? false" do
1080
+ @foo = define "foo" do
1081
+ project.no_iml
1082
+ end
1083
+ @foo.iml?.should be_false
1084
+ end
1085
+ end
1086
+
1087
+ describe "#iml" do
1088
+ before do
1089
+ define "foo" do
1090
+ iml.suffix = "-top"
1091
+
1092
+ define "bar" do
1093
+ iml.suffix = "-mid"
1094
+
1095
+ define "baz" do
1096
+ end
1097
+ end
1098
+ end
1099
+ end
1100
+
1101
+ it "inherits the direct parent's IML settings" do
1102
+ project('foo:bar:baz').iml.suffix.should == "-mid"
1103
+ end
1104
+
1105
+ it "does not modify the parent's IML settings" do
1106
+ project('foo').iml.suffix.should == "-top"
1107
+ end
1108
+
1109
+ it "works even when the parent has no IML" do
1110
+ lambda {
1111
+ define "a" do
1112
+ project.no_iml
1113
+ define "b" do
1114
+ iml.suffix = "-alone"
1115
+ end
1116
+ end
1117
+ }.should_not raise_error
1118
+ end
1119
+
1120
+ it "inherits from the first ancestor which has an IML" do
1121
+ define "a" do
1122
+ iml.suffix = "-a"
1123
+ define "b" do
1124
+ iml.suffix = "-b"
1125
+ define "c" do
1126
+ project.no_iml
1127
+ define "d" do
1128
+ project.no_iml
1129
+ define "e" do
1130
+ project.no_iml
1131
+ define "f" do
1132
+ end
1133
+ end
1134
+ end
1135
+ end
1136
+ end
1137
+ end
1138
+
1139
+ project("a:b:c:d:e:f").iml.suffix.should == "-b"
1140
+ end
1141
+ end
1142
+ end
1143
+
1144
+ end