mguymon-buildr 1.4.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data/CHANGELOG +1291 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +44 -0
  6. data/_buildr +35 -0
  7. data/_jbuildr +35 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/bnd.rb +147 -0
  10. data/addon/buildr/cobertura.rb +22 -0
  11. data/addon/buildr/drb.rb +281 -0
  12. data/addon/buildr/emma.rb +22 -0
  13. data/addon/buildr/hibernate.rb +149 -0
  14. data/addon/buildr/javacc.rb +85 -0
  15. data/addon/buildr/jaxb_xjc.rb +72 -0
  16. data/addon/buildr/jdepend.rb +60 -0
  17. data/addon/buildr/jetty.rb +248 -0
  18. data/addon/buildr/jibx.rb +86 -0
  19. data/addon/buildr/nailgun.rb +221 -0
  20. data/addon/buildr/openjpa.rb +88 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  23. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  27. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  28. data/addon/buildr/protobuf.rb +88 -0
  29. data/addon/buildr/xmlbeans.rb +93 -0
  30. data/bin/buildr +19 -0
  31. data/buildr.buildfile +58 -0
  32. data/buildr.gemspec +78 -0
  33. data/doc/_config.yml +1 -0
  34. data/doc/_layouts/default.html +90 -0
  35. data/doc/_layouts/preface.html +22 -0
  36. data/doc/artifacts.textile +217 -0
  37. data/doc/building.textile +276 -0
  38. data/doc/contributing.textile +268 -0
  39. data/doc/css/default.css +236 -0
  40. data/doc/css/print.css +101 -0
  41. data/doc/css/syntax.css +23 -0
  42. data/doc/download.textile +151 -0
  43. data/doc/extending.textile +212 -0
  44. data/doc/images/1442160941-frontcover.jpg +0 -0
  45. data/doc/images/asf-logo.gif +0 -0
  46. data/doc/images/asf-logo.png +0 -0
  47. data/doc/images/buildr-hires.png +0 -0
  48. data/doc/images/buildr.png +0 -0
  49. data/doc/images/favicon.png +0 -0
  50. data/doc/images/growl-icon.tiff +0 -0
  51. data/doc/images/note.png +0 -0
  52. data/doc/images/project-structure.png +0 -0
  53. data/doc/images/tip.png +0 -0
  54. data/doc/images/zbuildr.png +0 -0
  55. data/doc/images/zbuildr.tif +0 -0
  56. data/doc/index.textile +109 -0
  57. data/doc/installing.textile +284 -0
  58. data/doc/languages.textile +599 -0
  59. data/doc/mailing_lists.textile +29 -0
  60. data/doc/more_stuff.textile +845 -0
  61. data/doc/packaging.textile +618 -0
  62. data/doc/preface.textile +54 -0
  63. data/doc/projects.textile +276 -0
  64. data/doc/quick_start.textile +210 -0
  65. data/doc/releasing.textile +117 -0
  66. data/doc/scripts/buildr-git.rb +512 -0
  67. data/doc/scripts/gitflow.rb +296 -0
  68. data/doc/scripts/install-jruby.sh +44 -0
  69. data/doc/scripts/install-linux.sh +73 -0
  70. data/doc/scripts/install-osx.sh +52 -0
  71. data/doc/settings_profiles.textile +287 -0
  72. data/doc/testing.textile +247 -0
  73. data/etc/KEYS +189 -0
  74. data/lib/buildr.rb +44 -0
  75. data/lib/buildr/clojure.rb +34 -0
  76. data/lib/buildr/clojure/shell.rb +52 -0
  77. data/lib/buildr/core.rb +34 -0
  78. data/lib/buildr/core/application.rb +700 -0
  79. data/lib/buildr/core/build.rb +516 -0
  80. data/lib/buildr/core/cc.rb +166 -0
  81. data/lib/buildr/core/checks.rb +253 -0
  82. data/lib/buildr/core/common.rb +151 -0
  83. data/lib/buildr/core/compile.rb +622 -0
  84. data/lib/buildr/core/doc.rb +276 -0
  85. data/lib/buildr/core/environment.rb +129 -0
  86. data/lib/buildr/core/filter.rb +404 -0
  87. data/lib/buildr/core/generate.rb +197 -0
  88. data/lib/buildr/core/help.rb +119 -0
  89. data/lib/buildr/core/jrebel.rb +42 -0
  90. data/lib/buildr/core/linux.rb +30 -0
  91. data/lib/buildr/core/osx.rb +46 -0
  92. data/lib/buildr/core/progressbar.rb +161 -0
  93. data/lib/buildr/core/project.rb +975 -0
  94. data/lib/buildr/core/run.rb +43 -0
  95. data/lib/buildr/core/shell.rb +137 -0
  96. data/lib/buildr/core/test.rb +843 -0
  97. data/lib/buildr/core/transports.rb +575 -0
  98. data/lib/buildr/core/util.rb +537 -0
  99. data/lib/buildr/groovy.rb +20 -0
  100. data/lib/buildr/groovy/bdd.rb +106 -0
  101. data/lib/buildr/groovy/compiler.rb +153 -0
  102. data/lib/buildr/groovy/doc.rb +76 -0
  103. data/lib/buildr/groovy/shell.rb +57 -0
  104. data/lib/buildr/ide.rb +19 -0
  105. data/lib/buildr/ide/eclipse.rb +427 -0
  106. data/lib/buildr/ide/eclipse/java.rb +53 -0
  107. data/lib/buildr/ide/eclipse/plugin.rb +71 -0
  108. data/lib/buildr/ide/eclipse/scala.rb +68 -0
  109. data/lib/buildr/ide/idea.rb +576 -0
  110. data/lib/buildr/java.rb +25 -0
  111. data/lib/buildr/java/ant.rb +94 -0
  112. data/lib/buildr/java/bdd.rb +460 -0
  113. data/lib/buildr/java/cobertura.rb +297 -0
  114. data/lib/buildr/java/commands.rb +223 -0
  115. data/lib/buildr/java/compiler.rb +135 -0
  116. data/lib/buildr/java/deprecated.rb +141 -0
  117. data/lib/buildr/java/doc.rb +86 -0
  118. data/lib/buildr/java/ecj.rb +69 -0
  119. data/lib/buildr/java/emma.rb +244 -0
  120. data/lib/buildr/java/external.rb +73 -0
  121. data/lib/buildr/java/jruby.rb +122 -0
  122. data/lib/buildr/java/jtestr_result.rb +295 -0
  123. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  124. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  125. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  126. data/lib/buildr/java/packaging.rb +734 -0
  127. data/lib/buildr/java/pom.rb +178 -0
  128. data/lib/buildr/java/rjb.rb +154 -0
  129. data/lib/buildr/java/test_result.rb +101 -0
  130. data/lib/buildr/java/tests.rb +362 -0
  131. data/lib/buildr/java/version_requirement.rb +172 -0
  132. data/lib/buildr/packaging.rb +25 -0
  133. data/lib/buildr/packaging/archive.rb +535 -0
  134. data/lib/buildr/packaging/artifact.rb +904 -0
  135. data/lib/buildr/packaging/artifact_namespace.rb +984 -0
  136. data/lib/buildr/packaging/artifact_search.rb +140 -0
  137. data/lib/buildr/packaging/gems.rb +105 -0
  138. data/lib/buildr/packaging/package.rb +249 -0
  139. data/lib/buildr/packaging/repository_array.rb +108 -0
  140. data/lib/buildr/packaging/tar.rb +189 -0
  141. data/lib/buildr/packaging/version_requirement.rb +192 -0
  142. data/lib/buildr/packaging/zip.rb +178 -0
  143. data/lib/buildr/packaging/ziptask.rb +356 -0
  144. data/lib/buildr/resources/buildr.icns +0 -0
  145. data/lib/buildr/resources/completed.png +0 -0
  146. data/lib/buildr/resources/failed.png +0 -0
  147. data/lib/buildr/resources/icons-license.txt +17 -0
  148. data/lib/buildr/run.rb +195 -0
  149. data/lib/buildr/scala.rb +26 -0
  150. data/lib/buildr/scala/bdd.rb +118 -0
  151. data/lib/buildr/scala/compiler.rb +242 -0
  152. data/lib/buildr/scala/doc.rb +142 -0
  153. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  154. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  155. data/lib/buildr/scala/shell.rb +52 -0
  156. data/lib/buildr/scala/tests.rb +171 -0
  157. data/lib/buildr/shell.rb +185 -0
  158. data/lib/buildr/version.rb +18 -0
  159. data/rakelib/all-in-one.rake +113 -0
  160. data/rakelib/checks.rake +57 -0
  161. data/rakelib/doc.rake +137 -0
  162. data/rakelib/metrics.rake +39 -0
  163. data/rakelib/package.rake +73 -0
  164. data/rakelib/release.rake +160 -0
  165. data/rakelib/rspec.rake +91 -0
  166. data/rakelib/setup.rake +66 -0
  167. data/rakelib/stage.rake +220 -0
  168. data/spec/addon/bnd_spec.rb +330 -0
  169. data/spec/addon/drb_spec.rb +328 -0
  170. data/spec/addon/jaxb_xjc_spec.rb +125 -0
  171. data/spec/core/application_spec.rb +631 -0
  172. data/spec/core/build_spec.rb +837 -0
  173. data/spec/core/cc_spec.rb +224 -0
  174. data/spec/core/checks_spec.rb +519 -0
  175. data/spec/core/common_spec.rb +725 -0
  176. data/spec/core/compile_spec.rb +658 -0
  177. data/spec/core/doc_spec.rb +195 -0
  178. data/spec/core/extension_spec.rb +201 -0
  179. data/spec/core/generate_spec.rb +33 -0
  180. data/spec/core/project_spec.rb +772 -0
  181. data/spec/core/run_spec.rb +93 -0
  182. data/spec/core/shell_spec.rb +146 -0
  183. data/spec/core/test_spec.rb +1320 -0
  184. data/spec/core/transport_spec.rb +544 -0
  185. data/spec/core/util_spec.rb +141 -0
  186. data/spec/groovy/bdd_spec.rb +80 -0
  187. data/spec/groovy/compiler_spec.rb +251 -0
  188. data/spec/groovy/doc_spec.rb +65 -0
  189. data/spec/ide/eclipse_spec.rb +739 -0
  190. data/spec/ide/idea_spec.rb +1145 -0
  191. data/spec/java/ant_spec.rb +37 -0
  192. data/spec/java/bdd_spec.rb +374 -0
  193. data/spec/java/cobertura_spec.rb +112 -0
  194. data/spec/java/commands_spec.rb +93 -0
  195. data/spec/java/compiler_spec.rb +252 -0
  196. data/spec/java/doc_spec.rb +56 -0
  197. data/spec/java/ecj_spec.rb +115 -0
  198. data/spec/java/emma_spec.rb +121 -0
  199. data/spec/java/external_spec.rb +56 -0
  200. data/spec/java/java_spec.rb +132 -0
  201. data/spec/java/packaging_spec.rb +1266 -0
  202. data/spec/java/run_spec.rb +78 -0
  203. data/spec/java/test_coverage_helper.rb +257 -0
  204. data/spec/java/tests_spec.rb +497 -0
  205. data/spec/packaging/archive_spec.rb +775 -0
  206. data/spec/packaging/artifact_namespace_spec.rb +743 -0
  207. data/spec/packaging/artifact_spec.rb +1074 -0
  208. data/spec/packaging/packaging_helper.rb +63 -0
  209. data/spec/packaging/packaging_spec.rb +719 -0
  210. data/spec/packaging/repository_array_spec.rb +109 -0
  211. data/spec/sandbox.rb +165 -0
  212. data/spec/scala/bdd_spec.rb +124 -0
  213. data/spec/scala/compiler_spec.rb +289 -0
  214. data/spec/scala/doc_spec.rb +88 -0
  215. data/spec/scala/scala.rb +38 -0
  216. data/spec/scala/tests_spec.rb +283 -0
  217. data/spec/spec_helpers.rb +369 -0
  218. data/spec/version_requirement_spec.rb +143 -0
  219. data/spec/xpath_matchers.rb +121 -0
  220. metadata +600 -0
