mguymon-buildr 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1291 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +44 -0
- data/_buildr +35 -0
- data/_jbuildr +35 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/bnd.rb +147 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +149 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jaxb_xjc.rb +72 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +88 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/protobuf.rb +88 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +78 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +90 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +217 -0
- data/doc/building.textile +276 -0
- data/doc/contributing.textile +268 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +151 -0
- data/doc/extending.textile +212 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +109 -0
- data/doc/installing.textile +284 -0
- data/doc/languages.textile +599 -0
- data/doc/mailing_lists.textile +29 -0
- data/doc/more_stuff.textile +845 -0
- data/doc/packaging.textile +618 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +276 -0
- data/doc/quick_start.textile +210 -0
- data/doc/releasing.textile +117 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +73 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +287 -0
- data/doc/testing.textile +247 -0
- data/etc/KEYS +189 -0
- data/lib/buildr.rb +44 -0
- data/lib/buildr/clojure.rb +34 -0
- data/lib/buildr/clojure/shell.rb +52 -0
- data/lib/buildr/core.rb +34 -0
- data/lib/buildr/core/application.rb +700 -0
- data/lib/buildr/core/build.rb +516 -0
- data/lib/buildr/core/cc.rb +166 -0
- data/lib/buildr/core/checks.rb +253 -0
- data/lib/buildr/core/common.rb +151 -0
- data/lib/buildr/core/compile.rb +622 -0
- data/lib/buildr/core/doc.rb +276 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +404 -0
- data/lib/buildr/core/generate.rb +197 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/jrebel.rb +42 -0
- data/lib/buildr/core/linux.rb +30 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +975 -0
- data/lib/buildr/core/run.rb +43 -0
- data/lib/buildr/core/shell.rb +137 -0
- data/lib/buildr/core/test.rb +843 -0
- data/lib/buildr/core/transports.rb +575 -0
- data/lib/buildr/core/util.rb +537 -0
- data/lib/buildr/groovy.rb +20 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +153 -0
- data/lib/buildr/groovy/doc.rb +76 -0
- data/lib/buildr/groovy/shell.rb +57 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +427 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +71 -0
- data/lib/buildr/ide/eclipse/scala.rb +68 -0
- data/lib/buildr/ide/idea.rb +576 -0
- data/lib/buildr/java.rb +25 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +460 -0
- data/lib/buildr/java/cobertura.rb +297 -0
- data/lib/buildr/java/commands.rb +223 -0
- data/lib/buildr/java/compiler.rb +135 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/doc.rb +86 -0
- data/lib/buildr/java/ecj.rb +69 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/external.rb +73 -0
- data/lib/buildr/java/jruby.rb +122 -0
- data/lib/buildr/java/jtestr_result.rb +295 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
- data/lib/buildr/java/packaging.rb +734 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +154 -0
- data/lib/buildr/java/test_result.rb +101 -0
- data/lib/buildr/java/tests.rb +362 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +25 -0
- data/lib/buildr/packaging/archive.rb +535 -0
- data/lib/buildr/packaging/artifact.rb +904 -0
- data/lib/buildr/packaging/artifact_namespace.rb +984 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +105 -0
- data/lib/buildr/packaging/package.rb +249 -0
- data/lib/buildr/packaging/repository_array.rb +108 -0
- data/lib/buildr/packaging/tar.rb +189 -0
- data/lib/buildr/packaging/version_requirement.rb +192 -0
- data/lib/buildr/packaging/zip.rb +178 -0
- data/lib/buildr/packaging/ziptask.rb +356 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/resources/completed.png +0 -0
- data/lib/buildr/resources/failed.png +0 -0
- data/lib/buildr/resources/icons-license.txt +17 -0
- data/lib/buildr/run.rb +195 -0
- data/lib/buildr/scala.rb +26 -0
- data/lib/buildr/scala/bdd.rb +118 -0
- data/lib/buildr/scala/compiler.rb +242 -0
- data/lib/buildr/scala/doc.rb +142 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +52 -0
- data/lib/buildr/scala/tests.rb +171 -0
- data/lib/buildr/shell.rb +185 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +137 -0
- data/rakelib/metrics.rake +39 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +160 -0
- data/rakelib/rspec.rake +91 -0
- data/rakelib/setup.rake +66 -0
- data/rakelib/stage.rake +220 -0
- data/spec/addon/bnd_spec.rb +330 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/spec/core/application_spec.rb +631 -0
- data/spec/core/build_spec.rb +837 -0
- data/spec/core/cc_spec.rb +224 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +725 -0
- data/spec/core/compile_spec.rb +658 -0
- data/spec/core/doc_spec.rb +195 -0
- data/spec/core/extension_spec.rb +201 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +772 -0
- data/spec/core/run_spec.rb +93 -0
- data/spec/core/shell_spec.rb +146 -0
- data/spec/core/test_spec.rb +1320 -0
- data/spec/core/transport_spec.rb +544 -0
- data/spec/core/util_spec.rb +141 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +251 -0
- data/spec/groovy/doc_spec.rb +65 -0
- data/spec/ide/eclipse_spec.rb +739 -0
- data/spec/ide/idea_spec.rb +1145 -0
- data/spec/java/ant_spec.rb +37 -0
- data/spec/java/bdd_spec.rb +374 -0
- data/spec/java/cobertura_spec.rb +112 -0
- data/spec/java/commands_spec.rb +93 -0
- data/spec/java/compiler_spec.rb +252 -0
- data/spec/java/doc_spec.rb +56 -0
- data/spec/java/ecj_spec.rb +115 -0
- data/spec/java/emma_spec.rb +121 -0
- data/spec/java/external_spec.rb +56 -0
- data/spec/java/java_spec.rb +132 -0
- data/spec/java/packaging_spec.rb +1266 -0
- data/spec/java/run_spec.rb +78 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +497 -0
- data/spec/packaging/archive_spec.rb +775 -0
- data/spec/packaging/artifact_namespace_spec.rb +743 -0
- data/spec/packaging/artifact_spec.rb +1074 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +719 -0
- data/spec/packaging/repository_array_spec.rb +109 -0
- data/spec/sandbox.rb +165 -0
- data/spec/scala/bdd_spec.rb +124 -0
- data/spec/scala/compiler_spec.rb +289 -0
- data/spec/scala/doc_spec.rb +88 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +283 -0
- data/spec/spec_helpers.rb +369 -0
- data/spec/version_requirement_spec.rb +143 -0
- data/spec/xpath_matchers.rb +121 -0
- metadata +649 -0
@@ -0,0 +1,141 @@
|
|
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 Buildr do
|
20
|
+
describe "#replace_extension" do
|
21
|
+
it "should replace filename extensions" do
|
22
|
+
replace = lambda { |filename, ext| Util.replace_extension(filename, ext) }
|
23
|
+
|
24
|
+
replace["foo.zip", "txt"].should eql("foo.txt")
|
25
|
+
replace["foo.", "txt"].should eql("foo.txt")
|
26
|
+
replace["foo", "txt"].should eql("foo.txt")
|
27
|
+
|
28
|
+
replace["bar/foo.zip", "txt"].should eql("bar/foo.txt")
|
29
|
+
replace["bar/foo.", "txt"].should eql("bar/foo.txt")
|
30
|
+
replace["bar/foo", "txt"].should eql("bar/foo.txt")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Hash do
|
36
|
+
describe "#only" do
|
37
|
+
it "should find value for one key" do
|
38
|
+
{:a => 1, :b => 2, :c => 3}.only(:a).should == {:a => 1}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should find values for multiple keys" do
|
42
|
+
{:a => 1, :b => 2, :c => 3}.only(:b, :c).should == {:b => 2, :c => 3}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe OpenObject do
|
48
|
+
before do
|
49
|
+
@obj = OpenObject.new({:a => 1, :b => 2, :c => 3})
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be kind of Hash" do
|
53
|
+
Hash.should === @obj
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should accept block that supplies default value" do
|
57
|
+
obj = OpenObject.new { |hash, key| hash[key] = "New #{key}" }
|
58
|
+
obj[:foo].should == "New foo"
|
59
|
+
obj.keys.should == [:foo]
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should combine initial values from hash argument and from block" do
|
63
|
+
obj = OpenObject.new(:a => 6, :b => 2) { |h, k| h[k] = k.to_s * 2 }
|
64
|
+
obj[:a].should == 6
|
65
|
+
obj[:c].should == 'cc'
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should allow reading a value by calling its name method" do
|
69
|
+
@obj.b.should == 2
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should allow setting a value by calling its name= method" do
|
73
|
+
lambda { @obj.f = 32 }.should change { @obj.f }.to(32)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should allow changing a value by calling its name= method" do
|
77
|
+
lambda { @obj.c = 17 }.should change { @obj.c }.to(17)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should implement only method like a hash" do
|
81
|
+
@obj.only(:a).should == { :a => 1 }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe File do
|
86
|
+
# Quite a few of the other specs depend on File#utime working correctly.
|
87
|
+
# These specs validate that utime is working as expected.
|
88
|
+
describe "#utime" do
|
89
|
+
it "should update mtime of directories" do
|
90
|
+
mkpath 'tmp'
|
91
|
+
begin
|
92
|
+
creation_time = File.mtime('tmp')
|
93
|
+
|
94
|
+
sleep 1
|
95
|
+
File.utime(nil, nil, 'tmp')
|
96
|
+
|
97
|
+
File.mtime('tmp').should > creation_time
|
98
|
+
ensure
|
99
|
+
Dir.rmdir 'tmp'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should update mtime of files" do
|
104
|
+
FileUtils.touch('tmp')
|
105
|
+
begin
|
106
|
+
creation_time = File.mtime('tmp')
|
107
|
+
|
108
|
+
sleep 1
|
109
|
+
File.utime(nil, nil, 'tmp')
|
110
|
+
|
111
|
+
File.mtime('tmp').should > creation_time
|
112
|
+
ensure
|
113
|
+
File.delete 'tmp'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should be able to set mtime in the past" do
|
118
|
+
FileUtils.touch('tmp')
|
119
|
+
begin
|
120
|
+
time = Time.at((Time.now - 10).to_i)
|
121
|
+
File.utime(time, time, 'tmp')
|
122
|
+
|
123
|
+
File.mtime('tmp').should == time
|
124
|
+
ensure
|
125
|
+
File.delete 'tmp'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should be able to set mtime in the future" do
|
130
|
+
FileUtils.touch('tmp')
|
131
|
+
begin
|
132
|
+
time = Time.at((Time.now + 10).to_i)
|
133
|
+
File.utime(time, time, 'tmp')
|
134
|
+
|
135
|
+
File.mtime('tmp').should == time
|
136
|
+
ensure
|
137
|
+
File.delete 'tmp'
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
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.expand_path(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,251 @@
|
|
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 '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 compile test groovy sources that rely on junit' do
|
102
|
+
write 'src/main/groovy/some/Example.groovy', 'package some; class Example { static main(args) { println "Hello" } }'
|
103
|
+
write 'src/test/groovy/some/ExampleTest.groovy', "package some\n import junit.framework.TestCase\n class ExampleTest extends TestCase { public testHello() { println \"Hello\" } }"
|
104
|
+
foo = define('foo') do
|
105
|
+
test.using :junit
|
106
|
+
end
|
107
|
+
foo.test.compile.invoke
|
108
|
+
file('target/classes/some/Example.class').should exist
|
109
|
+
file('target/test/classes/some/ExampleTest.class').should exist
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should include as classpath dependency' do
|
113
|
+
write 'src/bar/groovy/some/Foo.groovy', 'package some; interface Foo {}'
|
114
|
+
write 'src/main/groovy/some/Example.groovy', 'package some; class Example implements Foo { }'
|
115
|
+
define('bar', :version => '1.0') do
|
116
|
+
compile.from('src/bar/groovy').into('target/bar')
|
117
|
+
package(:jar)
|
118
|
+
end
|
119
|
+
lambda { define('foo').compile.with(project('bar').package(:jar)).invoke }.should run_task('foo:compile')
|
120
|
+
file('target/classes/some/Example.class').should exist
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should cross compile java sources' do
|
124
|
+
write 'src/main/java/some/Foo.java', 'package some; public interface Foo { public void hello(); }'
|
125
|
+
write 'src/main/java/some/Baz.java', 'package some; public class Baz extends Bar { }'
|
126
|
+
write 'src/main/groovy/some/Bar.groovy', 'package some; class Bar implements Foo { def void hello() { } }'
|
127
|
+
define('foo').compile.invoke
|
128
|
+
%w{Foo Bar Baz}.each { |f| file("target/classes/some/#{f}.class").should exist }
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should cross compile test java sources' do
|
132
|
+
write 'src/test/java/some/Foo.java', 'package some; public interface Foo { public void hello(); }'
|
133
|
+
write 'src/test/java/some/Baz.java', 'package some; public class Baz extends Bar { }'
|
134
|
+
write 'src/test/groovy/some/Bar.groovy', 'package some; class Bar implements Foo { def void hello() { } }'
|
135
|
+
define('foo').test.compile.invoke
|
136
|
+
%w{Foo Bar Baz}.each { |f| file("target/test/classes/some/#{f}.class").should exist }
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should package classes into a jar file' do
|
140
|
+
write 'src/main/groovy/some/Example.groovy', 'package some; class Example { }'
|
141
|
+
define('foo', :version => '1.0').package.invoke
|
142
|
+
file('target/foo-1.0.jar').should exist
|
143
|
+
Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
|
144
|
+
jar.file.exist?('some/Example.class').should be_true
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
describe 'groovyc compiler options' do
|
151
|
+
|
152
|
+
def groovyc(&prc)
|
153
|
+
define('foo') do
|
154
|
+
compile.using(:groovyc)
|
155
|
+
@compiler = compile.instance_eval { @compiler }
|
156
|
+
class << @compiler
|
157
|
+
public :groovyc_options, :javac_options
|
158
|
+
end
|
159
|
+
if block_given?
|
160
|
+
instance_eval(&prc)
|
161
|
+
else
|
162
|
+
return compile
|
163
|
+
end
|
164
|
+
end
|
165
|
+
project('foo').compile
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should set warning option to false by default' do
|
169
|
+
groovyc do
|
170
|
+
compile.options.warnings.should be_false
|
171
|
+
@compiler.javac_options[:nowarn].should be_true
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should set warning option to true when running with --verbose option' do
|
176
|
+
verbose true
|
177
|
+
groovyc do
|
178
|
+
compile.options.warnings.should be_true
|
179
|
+
@compiler.javac_options[:nowarn].should be_false
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should not set verbose option by default' do
|
184
|
+
groovyc.options.verbose.should be_false
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should set verbose option when running with --trace=groovyc option' do
|
188
|
+
Buildr.application.options.trace_categories = [:groovyc]
|
189
|
+
groovyc.options.verbose.should be_true
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'should set debug option to false based on Buildr.options' do
|
193
|
+
Buildr.options.debug = false
|
194
|
+
groovyc.options.debug.should be_false
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should set debug option to false based on debug environment variable' do
|
198
|
+
ENV['debug'] = 'no'
|
199
|
+
groovyc.options.debug.should be_false
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should set debug option to false based on DEBUG environment variable' do
|
203
|
+
ENV['DEBUG'] = 'no'
|
204
|
+
groovyc.options.debug.should be_false
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'should set deprecation option to false by default' do
|
208
|
+
groovyc.options.deprecation.should be_false
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'should use deprecation argument when deprecation is true' do
|
212
|
+
groovyc do
|
213
|
+
compile.using(:deprecation=>true)
|
214
|
+
compile.options.deprecation.should be_true
|
215
|
+
@compiler.javac_options[:deprecation].should be_true
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should not use deprecation argument when deprecation is false' do
|
220
|
+
groovyc do
|
221
|
+
compile.using(:deprecation=>false)
|
222
|
+
compile.options.deprecation.should be_false
|
223
|
+
@compiler.javac_options[:deprecation].should_not be_true
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'should set optimise option to false by default' do
|
228
|
+
groovyc.options.optimise.should be_false
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should use optimize argument when deprecation is true' do
|
232
|
+
groovyc do
|
233
|
+
compile.using(:optimise=>true)
|
234
|
+
@compiler.javac_options[:optimize].should be_true
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'should not use optimize argument when deprecation is false' do
|
239
|
+
groovyc do
|
240
|
+
compile.using(:optimise=>false)
|
241
|
+
@compiler.javac_options[:optimize].should be_false
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
after do
|
246
|
+
Buildr.options.debug = nil
|
247
|
+
ENV.delete "debug"
|
248
|
+
ENV.delete "DEBUG"
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|