realityforge-buildr 1.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.md +3 -0
  6. data/Rakefile +50 -0
  7. data/addon/buildr/checkstyle-report.xsl +104 -0
  8. data/addon/buildr/checkstyle.rb +254 -0
  9. data/addon/buildr/git_auto_version.rb +36 -0
  10. data/addon/buildr/gpg.rb +90 -0
  11. data/addon/buildr/gwt.rb +413 -0
  12. data/addon/buildr/jacoco.rb +161 -0
  13. data/addon/buildr/pmd.rb +185 -0
  14. data/addon/buildr/single_intermediate_layout.rb +71 -0
  15. data/addon/buildr/spotbugs.rb +265 -0
  16. data/addon/buildr/top_level_generate_dir.rb +37 -0
  17. data/addon/buildr/wsgen.rb +192 -0
  18. data/bin/buildr +20 -0
  19. data/buildr.gemspec +61 -0
  20. data/lib/buildr.rb +86 -0
  21. data/lib/buildr/core/application.rb +705 -0
  22. data/lib/buildr/core/assets.rb +96 -0
  23. data/lib/buildr/core/build.rb +587 -0
  24. data/lib/buildr/core/common.rb +167 -0
  25. data/lib/buildr/core/compile.rb +599 -0
  26. data/lib/buildr/core/console.rb +124 -0
  27. data/lib/buildr/core/doc.rb +275 -0
  28. data/lib/buildr/core/environment.rb +128 -0
  29. data/lib/buildr/core/filter.rb +405 -0
  30. data/lib/buildr/core/help.rb +114 -0
  31. data/lib/buildr/core/progressbar.rb +161 -0
  32. data/lib/buildr/core/project.rb +994 -0
  33. data/lib/buildr/core/test.rb +776 -0
  34. data/lib/buildr/core/transports.rb +456 -0
  35. data/lib/buildr/core/util.rb +77 -0
  36. data/lib/buildr/ide/idea.rb +1664 -0
  37. data/lib/buildr/java/commands.rb +230 -0
  38. data/lib/buildr/java/compiler.rb +85 -0
  39. data/lib/buildr/java/custom_pom.rb +300 -0
  40. data/lib/buildr/java/doc.rb +62 -0
  41. data/lib/buildr/java/packaging.rb +393 -0
  42. data/lib/buildr/java/pom.rb +191 -0
  43. data/lib/buildr/java/test_result.rb +54 -0
  44. data/lib/buildr/java/tests.rb +111 -0
  45. data/lib/buildr/packaging/archive.rb +586 -0
  46. data/lib/buildr/packaging/artifact.rb +1113 -0
  47. data/lib/buildr/packaging/artifact_namespace.rb +1010 -0
  48. data/lib/buildr/packaging/artifact_search.rb +138 -0
  49. data/lib/buildr/packaging/package.rb +237 -0
  50. data/lib/buildr/packaging/version_requirement.rb +189 -0
  51. data/lib/buildr/packaging/zip.rb +189 -0
  52. data/lib/buildr/packaging/ziptask.rb +387 -0
  53. data/lib/buildr/version.rb +18 -0
  54. data/rakelib/release.rake +99 -0
  55. data/spec/addon/checkstyle_spec.rb +58 -0
  56. data/spec/core/application_spec.rb +576 -0
  57. data/spec/core/build_spec.rb +922 -0
  58. data/spec/core/common_spec.rb +670 -0
  59. data/spec/core/compile_spec.rb +656 -0
  60. data/spec/core/console_spec.rb +65 -0
  61. data/spec/core/doc_spec.rb +194 -0
  62. data/spec/core/extension_spec.rb +200 -0
  63. data/spec/core/project_spec.rb +736 -0
  64. data/spec/core/test_spec.rb +1131 -0
  65. data/spec/core/transport_spec.rb +452 -0
  66. data/spec/core/util_spec.rb +154 -0
  67. data/spec/ide/idea_spec.rb +1952 -0
  68. data/spec/java/commands_spec.rb +79 -0
  69. data/spec/java/compiler_spec.rb +274 -0
  70. data/spec/java/custom_pom_spec.rb +165 -0
  71. data/spec/java/doc_spec.rb +55 -0
  72. data/spec/java/packaging_spec.rb +786 -0
  73. data/spec/java/pom_spec.rb +162 -0
  74. data/spec/java/test_coverage_helper.rb +257 -0
  75. data/spec/java/tests_spec.rb +224 -0
  76. data/spec/packaging/archive_spec.rb +686 -0
  77. data/spec/packaging/artifact_namespace_spec.rb +757 -0
  78. data/spec/packaging/artifact_spec.rb +1351 -0
  79. data/spec/packaging/packaging_helper.rb +63 -0
  80. data/spec/packaging/packaging_spec.rb +690 -0
  81. data/spec/sandbox.rb +166 -0
  82. data/spec/spec_helpers.rb +420 -0
  83. data/spec/version_requirement_spec.rb +145 -0
  84. data/spec/xpath_matchers.rb +123 -0
  85. metadata +295 -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
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
17
+
18
+ describe Buildr::Console do
19
+
20
+ describe 'console_dimensions' do
21
+
22
+ it 'should return a value' do
23
+ Buildr::Console.console_dimensions.should_not be_nil if $stdout.isatty # have to ask again as stdout may be redirected.
24
+ end if $stdout.isatty && !ENV["TRAVIS"]
25
+ end
26
+
27
+ describe 'color' do
28
+
29
+ describe 'when use_color is true' do
30
+ before do
31
+ Buildr::Console.use_color = true
32
+ end
33
+
34
+ it 'should emit red code when asked' do
35
+ Buildr::Console.color('message', :red).should eql("\e[31mmessage\e[0m")
36
+ end
37
+
38
+ it 'should emit green code when asked' do
39
+ Buildr::Console.color('message', :green).should eql("\e[32mmessage\e[0m")
40
+ end
41
+
42
+ it 'should emit blue code when asked' do
43
+ Buildr::Console.color('message', :blue).should eql("\e[34mmessage\e[0m")
44
+ end
45
+ end if $stdout.isatty
46
+
47
+ describe ' use_color is false' do
48
+ before do
49
+ Buildr::Console.use_color = false
50
+ end
51
+
52
+ it 'should not emit red code when asked' do
53
+ Buildr::Console.color('message', :red).should eql("message")
54
+ end
55
+
56
+ it 'should not emit green code when asked' do
57
+ Buildr::Console.color('message', :green).should eql("message")
58
+ end
59
+
60
+ it 'should not emit blue code when asked' do
61
+ Buildr::Console.color('message', :blue).should eql("message")
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,194 @@
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
+ describe Project, '#doc' do
21
+ def sources
22
+ @sources ||= (1..3).map { |i| "Test#{i}" }.
23
+ each { |name| write "src/main/java/foo/#{name}.java", "package foo; public class #{name}{}" }.
24
+ map { |name| "src/main/java/foo/#{name}.java" }
25
+ end
26
+
27
+ it 'should return the project\'s Javadoc task' do
28
+ define('foo') { compile.using(:javac) }
29
+ project('foo').doc.name.should eql('foo:doc')
30
+ end
31
+
32
+ it 'should return a DocTask' do
33
+ define('foo') { compile.using(:javac) }
34
+ project('foo').doc.should be_kind_of(Doc::DocTask)
35
+ end
36
+
37
+ it 'should set target directory to target/doc' do
38
+ define 'foo' do
39
+ compile.using(:javac)
40
+ doc.target.to_s.should point_to_path('target/doc')
41
+ end
42
+ end
43
+
44
+ it 'should create file task for target directory' do
45
+ define 'foo' do
46
+ compile.using(:javac)
47
+ doc.should_receive(:invoke_prerequisites)
48
+ end
49
+ project('foo').file('target/doc').invoke
50
+ end
51
+
52
+ it 'should respond to into() and return self' do
53
+ define 'foo' do
54
+ compile.using(:javac)
55
+ doc.into('docs').should be(doc)
56
+ end
57
+ end
58
+
59
+ it 'should respond to into() and change target directory' do
60
+ define 'foo' do
61
+ compile.using(:javac)
62
+ doc.into('docs')
63
+ doc.should_receive(:invoke_prerequisites)
64
+ end
65
+ file('docs').invoke
66
+ end
67
+
68
+ it 'should respond to from() and return self' do
69
+ task = nil
70
+ define('foo') do
71
+ compile.using(:javac)
72
+ task = doc.from('srcs')
73
+ end
74
+ task.should be(project('foo').doc)
75
+ end
76
+
77
+ it 'should respond to from() and add sources' do
78
+ define 'foo' do
79
+ compile.using(:javac)
80
+ doc.from('srcs').should be(doc)
81
+ end
82
+ end
83
+
84
+ it 'should respond to from() and add file task' do
85
+ define 'foo' do
86
+ compile.using(:javac)
87
+ doc.from('srcs').should be(doc)
88
+ end
89
+ project('foo').doc.source_files.first.should point_to_path('srcs')
90
+ end
91
+
92
+ it 'should respond to from() and add project\'s sources and dependencies' do
93
+ write 'bar/src/main/java/Test.java'
94
+ define 'foo' do
95
+ compile.using(:javac)
96
+ define('bar') { compile.using(:javac).with 'group:id:jar:1.0' }
97
+ doc.from project('foo:bar')
98
+ end
99
+ project('foo').doc.source_files.first.should point_to_path('bar/src/main/java/Test.java')
100
+ project('foo').doc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
101
+ end
102
+
103
+ it 'should generate docs from project' do
104
+ sources
105
+ define('foo') { compile.using(:javac) }
106
+ project('foo').doc.source_files.sort.should == sources.sort.map { |f| File.expand_path(f) }
107
+ end
108
+
109
+ it 'should include compile dependencies' do
110
+ define('foo') { compile.using(:javac).with 'group:id:jar:1.0' }
111
+ project('foo').doc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
112
+ end
113
+
114
+ it 'should respond to include() and return self' do
115
+ define 'foo' do
116
+ compile.using(:javac)
117
+ doc.include('srcs').should be(doc)
118
+ end
119
+ end
120
+
121
+ it 'should respond to include() and add files' do
122
+ included = sources.first
123
+ define 'foo' do
124
+ compile.using(:javac)
125
+ doc.include included
126
+ end
127
+ project('foo').doc.source_files.should include(File.expand_path(included))
128
+ end
129
+
130
+ it 'should respond to exclude() and return self' do
131
+ define 'foo' do
132
+ compile.using(:javac)
133
+ doc.exclude('srcs').should be(doc)
134
+ end
135
+ end
136
+
137
+ it 'should respond to exclude() and ignore files' do
138
+ excluded = sources.first
139
+ define 'foo' do
140
+ compile.using(:javac)
141
+ doc.exclude excluded
142
+ end
143
+ sources
144
+ project('foo').doc.source_files.sort.should == sources[1..-1].map { |f| File.expand_path(f) }
145
+ end
146
+
147
+ it 'should respond to using() and return self' do
148
+ define 'foo' do
149
+ compile.using(:javac)
150
+ doc.using(:foo=>'Fooing').should be(doc)
151
+ end
152
+ end
153
+
154
+ it 'should respond to using() and accept options' do
155
+ define 'foo' do
156
+ compile.using(:javac)
157
+ doc.using :foo=>'Fooing'
158
+ end
159
+ project('foo').doc.options[:foo].should eql('Fooing')
160
+ end
161
+
162
+ it 'should produce documentation' do
163
+ sources
164
+ define('foo') { compile.using(:javac) }
165
+ project('foo').doc.invoke
166
+ (1..3).map { |i| "target/doc/foo/Test#{i}.html" }.each { |f| file(f).should exist }
167
+ end
168
+
169
+ it 'should fail on error' do
170
+ write 'Test.java', 'class Test {}'
171
+ define 'foo' do
172
+ compile.using(:javac)
173
+ doc.include 'Test.java'
174
+ end
175
+ lambda { project('foo').doc.invoke }.should raise_error(RuntimeError, /Failed to generate Javadocs/)
176
+ end
177
+
178
+ it 'should be local task' do
179
+ define 'foo' do
180
+ define('bar') { compile.using(:javac) }
181
+ end
182
+ project('foo:bar').doc.should_receive(:invoke_prerequisites)
183
+ in_original_dir(project('foo:bar').base_dir) { task('doc').invoke }
184
+ end
185
+
186
+ it 'should not recurse' do
187
+ define 'foo' do
188
+ compile.using(:javac)
189
+ define('bar') { compile.using(:javac) }
190
+ end
191
+ project('foo:bar').doc.should_not_receive(:invoke_prerequisites)
192
+ project('foo').doc.invoke
193
+ end
194
+ end
@@ -0,0 +1,200 @@
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
+ describe Extension do
21
+
22
+ before do
23
+ @saved_modules = Project.class_eval { @extension_modules }.dup
24
+ @saved_callbacks = Project.class_eval { @global_callbacks }.dup
25
+ end
26
+
27
+ after do
28
+ modules = @saved_modules
29
+ callbacks = @saved_callbacks
30
+ Project.class_eval do
31
+ @global_callbacks = callbacks
32
+ @extension_modules = modules
33
+ end
34
+ end
35
+
36
+ it 'should call Extension.first_time during include' do
37
+ TestExtension.should_receive(:first_time_called).once
38
+ class Buildr::Project
39
+ include TestExtension
40
+ end
41
+ end
42
+
43
+ it 'should call before_define and after_define in order when project is defined' do
44
+ begin
45
+ TestExtension.callback do |extension|
46
+ extension.should_receive(:before_define_called).once.ordered
47
+ extension.should_receive(:after_define_called).once.ordered
48
+ end
49
+ class Buildr::Project
50
+ include TestExtension
51
+ end
52
+ define('foo')
53
+ ensure
54
+ TestExtension.callback { |ignore| }
55
+ end
56
+ end
57
+
58
+ it 'should call before_define and after_define for each project defined' do
59
+ begin
60
+ extensions = 0
61
+ TestExtension.callback do |extension|
62
+ extensions += 1
63
+ extension.should_receive(:before_define_called).once.ordered
64
+ extension.should_receive(:after_define_called).once.ordered
65
+ end
66
+ class Buildr::Project
67
+ include TestExtension
68
+ end
69
+ define('foo')
70
+ define('bar')
71
+ extensions.should equal(2)
72
+ ensure
73
+ TestExtension.callback { |ignore| }
74
+ end
75
+ end
76
+
77
+ it 'should call before_define callbacks in dependency order' do
78
+ class Buildr::Project
79
+ include ExtensionOneTwo
80
+ include ExtensionThreeFour
81
+ end
82
+ define('foo')
83
+ project('foo').before_order.should == [ :one, :two, :three, :four ]
84
+ project('foo').after_order.should == [ :four, :three, :two, :one ]
85
+ end
86
+
87
+ it 'should call before_define callbacks when extending project' do
88
+ define('foo') do
89
+ extend ExtensionOneTwo
90
+ extend ExtensionThreeFour
91
+ end
92
+ project('foo').before_order.should == [ :two, :one, :four, :three ]
93
+ project('foo').after_order.should == [ :four, :three, :two, :one ]
94
+ end
95
+
96
+ it 'should raise error when including if callback dependencies cannot be satisfied' do
97
+ class Buildr::Project
98
+ include ExtensionOneTwo # missing ExtensionThreeFour
99
+ end
100
+ lambda { define('foo') }.should raise_error
101
+ end
102
+
103
+ it 'should raise error when extending if callback dependencies cannot be satisfied' do
104
+ lambda {
105
+ define('foo') do |project|
106
+ extend ExtensionOneTwo # missing ExtensionThreeFour
107
+ end
108
+ }.should raise_error
109
+ end
110
+
111
+ it 'should ignore dependencies when extending project' do
112
+ define('bar') do |project|
113
+ extend ExtensionThreeFour # missing ExtensionOneTwo
114
+ end
115
+ project('bar').before_order.should == [:four, :three]
116
+ project('bar').after_order.should == [:four, :three]
117
+ end
118
+ end
119
+
120
+ module TestExtension
121
+ include Extension
122
+
123
+ def initialize(*args)
124
+ super
125
+ # callback is used to obtain extension instance created by buildr
126
+ @@callback.call(self) if @@callback
127
+ end
128
+
129
+ def self.callback(&block)
130
+ @@callback = block
131
+ end
132
+
133
+ first_time do
134
+ self.first_time_called()
135
+ end
136
+
137
+ before_define do |project|
138
+ project.before_define_called()
139
+ end
140
+
141
+ after_define do |project|
142
+ project.after_define_called()
143
+ end
144
+
145
+ def self.first_time_called()
146
+ end
147
+
148
+ end
149
+
150
+ module BeforeAfter
151
+ def before_order
152
+ @before_order ||= []
153
+ end
154
+
155
+ def after_order
156
+ @after_order ||= []
157
+ end
158
+ end
159
+
160
+ module ExtensionOneTwo
161
+ include Extension, BeforeAfter
162
+
163
+ before_define(:two => :one) do |project|
164
+ project.before_order << :two
165
+ end
166
+
167
+ before_define(:one) do |project|
168
+ project.before_order << :one
169
+ end
170
+
171
+ after_define(:one => :two) do |project|
172
+ project.after_order << :one
173
+ end
174
+
175
+ after_define(:two => :three) do |project|
176
+ project.after_order << :two
177
+ end
178
+ end
179
+
180
+ module ExtensionThreeFour
181
+ include Extension, BeforeAfter
182
+
183
+ before_define(:three => :two)
184
+
185
+ before_define(:four => :three) do |project|
186
+ project.before_order << :four
187
+ end
188
+
189
+ before_define(:three) do |project|
190
+ project.before_order << :three
191
+ end
192
+
193
+ after_define(:three => :four) do |project|
194
+ project.after_order << :three
195
+ end
196
+
197
+ after_define(:four) do |project|
198
+ project.after_order << :four
199
+ end
200
+ end