@@ -0,0 +1,65 @@
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
+
19
+ describe "Groovydoc" do
20
+
21
+ it 'should pick :windowtitle from project name by default' do
22
+ define 'foo' do
23
+ doc.using :groovydoc
24
+
25
+ define 'bar' do
26
+ doc.using :groovydoc
27
+ end
28
+ end
29
+
30
+ project('foo').doc.options[:windowtitle].should eql('foo')
31
+ project('foo:bar').doc.options[:windowtitle].should eql('foo:bar')
32
+ end
33
+
34
+ it 'should pick :windowtitle from project description by default, if available' do
35
+ desc 'My App'
36
+ define 'foo' do
37
+ doc.using :groovydoc
38
+ end
39
+ project('foo').doc.options[:windowtitle].should eql('My App')
40
+ end
41
+
42
+ it 'should not override explicit :windowtitle option' do
43
+ define 'foo' do
44
+ doc.using :groovydoc
45
+ doc.using :windowtitle => 'explicit'
46
+ end
47
+ project('foo').doc.options[:windowtitle].should eql('explicit')
48
+ end
49
+
50
+ it 'should identify itself from groovy source directories' do
51
+ write 'src/main/groovy/some/A.java', 'package some; public class A {}'
52
+ write 'src/main/groovy/some/B.groovy', 'package some; public class B {}'
53
+ define('foo') do
54
+ doc.engine.should be_a(Buildr::Doc::Groovydoc)
55
+ end
56
+ end
57
+
58
+ it 'should produce Groovydocs' do
59
+ write 'src/main/groovy/some/A.java', 'package some; public class A {}'
60
+ write 'src/main/groovy/some/B.groovy', 'package some; public class B {}'
61
+ define('foo')
62
+ project('foo').doc.invoke
63
+ file('target/doc/index.html').should exist
64
+ end
65
+ end
@@ -0,0 +1,739 @@
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
+
19
+
20
+ JAVA_CONTAINER = Buildr::Eclipse::Java::CONTAINER
21
+ SCALA_CONTAINER = Buildr::Eclipse::Scala::CONTAINER
22
+ PLUGIN_CONTAINER = Buildr::Eclipse::Plugin::CONTAINER
23
+
24
+ JAVA_NATURE = Buildr::Eclipse::Java::NATURE
25
+ SCALA_NATURE = Buildr::Eclipse::Scala::NATURE
26
+ PLUGIN_NATURE = Buildr::Eclipse::Plugin::NATURE
27
+
28
+ JAVA_BUILDER = Buildr::Eclipse::Java::BUILDER
29
+ SCALA_BUILDER = Buildr::Eclipse::Scala::BUILDER
30
+ PLUGIN_BUILDERS = Buildr::Eclipse::Plugin::BUILDERS
31
+
32
+
33
+ module EclipseHelper
34
+ def classpath_xml_elements
35
+ task('eclipse').invoke
36
+ File.open('.classpath') { |f| REXML::Document.new(f).root.elements }
37
+ end
38
+
39
+ def classpath_sources(attribute='path')
40
+ classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes[attribute] }
41
+ end
42
+
43
+ # <classpathentry path="PATH" output="RETURNED_VALUE"/>
44
+ def classpath_specific_output(path)
45
+ specific_output = classpath_xml_elements.collect("classpathentry[@path='#{path}']") { |n| n.attributes['output'] }
46
+ raise "expected: one output attribute for path '#{path}, got: #{specific_output.inspect}" if specific_output.length > 1
47
+ specific_output[0]
48
+ end
49
+
50
+ # <classpathentry path="RETURNED_VALUE" kind="output"/>
51
+ def classpath_default_output
52
+ default_output = classpath_xml_elements.collect("classpathentry[@kind='output']") { |n| n.attributes['path'] }
53
+ raise "expected: one path attribute for kind='output', got: #{default_output.inspect}" if default_output.length > 1
54
+ default_output[0]
55
+ end
56
+
57
+ # <classpathentry path="PATH" sourcepath="RETURNED_VALUE" kind="var"/>
58
+ def sourcepath_for_path(path)
59
+ classpath_xml_elements.collect("classpathentry[@kind='var',@path='#{path}']") do |n|
60
+ n.attributes['sourcepath'] || 'no source artifact'
61
+ end
62
+ end
63
+
64
+ # <classpathentry path="PATH" javadocpath="RETURNED_VALUE" kind="var"/>
65
+ def javadocpath_for_path(path)
66
+ classpath_xml_elements.collect("classpathentry[@kind='var',@path='#{path}']") do |n|
67
+ n.attributes['javadocpath'] || 'no javadoc artifact'
68
+ end
69
+ end
70
+
71
+ def project_xml_elements
72
+ task('eclipse').invoke
73
+ File.open('.project') { |f| REXML::Document.new(f).root.elements }
74
+ end
75
+
76
+ def project_natures
77
+ project_xml_elements.collect("natures/nature") { |n| n.text }
78
+ end
79
+
80
+ def build_commands
81
+ project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
82
+ end
83
+
84
+ def classpath_containers(attribute='path')
85
+ classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
86
+ end
87
+ end
88
+
89
+
90
+ describe Buildr::Eclipse do
91
+ include EclipseHelper
92
+
93
+ describe "eclipse's .project file" do
94
+
95
+ describe 'default project' do
96
+ before do
97
+ write 'buildfile'
98
+ write 'src/main/nono/Main.nono'
99
+ end
100
+
101
+ it 'should not have natures' do
102
+ define('foo')
103
+ project_natures.should be_empty
104
+ end
105
+
106
+ it 'should not have build commands' do
107
+ define('foo')
108
+ build_commands.should be_empty
109
+ end
110
+
111
+ it 'should generate a .project file' do
112
+ define('foo')
113
+ task('eclipse').invoke
114
+ File.open('.project') do |f|
115
+ REXML::Document.new(f).root.
116
+ elements.collect("name") { |e| e.text }.should == ['foo']
117
+ end
118
+ end
119
+
120
+ it 'should use eclipse project name if specified' do
121
+ define('foo') { eclipse.name = 'bar' }
122
+ task('eclipse').invoke
123
+ File.open('.project') do |f|
124
+ REXML::Document.new(f).root.
125
+ elements.collect("name") { |e| e.text }.should == ['bar']
126
+ end
127
+ end
128
+
129
+ it 'should not generate a .classpath file' do
130
+ define('foo')
131
+ task('eclipse').invoke
132
+ File.exists?('.classpath').should be_false
133
+ end
134
+ end
135
+
136
+ describe 'parent project' do
137
+ before do
138
+ write 'buildfile'
139
+ mkpath 'bar'
140
+ end
141
+
142
+ it 'should not generate a .project for the parent project' do
143
+ define('foo') do
144
+ define('bar')
145
+ end
146
+ task('eclipse').invoke
147
+ File.exists?('.project').should be_false
148
+ File.exists?(File.join('bar','.project')).should be_true
149
+ end
150
+ end
151
+
152
+ describe 'java project' do
153
+ before do
154
+ write 'buildfile'
155
+ write 'src/main/java/Main.java'
156
+ end
157
+
158
+ it 'should have Java nature' do
159
+ define('foo')
160
+ project_natures.should include(JAVA_NATURE)
161
+ end
162
+
163
+ it 'should have Java build command' do
164
+ define('foo')
165
+ build_commands.should include(JAVA_BUILDER)
166
+ end
167
+ end
168
+
169
+ describe 'nested java project' do
170
+
171
+ it 'should have name corresponding to its project definition' do
172
+ mkdir 'foo'
173
+ define('myproject') {
174
+ project.version = '1.0'
175
+ define('foo') { compile.using(:javac); package :jar }
176
+ }
177
+ task('eclipse').invoke
178
+ File.open(File.join('foo', '.project')) do |f|
179
+ REXML::Document.new(f).root.
180
+ elements.collect("name") { |e| e.text }.should == ['myproject-foo']
181
+ end
182
+ end
183
+
184
+ it 'should use eclipse name for child project if set' do
185
+ mkdir 'foo'
186
+ define('myproject') {
187
+ project.version = '1.0'
188
+ define('foo') { eclipse.name = 'bar'; compile.using(:javac); package :jar }
189
+ }
190
+ task('eclipse').invoke
191
+ File.open(File.join('foo', '.project')) do |f|
192
+ REXML::Document.new(f).root.
193
+ elements.collect("name") { |e| e.text }.should == ['bar']
194
+ end
195
+ end
196
+
197
+ it 'should use short name for child project if eclipse.options.short_names = true' do
198
+ mkdir 'foo'
199
+ define('myproject') {
200
+ project.version = '1.0'
201
+ eclipse.options.short_names = true
202
+ define('foo') { compile.using(:javac); package :jar }
203
+ }
204
+ task('eclipse').invoke
205
+ File.open(File.join('foo', '.project')) do |f|
206
+ REXML::Document.new(f).root.
207
+ elements.collect("name") { |e| e.text }.should == ['foo']
208
+ end
209
+ end
210
+ end
211
+
212
+ describe 'scala project' do
213
+
214
+ before do
215
+ define 'foo' do
216
+ eclipse.natures :scala
217
+ end
218
+ end
219
+
220
+ it 'should have Scala nature before Java nature' do
221
+ project_natures.should include(SCALA_NATURE)
222
+ project_natures.should include(JAVA_NATURE)
223
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
224
+ end
225
+
226
+ it 'should have Scala build command and no Java build command' do
227
+ build_commands.should include(SCALA_BUILDER)
228
+ build_commands.should_not include(JAVA_BUILDER)
229
+ end
230
+ end
231
+
232
+ describe 'standard scala project' do
233
+
234
+ before do
235
+ write 'buildfile'
236
+ write 'src/main/scala/Main.scala'
237
+ define 'foo'
238
+ end
239
+
240
+ it 'should have Scala nature before Java nature' do
241
+ project_natures.should include(SCALA_NATURE)
242
+ project_natures.should include(JAVA_NATURE)
243
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
244
+ end
245
+
246
+ it 'should have Scala build command and no Java build command' do
247
+ build_commands.should include(SCALA_BUILDER)
248
+ build_commands.should_not include(JAVA_BUILDER)
249
+ end
250
+ end
251
+
252
+ describe 'non-standard scala project' do
253
+
254
+ before do
255
+ write 'buildfile'
256
+ write 'src/main/foo/Main.scala'
257
+ define 'foo' do
258
+ eclipse.natures = :scala
259
+ end
260
+ end
261
+
262
+ it 'should have Scala nature before Java nature' do
263
+ project_natures.should include(SCALA_NATURE)
264
+ project_natures.should include(JAVA_NATURE)
265
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
266
+ end
267
+
268
+ it 'should have Scala build command and no Java build command' do
269
+ build_commands.should include(SCALA_BUILDER)
270
+ build_commands.should_not include(JAVA_BUILDER)
271
+ end
272
+ end
273
+
274
+ describe 'Plugin project' do
275
+
276
+ before do
277
+ write 'buildfile'
278
+ write 'src/main/java/Activator.java'
279
+ write 'plugin.xml'
280
+ end
281
+
282
+ it 'should have plugin nature before Java nature' do
283
+ define('foo')
284
+ project_natures.should include(PLUGIN_NATURE)
285
+ project_natures.should include(JAVA_NATURE)
286
+ project_natures.index(PLUGIN_NATURE).should < project_natures.index(JAVA_NATURE)
287
+ end
288
+
289
+ it 'should have plugin build commands and the Java build command' do
290
+ define('foo')
291
+ build_commands.should include(PLUGIN_BUILDERS[0])
292
+ build_commands.should include(PLUGIN_BUILDERS[1])
293
+ build_commands.should include(JAVA_BUILDER)
294
+ end
295
+ end
296
+
297
+ describe 'Plugin project' do
298
+
299
+ before do
300
+ write 'buildfile'
301
+ write 'src/main/java/Activator.java'
302
+ write 'plugin.xml'
303
+ end
304
+
305
+ it 'should have plugin nature before Java nature' do
306
+ define('foo')
307
+ project_natures.should include(PLUGIN_NATURE)
308
+ project_natures.should include(JAVA_NATURE)
309
+ project_natures.index(PLUGIN_NATURE).should < project_natures.index(JAVA_NATURE)
310
+ end
311
+
312
+ it 'should have plugin build commands and the Java build command' do
313
+ define('foo')
314
+ build_commands.should include(PLUGIN_BUILDERS[0])
315
+ build_commands.should include(PLUGIN_BUILDERS[1])
316
+ build_commands.should include(JAVA_BUILDER)
317
+ end
318
+ end
319
+
320
+ describe 'Plugin project with META-INF/MANIFEST.MF' do
321
+
322
+ before do
323
+ write 'buildfile'
324
+ write 'src/main/java/Activator.java'
325
+ end
326
+
327
+ it 'should have plugin nature by default if MANIFEST.MF contains "Bundle-SymbolicName:"' do
328
+ write 'META-INF/MANIFEST.MF', <<-MANIFEST
329
+ Manifest-Version: 1.0
330
+ Name: example/
331
+ Specification-Title: "Examples"
332
+ Specification-Version: "1.0"
333
+ Specification-Vendor: "Acme Corp.".
334
+ Implementation-Title: "example"
335
+ Implementation-Version: "build57"
336
+ Implementation-Vendor: "Acme Corp."
337
+ Bundle-SymbolicName: acme.plugin.example
338
+ MANIFEST
339
+ define('foo')
340
+ project_natures.should include(PLUGIN_NATURE)
341
+ end
342
+
343
+ it 'should not have plugin nature if MANIFEST.MF exists but doesn\'t contain "Bundle-SymbolicName:"' do
344
+ write 'META-INF/MANIFEST.MF', <<-MANIFEST
345
+ Manifest-Version: 1.0
346
+ Name: example/
347
+ Specification-Title: "Examples"
348
+ Specification-Version: "1.0"
349
+ Specification-Vendor: "Acme Corp.".
350
+ Implementation-Title: "example"
351
+ Implementation-Version: "build57"
352
+ Implementation-Vendor: "Acme Corp."
353
+ MANIFEST
354
+ define('foo')
355
+ project_natures.should_not include(PLUGIN_NATURE)
356
+ end
357
+ end
358
+ end
359
+
360
+ describe "eclipse's .classpath file" do
361
+
362
+ describe 'scala project' do
363
+
364
+ before do
365
+ write 'buildfile'
366
+ write 'src/main/scala/Main.scala'
367
+ end
368
+
369
+ it 'should have SCALA_CONTAINER before JAVA_CONTAINER' do
370
+ define('foo')
371
+ classpath_containers.should include(SCALA_CONTAINER)
372
+ classpath_containers.should include(JAVA_CONTAINER)
373
+ classpath_containers.index(SCALA_CONTAINER).should < classpath_containers.index(JAVA_CONTAINER)
374
+ end
375
+ end
376
+
377
+ describe 'source folders' do
378
+
379
+ before do
380
+ write 'buildfile'
381
+ write 'src/main/java/Main.java'
382
+ write 'src/test/java/Test.java'
383
+ end
384
+
385
+ shared_examples_for 'source' do
386
+ it 'should ignore CVS and SVN files' do
387
+ define('foo')
388
+ classpath_sources('excluding').each do |excluding_attribute|
389
+ excluding = excluding_attribute.split('|')
390
+ excluding.should include('**/.svn/')
391
+ excluding.should include('**/CVS/')
392
+ end
393
+ end
394
+ end
395
+
396
+ describe 'main code' do
397
+ it_should_behave_like 'source'
398
+
399
+ it 'should accept to come from the default directory' do
400
+ define('foo')
401
+ classpath_sources.should include('src/main/java')
402
+ end
403
+
404
+ it 'should accept to come from a user-defined directory' do
405
+ define('foo') { compile path_to('src/java') }
406
+ classpath_sources.should include('src/java')
407
+ end
408
+
409
+ it 'should accept a file task as a main source folder' do
410
+ define('foo') { compile apt }
411
+ classpath_sources.should include('target/generated/apt')
412
+ end
413
+
414
+ it 'should go to the default target directory' do
415
+ define('foo')
416
+ classpath_specific_output('src/main/java').should be(nil)
417
+ classpath_default_output.should == 'target/classes'
418
+ end
419
+ end
420
+
421
+ describe 'test code' do
422
+ it_should_behave_like 'source'
423
+
424
+ it 'should accept to come from the default directory' do
425
+ define('foo')
426
+ classpath_sources.should include('src/test/java')
427
+ end
428
+
429
+ it 'should accept to come from a user-defined directory' do
430
+ define('foo') { test.compile path_to('src/test') }
431
+ classpath_sources.should include('src/test')
432
+ end
433
+
434
+ it 'should go to the default target directory' do
435
+ define('foo')
436
+ classpath_specific_output('src/test/java').should == 'target/test/classes'
437
+ end
438
+
439
+ it 'should accept to be the only code in the project' do
440
+ rm 'src/main/java/Main.java'
441
+ define('foo')
442
+ classpath_sources.should include('src/test/java')
443
+ end
444
+ end
445
+
446
+ describe 'main resources' do
447
+ it_should_behave_like 'source'
448
+
449
+ before do
450
+ write 'src/main/resources/config.xml'
451
+ end
452
+
453
+ it 'should accept to come from the default directory' do
454
+ define('foo')
455
+ classpath_sources.should include('src/main/resources')
456
+ end
457
+
458
+ it 'should share a classpath entry if it comes from a directory with code' do
459
+ write 'src/main/java/config.properties'
460
+ define('foo') { resources.from('src/main/java').exclude('**/*.java') }
461
+ classpath_sources.select { |path| path == 'src/main/java'}.length.should == 1
462
+ end
463
+
464
+ it 'should go to the default target directory' do
465
+ define('foo')
466
+ classpath_specific_output('src/main/resources').should == 'target/resources'
467
+ end
468
+ end
469
+
470
+ describe 'test resources' do
471
+ it_should_behave_like 'source'
472
+
473
+ before do
474
+ write 'src/test/resources/config-test.xml'
475
+ end
476
+
477
+ it 'should accept to come from the default directory' do
478
+ define('foo')
479
+ classpath_sources.should include('src/test/resources')
480
+ end
481
+
482
+ it 'should share a classpath entry if it comes from a directory with code' do
483
+ write 'src/test/java/config-test.properties'
484
+ define('foo') { test.resources.from('src/test/java').exclude('**/*.java') }
485
+ classpath_sources.select { |path| path == 'src/test/java'}.length.should == 1
486
+ end
487
+
488
+ it 'should go to the default target directory' do
489
+ define('foo')
490
+ classpath_specific_output('src/test/resources').should == 'target/test/resources'
491
+ end
492
+ end
493
+ end
494
+
495
+ describe 'project depending on another project' do
496
+ it 'should have the underlying project in its classpath' do
497
+ mkdir 'foo'
498
+ mkdir 'bar'
499
+ define('myproject') {
500
+ project.version = '1.0'
501
+ define('foo') { package :jar }
502
+ define('bar') { compile.using(:javac).with project('foo'); }
503
+ }
504
+ task('eclipse').invoke
505
+ File.open(File.join('bar', '.classpath')) do |f|
506
+ REXML::Document.new(f).root.
507
+ elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should include('/myproject-foo')
508
+ end
509
+ end
510
+
511
+ it 'should use eclipse name in its classpath if set' do
512
+ mkdir 'foo'
513
+ mkdir 'bar'
514
+ define('myproject') {
515
+ project.version = '1.0'
516
+ define('foo') { eclipse.name = 'eclipsefoo'; package :jar }
517
+ define('bar') { eclipse.name = 'eclipsebar'; compile.using(:javac).with project('foo'); }
518
+ }
519
+ task('eclipse').invoke
520
+ File.open(File.join('bar', '.classpath')) do |f|
521
+ REXML::Document.new(f).root.
522
+ elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should include('/eclipsefoo')
523
+ end
524
+ end
525
+ end
526
+ end
527
+
528
+ describe 'local dependency' do
529
+ before do
530
+ write 'lib/some-local.jar'
531
+ define('foo') { compile.using(:javac).with(_('lib/some-local.jar')) }
532
+ end
533
+
534
+ it 'should have a lib artifact reference in the .classpath file' do
535
+ classpath_xml_elements.collect("classpathentry[@kind='lib']") { |n| n.attributes['path'] }.
536
+ should include('lib/some-local.jar')
537
+ end
538
+ end
539
+
540
+ describe 'project .classpath' do
541
+ before do
542
+ mkdir_p '../libs'
543
+ write '../libs/some-local.jar'
544
+ define('foo') do
545
+ eclipse.classpath_variables :LIBS => '../libs', :LIBS2 => '../libs2'
546
+ compile.using(:javac).with(_('../libs/some-local.jar'))
547
+ end
548
+ end
549
+
550
+ it 'supports generating library paths with classpath variables' do
551
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
552
+ should include('LIBS/some-local.jar')
553
+ end
554
+ end
555
+
556
+ describe 'generated .classes' do
557
+ before do
558
+ write 'lib/some.class'
559
+ define('foo') { compile.using(:javac).with(_('lib')) }
560
+ end
561
+
562
+ it 'should have src reference in the .classpath file' do
563
+ classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.
564
+ should include('lib')
565
+ end
566
+ end
567
+
568
+ describe 'maven2 artifact dependency' do
569
+ before do
570
+ define('foo') { compile.using(:javac).with('com.example:library:jar:2.0') }
571
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
572
+ task('eclipse').invoke
573
+ end
574
+
575
+ it 'should have a reference in the .classpath file relative to the local M2 repo' do
576
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
577
+ should include('M2_REPO/com/example/library/2.0/library-2.0.jar')
578
+ end
579
+
580
+ it 'should be downloaded' do
581
+ file(artifact('com.example:library:jar:2.0').name).should exist
582
+ end
583
+
584
+ it 'should have a source artifact reference in the .classpath file' do
585
+ sourcepath_for_path('M2_REPO/com/example/library/2.0/library-2.0.jar').
586
+ should == ['M2_REPO/com/example/library/2.0/library-2.0-sources.jar']
587
+ end
588
+
589
+ it 'should have a javadoc artifact reference in the .classpath file' do
590
+ javadocpath_for_path('M2_REPO/com/example/library/2.0/library-2.0.jar').
591
+ should == ['M2_REPO/com/example/library/2.0/library-2.0-javadoc.jar']
592
+ end
593
+ end
594
+
595
+ describe 'maven2 repository variable' do
596
+ it 'should be configurable' do
597
+ define('foo') do
598
+ eclipse.options.m2_repo_var = 'PROJ_REPO'
599
+ compile.using(:javac).with('com.example:library:jar:2.0')
600
+ end
601
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
602
+
603
+ task('eclipse').invoke
604
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
605
+ should include('PROJ_REPO/com/example/library/2.0/library-2.0.jar')
606
+ end
607
+
608
+ it 'should pick the parent value by default' do
609
+ define('foo') do
610
+ eclipse.options.m2_repo_var = 'FOO_REPO'
611
+ define('bar')
612
+
613
+ define('bar2') do
614
+ eclipse.options.m2_repo_var = 'BAR2_REPO'
615
+ end
616
+ end
617
+ project('foo:bar').eclipse.options.m2_repo_var.should eql('FOO_REPO')
618
+ project('foo:bar2').eclipse.options.m2_repo_var.should eql('BAR2_REPO')
619
+ end
620
+ end
621
+
622
+ describe 'natures variable' do
623
+ it 'should be configurable' do
624
+ define('foo') do
625
+ eclipse.natures = 'dummyNature'
626
+ compile.using(:javac).with('com.example:library:jar:2.0')
627
+ end
628
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
629
+ project_natures.should include('dummyNature')
630
+ end
631
+
632
+ it 'should pick the parent value by default' do
633
+ define('foo') do
634
+ eclipse.natures = 'foo_nature'
635
+ define('bar')
636
+
637
+ define('bar2') do
638
+ eclipse.natures = 'bar2_nature'
639
+ end
640
+ end
641
+ project('foo:bar').eclipse.natures.should include('foo_nature')
642
+ project('foo:bar2').eclipse.natures.should include('bar2_nature')
643
+ end
644
+
645
+ it 'should handle arrays correctly' do
646
+ define('foo') do
647
+ eclipse.natures ['foo_nature', 'bar_nature']
648
+ end
649
+ project('foo').eclipse.natures.should == ['foo_nature', 'bar_nature']
650
+ end
651
+ end
652
+
653
+ describe 'builders variable' do
654
+ it 'should be configurable' do
655
+ define('foo') do
656
+ eclipse.builders 'dummyBuilder'
657
+ compile.using(:javac).with('com.example:library:jar:2.0')
658
+ end
659
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
660
+ build_commands.should include('dummyBuilder')
661
+ end
662
+
663
+ it 'should pick the parent value by default' do
664
+ define('foo') do
665
+ eclipse.builders = 'foo_builder'
666
+ define('bar')
667
+
668
+ define('bar2') do
669
+ eclipse.builders = 'bar2_builder'
670
+ end
671
+ end
672
+ project('foo:bar').eclipse.builders.should include('foo_builder')
673
+ project('foo:bar2').eclipse.builders.should include('bar2_builder')
674
+ end
675
+
676
+ it 'should handle arrays correctly' do
677
+ define('foo') do
678
+ eclipse.builders ['foo_builder', 'bar_builder']
679
+ end
680
+ project('foo').eclipse.builders.should == ['foo_builder', 'bar_builder']
681
+ end
682
+ end
683
+
684
+ describe 'classpath_containers variable' do
685
+ it 'should be configurable' do
686
+ define('foo') do
687
+ eclipse.classpath_containers = 'myOlGoodContainer'
688
+ compile.using(:javac).with('com.example:library:jar:2.0')
689
+ end
690
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
691
+ classpath_containers.should include('myOlGoodContainer')
692
+ end
693
+
694
+ it 'should pick the parent value by default' do
695
+ define('foo') do
696
+ eclipse.classpath_containers = 'foo_classpath_containers'
697
+ define('bar')
698
+
699
+ define('bar2') do
700
+ eclipse.classpath_containers = 'bar2_classpath_containers'
701
+ end
702
+ end
703
+ project('foo:bar').eclipse.classpath_containers.should include('foo_classpath_containers')
704
+ project('foo:bar2').eclipse.classpath_containers.should include('bar2_classpath_containers')
705
+ end
706
+
707
+ it 'should handle arrays correctly' do
708
+ define('foo') do
709
+ eclipse.classpath_containers ['foo_cc', 'bar_cc']
710
+ end
711
+ project('foo').eclipse.classpath_containers.should == ['foo_cc', 'bar_cc']
712
+ end
713
+ end
714
+
715
+ describe 'exclude_libs' do
716
+ it 'should support artifacts' do
717
+ define('foo') do
718
+ compile.using(:javac).with('com.example:library:jar:2.0')
719
+ eclipse.exclude_libs += [ artifact('com.example:library:jar:2.0') ]
720
+ end
721
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
722
+
723
+ task('eclipse').invoke
724
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
725
+ should_not include('M2_REPO/com/example/library/2.0/library-2.0.jar')
726
+ end
727
+ it 'should support string paths' do
728
+ define('foo') do
729
+ compile.using(:javac).with _('path/to/library.jar')
730
+ eclipse.exclude_libs += [ _('path/to/library.jar') ]
731
+ end
732
+ write project('foo').path_to('path/to/library.jar')
733
+
734
+ task('eclipse').invoke
735
+ classpath_xml_elements.collect("classpathentry[@kind='lib']") { |n| n.attributes['path'] }.
736
+ should_not include('path/to/library.jar')
737
+ end
738
+ end
739
+ end