buildr 1.3.5-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +998 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +244 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +79 -0
  40. data/doc/extending.textile +186 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +266 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +280 -0
  68. data/doc/testing.textile +222 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +656 -0
  73. data/lib/buildr/core/build.rb +452 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +362 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
@@ -0,0 +1,67 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+ describe Hash do
20
+ describe "#only" do
21
+ it "should find value for one key" do
22
+ {:a => 1, :b => 2, :c => 3}.only(:a).should == {:a => 1}
23
+ end
24
+
25
+ it "should find values for multiple keys" do
26
+ {:a => 1, :b => 2, :c => 3}.only(:b, :c).should == {:b => 2, :c => 3}
27
+ end
28
+ end
29
+ end
30
+
31
+ describe OpenObject do
32
+ before do
33
+ @obj = OpenObject.new({:a => 1, :b => 2, :c => 3})
34
+ end
35
+
36
+ it "should be kind of Hash" do
37
+ Hash.should === @obj
38
+ end
39
+
40
+ it "should accept block that supplies default value" do
41
+ obj = OpenObject.new { |hash, key| hash[key] = "New #{key}" }
42
+ obj[:foo].should == "New foo"
43
+ obj.keys.should == [:foo]
44
+ end
45
+
46
+ it "should combine initial values from hash argument and from block" do
47
+ obj = OpenObject.new(:a => 6, :b => 2) { |h, k| h[k] = k.to_s * 2 }
48
+ obj[:a].should == 6
49
+ obj[:c].should == 'cc'
50
+ end
51
+
52
+ it "should allow reading a value by calling its name method" do
53
+ @obj.b.should == 2
54
+ end
55
+
56
+ it "should allow setting a value by calling its name= method" do
57
+ lambda { @obj.f = 32 }.should change { @obj.f }.to(32)
58
+ end
59
+
60
+ it "should allow changing a value by calling its name= method" do
61
+ lambda { @obj.c = 17 }.should change { @obj.c }.to(17)
62
+ end
63
+
64
+ it "should implement only method like a hash" do
65
+ @obj.only(:a).should == { :a => 1 }
66
+ end
67
+ end
@@ -0,0 +1,80 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+
19
+ describe Buildr::Groovy::EasyB do
20
+
21
+ def foo(*args, &prc)
22
+ define('foo', *args) do
23
+ test.using :easyb
24
+ if prc
25
+ instance_eval(&prc)
26
+ else
27
+ self
28
+ end
29
+ end
30
+ end
31
+
32
+ it 'should apply to a project having EasyB sources' do
33
+ define('one', :base_dir => 'one') do
34
+ write _('src/spec/groovy/SomeSpecification.groovy'), 'true;'
35
+ Buildr::Groovy::EasyB.applies_to?(self).should be_true
36
+ end
37
+ define('two', :base_dir => 'two') do
38
+ write _('src/test/groovy/SomeSpecification.groovy'), 'true;'
39
+ Buildr::Groovy::EasyB.applies_to?(self).should be_false
40
+ end
41
+ define('three', :base_dir => 'three') do
42
+ write _('src/spec/groovy/SomeStory.groovy'), 'true;'
43
+ Buildr::Groovy::EasyB.applies_to?(self).should be_true
44
+ end
45
+ define('four', :base_dir => 'four') do
46
+ write _('src/test/groovy/SomeStory.groovy'), 'true;'
47
+ Buildr::Groovy::EasyB.applies_to?(self).should be_false
48
+ end
49
+ end
50
+
51
+ it 'should be selected by :easyb name' do
52
+ foo { test.framework.should eql(:easyb) }
53
+ end
54
+
55
+ it 'should select a java compiler if java sources are found' do
56
+ foo do
57
+ write _('src/spec/java/SomeSpecification.java'), 'public class SomeSpecification {}'
58
+ test.compile.language.should eql(:java)
59
+ end
60
+ end
61
+
62
+ it 'should include src/spec/groovy/*Specification.groovy' do
63
+ foo do
64
+ spec = _('src/spec/groovy/SomeSpecification.groovy')
65
+ write spec, 'true'
66
+ test.invoke
67
+ test.tests.should include(spec)
68
+ end
69
+ end
70
+
71
+ it 'should include src/spec/groovy/*Story.groovy' do
72
+ foo do
73
+ spec = _('src/spec/groovy/SomeStory.groovy')
74
+ write spec, 'true'
75
+ test.invoke
76
+ test.tests.should include(spec)
77
+ end
78
+ end
79
+
80
+ end # EasyB
@@ -0,0 +1,240 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+ describe 'groovyc compiler' do
20
+
21
+ it 'should identify itself from groovy source directories' do
22
+ write 'src/main/groovy/some/Hello.groovy', 'println "Hello Groovy"'
23
+ write 'src/test/groovy/some/Hello.groovy', 'println "Hello Groovy"'
24
+ define('foo') do
25
+ compile.compiler.should eql(:groovyc)
26
+ test.compile.compiler.should eql(:groovyc)
27
+ end
28
+ end
29
+
30
+ it 'should identify if groovy sources are found on java directories' do
31
+ write 'src/main/java/some/Hello.groovy', 'println "Hello Groovy"'
32
+ write 'src/test/java/some/Hello.groovy', 'println "Hello Groovy"'
33
+ define('foo') do
34
+ compile.compiler.should eql(:groovyc)
35
+ test.compile.compiler.should eql(:groovyc)
36
+ end
37
+ end
38
+
39
+ it 'should identify itself even if groovy and java sources are found' do
40
+ write 'src/main/java/some/Empty.java', 'package some; public interface Empty {}'
41
+ write 'src/main/groovy/some/Hello.groovy', 'println "Hello Groovy"'
42
+ write 'src/test/java/some/Empty.java', 'package some; public interface Empty {}'
43
+ write 'src/test/groovy/some/Hello.groovy', 'println "Hello Groovy"'
44
+ define('foo') do
45
+ compile.compiler.should eql(:groovyc)
46
+ test.compile.compiler.should eql(:groovyc)
47
+ end
48
+ end
49
+
50
+ it 'should identify from custom layout' do
51
+ write 'groovy/Hello.groovy', 'println "Hello world"'
52
+ write 'testing/Hello.groovy', 'println "Hello world"'
53
+ custom = Layout.new
54
+ custom[:source, :main, :groovy] = 'groovy'
55
+ custom[:source, :test, :groovy] = 'testing'
56
+ define 'foo', :layout=>custom do
57
+ compile.compiler.should eql(:groovyc)
58
+ test.compile.compiler.should eql(:groovyc)
59
+ end
60
+ end
61
+
62
+ it 'should identify from compile source directories' do
63
+ write 'src/com/example/Code.groovy', 'println "monkey code"'
64
+ write 'testing/com/example/Test.groovy', 'println "some test"'
65
+ define 'foo' do
66
+ lambda { compile.from 'src' }.should change { compile.compiler }.to(:groovyc)
67
+ lambda { test.compile.from 'testing' }.should change { test.compile.compiler }.to(:groovyc)
68
+ end
69
+ end
70
+
71
+ it 'should report the multi-language as :groovy, :java' do
72
+ define('foo').compile.using(:groovyc).language.should == :groovy
73
+ end
74
+
75
+ it 'should set the target directory to target/classes' do
76
+ define 'foo' do
77
+ lambda { compile.using(:groovyc) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
78
+ end
79
+ end
80
+
81
+ it 'should not override existing target directory' do
82
+ define 'foo' do
83
+ compile.into('classes')
84
+ lambda { compile.using(:groovyc) }.should_not change { compile.target }
85
+ end
86
+ end
87
+
88
+ it 'should not change existing list of sources' do
89
+ define 'foo' do
90
+ compile.from('sources')
91
+ lambda { compile.using(:groovyc) }.should_not change { compile.sources }
92
+ end
93
+ end
94
+
95
+ it 'should compile groovy sources' do
96
+ write 'src/main/groovy/some/Example.groovy', 'package some; class Example { static main(args) { println "Hello" } }'
97
+ define('foo').compile.invoke
98
+ file('target/classes/some/Example.class').should exist
99
+ end
100
+
101
+ it 'should include as classpath dependency' do
102
+ write 'src/bar/groovy/some/Foo.groovy', 'package some; interface Foo {}'
103
+ write 'src/main/groovy/some/Example.groovy', 'package some; class Example implements Foo { }'
104
+ define('bar', :version => '1.0') do
105
+ compile.from('src/bar/groovy').into('target/bar')
106
+ package(:jar)
107
+ end
108
+ lambda { define('foo').compile.with(project('bar').package(:jar)).invoke }.should run_task('foo:compile')
109
+ file('target/classes/some/Example.class').should exist
110
+ end
111
+
112
+ it 'should cross compile java sources' do
113
+ write 'src/main/java/some/Foo.java', 'package some; public interface Foo { public void hello(); }'
114
+ write 'src/main/java/some/Baz.java', 'package some; public class Baz extends Bar { }'
115
+ write 'src/main/groovy/some/Bar.groovy', 'package some; class Bar implements Foo { def void hello() { } }'
116
+ define('foo').compile.invoke
117
+ %w{Foo Bar Baz}.each { |f| file("target/classes/some/#{f}.class").should exist }
118
+ end
119
+
120
+ it 'should cross compile test java sources' do
121
+ write 'src/test/java/some/Foo.java', 'package some; public interface Foo { public void hello(); }'
122
+ write 'src/test/java/some/Baz.java', 'package some; public class Baz extends Bar { }'
123
+ write 'src/test/groovy/some/Bar.groovy', 'package some; class Bar implements Foo { def void hello() { } }'
124
+ define('foo').test.compile.invoke
125
+ %w{Foo Bar Baz}.each { |f| file("target/test/classes/some/#{f}.class").should exist }
126
+ end
127
+
128
+ it 'should package classes into a jar file' do
129
+ write 'src/main/groovy/some/Example.groovy', 'package some; class Example { }'
130
+ define('foo', :version => '1.0').package.invoke
131
+ file('target/foo-1.0.jar').should exist
132
+ Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
133
+ jar.file.exist?('some/Example.class').should be_true
134
+ end
135
+ end
136
+
137
+ end
138
+
139
+ describe 'groovyc compiler options' do
140
+
141
+ def groovyc(&prc)
142
+ define('foo') do
143
+ compile.using(:groovyc)
144
+ @compiler = compile.instance_eval { @compiler }
145
+ class << @compiler
146
+ public :groovyc_options, :javac_options
147
+ end
148
+ if block_given?
149
+ instance_eval(&prc)
150
+ else
151
+ return compile
152
+ end
153
+ end
154
+ project('foo').compile
155
+ end
156
+
157
+ it 'should set warning option to false by default' do
158
+ groovyc do
159
+ compile.options.warnings.should be_false
160
+ @compiler.javac_options[:nowarn].should be_true
161
+ end
162
+ end
163
+
164
+ it 'should set warning option to true when running with --verbose option' do
165
+ verbose true
166
+ groovyc do
167
+ compile.options.warnings.should be_true
168
+ @compiler.javac_options[:nowarn].should be_false
169
+ end
170
+ end
171
+
172
+ it 'should not set verbose option by default' do
173
+ groovyc.options.verbose.should be_false
174
+ end
175
+
176
+ it 'should set verbose option when running with --trace option' do
177
+ trace true
178
+ groovyc.options.verbose.should be_true
179
+ end
180
+
181
+ it 'should set debug option to false based on Buildr.options' do
182
+ Buildr.options.debug = false
183
+ groovyc.options.debug.should be_false
184
+ end
185
+
186
+ it 'should set debug option to false based on debug environment variable' do
187
+ ENV['debug'] = 'no'
188
+ groovyc.options.debug.should be_false
189
+ end
190
+
191
+ it 'should set debug option to false based on DEBUG environment variable' do
192
+ ENV['DEBUG'] = 'no'
193
+ groovyc.options.debug.should be_false
194
+ end
195
+
196
+ it 'should set deprecation option to false by default' do
197
+ groovyc.options.deprecation.should be_false
198
+ end
199
+
200
+ it 'should use deprecation argument when deprecation is true' do
201
+ groovyc do
202
+ compile.using(:deprecation=>true)
203
+ compile.options.deprecation.should be_true
204
+ @compiler.javac_options[:deprecation].should be_true
205
+ end
206
+ end
207
+
208
+ it 'should not use deprecation argument when deprecation is false' do
209
+ groovyc do
210
+ compile.using(:deprecation=>false)
211
+ compile.options.deprecation.should be_false
212
+ @compiler.javac_options[:deprecation].should_not be_true
213
+ end
214
+ end
215
+
216
+ it 'should set optimise option to false by default' do
217
+ groovyc.options.optimise.should be_false
218
+ end
219
+
220
+ it 'should use optimize argument when deprecation is true' do
221
+ groovyc do
222
+ compile.using(:optimise=>true)
223
+ @compiler.javac_options[:optimize].should be_true
224
+ end
225
+ end
226
+
227
+ it 'should not use optimize argument when deprecation is false' do
228
+ groovyc do
229
+ compile.using(:optimise=>false)
230
+ @compiler.javac_options[:optimize].should be_false
231
+ end
232
+ end
233
+
234
+ after do
235
+ Buildr.options.debug = nil
236
+ ENV.delete "debug"
237
+ ENV.delete "DEBUG"
238
+ end
239
+
240
+ end
@@ -0,0 +1,501 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+
20
+ 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
+ REXML::Document.new(File.open('.classpath')).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
+ def project_xml_elements
65
+ task('eclipse').invoke
66
+ REXML::Document.new(File.open('.project')).root.elements
67
+ end
68
+
69
+ def project_natures
70
+ project_xml_elements.collect("natures/nature") { |n| n.text }
71
+ end
72
+
73
+ def build_commands
74
+ project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
75
+ end
76
+
77
+ def classpath_containers(attribute='path')
78
+ classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
79
+ end
80
+ end
81
+
82
+
83
+ describe Buildr::Eclipse do
84
+ include EclipseHelper
85
+
86
+ describe "eclipse's .project file" do
87
+
88
+ describe 'java project' do
89
+ before do
90
+ write 'buildfile'
91
+ write 'src/main/java/Main.java'
92
+ end
93
+
94
+ it 'should have Java nature' do
95
+ define('foo')
96
+ project_natures.should include(JAVA_NATURE)
97
+ end
98
+
99
+ it 'should have Java build command' do
100
+ define('foo')
101
+ build_commands.should include(JAVA_BUILDER)
102
+ end
103
+ end
104
+
105
+ describe 'nested java project' do
106
+
107
+ it 'should have name corresponding to its project definition' do
108
+ mkdir 'foo'
109
+ define('myproject') {
110
+ project.version = '1.0'
111
+ define('foo') { compile.using(:javac); package :jar }
112
+ }
113
+ task('eclipse').invoke
114
+ REXML::Document.new(File.open(File.join('foo', '.project'))).root.
115
+ elements.collect("name") { |e| e.text }.should == ['myproject-foo']
116
+ end
117
+
118
+ end
119
+
120
+ describe 'scala project' do
121
+
122
+ before do
123
+ define 'foo' do
124
+ eclipse.natures :scala
125
+ end
126
+ end
127
+
128
+ it 'should have Scala nature before Java nature' do
129
+ project_natures.should include(SCALA_NATURE)
130
+ project_natures.should include(JAVA_NATURE)
131
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
132
+ end
133
+
134
+ it 'should have Scala build command and no Java build command' do
135
+ build_commands.should include(SCALA_BUILDER)
136
+ build_commands.should_not include(JAVA_BUILDER)
137
+ end
138
+ end
139
+
140
+ describe 'standard scala project' do
141
+
142
+ before do
143
+ write 'buildfile'
144
+ write 'src/main/scala/Main.scala'
145
+ define 'foo'
146
+ end
147
+
148
+ it 'should have Scala nature before Java nature' do
149
+ project_natures.should include(SCALA_NATURE)
150
+ project_natures.should include(JAVA_NATURE)
151
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
152
+ end
153
+
154
+ it 'should have Scala build command and no Java build command' do
155
+ build_commands.should include(SCALA_BUILDER)
156
+ build_commands.should_not include(JAVA_BUILDER)
157
+ end
158
+ end
159
+
160
+ describe 'non-standard scala project' do
161
+
162
+ before do
163
+ write 'buildfile'
164
+ write 'src/main/foo/Main.scala'
165
+ define 'foo' do
166
+ eclipse.natures = :scala
167
+ end
168
+ end
169
+
170
+ it 'should have Scala nature before Java nature' do
171
+ project_natures.should include(SCALA_NATURE)
172
+ project_natures.should include(JAVA_NATURE)
173
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
174
+ end
175
+
176
+ it 'should have Scala build command and no Java build command' do
177
+ build_commands.should include(SCALA_BUILDER)
178
+ build_commands.should_not include(JAVA_BUILDER)
179
+ end
180
+ end
181
+
182
+ describe 'Plugin project' do
183
+
184
+ before do
185
+ write 'buildfile'
186
+ write 'src/main/java/Activator.java'
187
+ write 'plugin.xml'
188
+ end
189
+
190
+ it 'should have plugin nature before Java nature' do
191
+ define('foo')
192
+ project_natures.should include(PLUGIN_NATURE)
193
+ project_natures.should include(JAVA_NATURE)
194
+ project_natures.index(PLUGIN_NATURE).should < project_natures.index(JAVA_NATURE)
195
+ end
196
+
197
+ it 'should have plugin build commands and the Java build command' do
198
+ define('foo')
199
+ build_commands.should include(PLUGIN_BUILDERS[0])
200
+ build_commands.should include(PLUGIN_BUILDERS[1])
201
+ build_commands.should include(JAVA_BUILDER)
202
+ end
203
+ end
204
+ end
205
+
206
+ describe "eclipse's .classpath file" do
207
+
208
+ describe 'scala project' do
209
+
210
+ before do
211
+ write 'buildfile'
212
+ write 'src/main/scala/Main.scala'
213
+ end
214
+
215
+ it 'should have SCALA_CONTAINER before JAVA_CONTAINER' do
216
+ define('foo')
217
+ classpath_containers.should include(SCALA_CONTAINER)
218
+ classpath_containers.should include(JAVA_CONTAINER)
219
+ classpath_containers.index(SCALA_CONTAINER).should < classpath_containers.index(JAVA_CONTAINER)
220
+ end
221
+ end
222
+
223
+ describe 'source folders' do
224
+
225
+ before do
226
+ write 'buildfile'
227
+ write 'src/main/java/Main.java'
228
+ write 'src/test/java/Test.java'
229
+ end
230
+
231
+ describe 'source', :shared=>true do
232
+ it 'should ignore CVS and SVN files' do
233
+ define('foo')
234
+ classpath_sources('excluding').each do |excluding_attribute|
235
+ excluding = excluding_attribute.split('|')
236
+ excluding.should include('**/.svn/')
237
+ excluding.should include('**/CVS/')
238
+ end
239
+ end
240
+ end
241
+
242
+ describe 'main code' do
243
+ it_should_behave_like 'source'
244
+
245
+ it 'should accept to come from the default directory' do
246
+ define('foo')
247
+ classpath_sources.should include('src/main/java')
248
+ end
249
+
250
+ it 'should accept to come from a user-defined directory' do
251
+ define('foo') { compile path_to('src/java') }
252
+ classpath_sources.should include('src/java')
253
+ end
254
+
255
+ it 'should accept a file task as a main source folder' do
256
+ define('foo') { compile apt }
257
+ classpath_sources.should include('target/generated/apt')
258
+ end
259
+
260
+ it 'should go to the default target directory' do
261
+ define('foo')
262
+ classpath_specific_output('src/main/java').should be(nil)
263
+ classpath_default_output.should == 'target/classes'
264
+ end
265
+ end
266
+
267
+ describe 'test code' do
268
+ it_should_behave_like 'source'
269
+
270
+ it 'should accept to come from the default directory' do
271
+ define('foo')
272
+ classpath_sources.should include('src/test/java')
273
+ end
274
+
275
+ it 'should accept to come from a user-defined directory' do
276
+ define('foo') { test.compile path_to('src/test') }
277
+ classpath_sources.should include('src/test')
278
+ end
279
+
280
+ it 'should go to the default target directory' do
281
+ define('foo')
282
+ classpath_specific_output('src/test/java').should == 'target/test/classes'
283
+ end
284
+
285
+ it 'should accept to be the only code in the project' do
286
+ rm 'src/main/java/Main.java'
287
+ define('foo')
288
+ classpath_sources.should include('src/test/java')
289
+ end
290
+ end
291
+
292
+ describe 'main resources' do
293
+ it_should_behave_like 'source'
294
+
295
+ before do
296
+ write 'src/main/resources/config.xml'
297
+ end
298
+
299
+ it 'should accept to come from the default directory' do
300
+ define('foo')
301
+ classpath_sources.should include('src/main/resources')
302
+ end
303
+
304
+ it 'should share a classpath entry if it comes from a directory with code' do
305
+ write 'src/main/java/config.properties'
306
+ define('foo') { resources.from('src/main/java').exclude('**/*.java') }
307
+ classpath_sources.select { |path| path == 'src/main/java'}.length.should == 1
308
+ end
309
+
310
+ it 'should go to the default target directory' do
311
+ define('foo')
312
+ classpath_specific_output('src/main/resources').should == 'target/resources'
313
+ end
314
+ end
315
+
316
+ describe 'test resources' do
317
+ it_should_behave_like 'source'
318
+
319
+ before do
320
+ write 'src/test/resources/config-test.xml'
321
+ end
322
+
323
+ it 'should accept to come from the default directory' do
324
+ define('foo')
325
+ classpath_sources.should include('src/test/resources')
326
+ end
327
+
328
+ it 'should share a classpath entry if it comes from a directory with code' do
329
+ write 'src/test/java/config-test.properties'
330
+ define('foo') { test.resources.from('src/test/java').exclude('**/*.java') }
331
+ classpath_sources.select { |path| path == 'src/test/java'}.length.should == 1
332
+ end
333
+
334
+ it 'should go to the default target directory' do
335
+ define('foo')
336
+ classpath_specific_output('src/test/resources').should == 'target/test/resources'
337
+ end
338
+ end
339
+ end
340
+
341
+ describe 'project depending on another project' do
342
+ it 'should have the underlying project in its classpath' do
343
+ mkdir 'foo'
344
+ mkdir 'bar'
345
+ define('myproject') {
346
+ project.version = '1.0'
347
+ define('foo') { package :jar }
348
+ define('bar') { compile.using(:javac).with project('foo'); }
349
+ }
350
+ task('eclipse').invoke
351
+ REXML::Document.new(File.open(File.join('bar', '.classpath'))).root.
352
+ elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should include('/myproject-foo')
353
+ end
354
+ end
355
+ end
356
+
357
+ describe 'local dependency' do
358
+ before do
359
+ write 'lib/some-local.jar'
360
+ define('foo') { compile.using(:javac).with(_('lib/some-local.jar')) }
361
+ end
362
+
363
+ it 'should have a lib artifact reference in the .classpath file' do
364
+ classpath_xml_elements.collect("classpathentry[@kind='lib']") { |n| n.attributes['path'] }.
365
+ should include(File.expand_path 'lib/some-local.jar')
366
+ end
367
+ end
368
+
369
+ describe 'generated .classes' do
370
+ before do
371
+ write 'lib/some.class'
372
+ define('foo') { compile.using(:javac).with(_('lib')) }
373
+ end
374
+
375
+ it 'should have src reference in the .classpath file' do
376
+ classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.
377
+ should include('lib')
378
+ end
379
+ end
380
+
381
+ describe 'maven2 artifact dependency' do
382
+ before do
383
+ define('foo') { compile.using(:javac).with('com.example:library:jar:2.0') }
384
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
385
+ task('eclipse').invoke
386
+ end
387
+
388
+ it 'should have a reference in the .classpath file relative to the local M2 repo' do
389
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
390
+ should include('M2_REPO/com/example/library/2.0/library-2.0.jar')
391
+ end
392
+
393
+ it 'should be downloaded' do
394
+ file(artifact('com.example:library:jar:2.0').name).should exist
395
+ end
396
+
397
+ it 'should have a source artifact reference in the .classpath file' do
398
+ sourcepath_for_path('M2_REPO/com/example/library/2.0/library-2.0.jar').
399
+ should == ['M2_REPO/com/example/library/2.0/library-2.0-sources.jar']
400
+ end
401
+ end
402
+
403
+ describe 'maven2 repository variable' do
404
+ it 'should be configurable' do
405
+ define('foo') do
406
+ eclipse.options.m2_repo_var = 'PROJ_REPO'
407
+ compile.using(:javac).with('com.example:library:jar:2.0')
408
+ end
409
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
410
+
411
+ task('eclipse').invoke
412
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
413
+ should include('PROJ_REPO/com/example/library/2.0/library-2.0.jar')
414
+ end
415
+
416
+ it 'should pick the parent value by default' do
417
+ define('foo') do
418
+ eclipse.options.m2_repo_var = 'FOO_REPO'
419
+ define('bar')
420
+
421
+ define('bar2') do
422
+ eclipse.options.m2_repo_var = 'BAR2_REPO'
423
+ end
424
+ end
425
+ project('foo:bar').eclipse.options.m2_repo_var.should eql('FOO_REPO')
426
+ project('foo:bar2').eclipse.options.m2_repo_var.should eql('BAR2_REPO')
427
+ end
428
+ end
429
+
430
+ describe 'natures variable' do
431
+ it 'should be configurable' do
432
+ define('foo') do
433
+ eclipse.natures = 'dummyNature'
434
+ compile.using(:javac).with('com.example:library:jar:2.0')
435
+ end
436
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
437
+ project_natures.should include('dummyNature')
438
+ end
439
+
440
+ it 'should pick the parent value by default' do
441
+ define('foo') do
442
+ eclipse.natures = 'foo_nature'
443
+ define('bar')
444
+
445
+ define('bar2') do
446
+ eclipse.natures = 'bar2_nature'
447
+ end
448
+ end
449
+ project('foo:bar').eclipse.natures.should include('foo_nature')
450
+ project('foo:bar2').eclipse.natures.should include('bar2_nature')
451
+ end
452
+ end
453
+
454
+ describe 'builders variable' do
455
+ it 'should be configurable' do
456
+ define('foo') do
457
+ eclipse.builders 'dummyBuilder'
458
+ compile.using(:javac).with('com.example:library:jar:2.0')
459
+ end
460
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
461
+ build_commands.should include('dummyBuilder')
462
+ end
463
+
464
+ it 'should pick the parent value by default' do
465
+ define('foo') do
466
+ eclipse.builders = 'foo_builder'
467
+ define('bar')
468
+
469
+ define('bar2') do
470
+ eclipse.builders = 'bar2_builder'
471
+ end
472
+ end
473
+ project('foo:bar').eclipse.builders.should include('foo_builder')
474
+ project('foo:bar2').eclipse.builders.should include('bar2_builder')
475
+ end
476
+ end
477
+
478
+ describe 'classpath_containers variable' do
479
+ it 'should be configurable' do
480
+ define('foo') do
481
+ eclipse.classpath_containers = 'myOlGoodContainer'
482
+ compile.using(:javac).with('com.example:library:jar:2.0')
483
+ end
484
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
485
+ classpath_containers.should include('myOlGoodContainer')
486
+ end
487
+
488
+ it 'should pick the parent value by default' do
489
+ define('foo') do
490
+ eclipse.classpath_containers = 'foo_classpath_containers'
491
+ define('bar')
492
+
493
+ define('bar2') do
494
+ eclipse.classpath_containers = 'bar2_classpath_containers'
495
+ end
496
+ end
497
+ project('foo:bar').eclipse.classpath_containers.should include('foo_classpath_containers')
498
+ project('foo:bar2').eclipse.classpath_containers.should include('bar2_classpath_containers')
499
+ end
500
+ end
501
+ end