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,109 @@
|
|
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 RepositoryArray do
|
20
|
+
it 'should create a new instance' do
|
21
|
+
repo_array = RepositoryArray.new
|
22
|
+
repo_array.should_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should create a new instance from an array' do
|
26
|
+
repo_array = RepositoryArray.new( ['url1', {:url => 'url2'}] )
|
27
|
+
repo_array[0].should eql( { :url => URI.parse('url1') } )
|
28
|
+
repo_array[1].should eql( { :url => URI.parse('url2') } )
|
29
|
+
end
|
30
|
+
|
31
|
+
context "instance" do
|
32
|
+
before(:each) do
|
33
|
+
@array = RepositoryArray.new
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should << and convert to standardize Hash' do
|
37
|
+
@array << 'url1' << { 'url' => 'url2' }
|
38
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
39
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should + and convert to standardize Hash' do
|
43
|
+
@array + ['url1', { :url => 'url2'}]
|
44
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
45
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
46
|
+
|
47
|
+
@array + ['url3', { :url => 'url4'}]
|
48
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
49
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
50
|
+
@array[2].should eql( {:url => URI.parse('url3')} )
|
51
|
+
@array[3].should eql( {:url => URI.parse('url4')} )
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should concat and convert to standardize Hash' do
|
55
|
+
@array + ['url1', { :url => 'url2'}]
|
56
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
57
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
58
|
+
|
59
|
+
@array + ['url3', { :url => 'url4'}]
|
60
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
61
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
62
|
+
@array[2].should eql( {:url => URI.parse('url3')} )
|
63
|
+
@array[3].should eql( {:url => URI.parse('url4')} )
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should convert a String into a standardize Hash' do
|
67
|
+
@array.convert_remote_url( 'url' ).should eql( {:url => URI.parse('url') } )
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should convert a Hash into a standardize Hash' do
|
71
|
+
@array.convert_remote_url({ :username => 'username', :blah => 7, 'password' => 'password', 'foo' => 'bot', 'url' => 'url' }).should eql( {:url => URI.parse('url'), :username => 'username', :password => 'password' } )
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should convert a URI into a standardize Hash' do
|
75
|
+
@array.convert_remote_url( URI.parse('test')).should eql( {:url => URI.parse('test') } )
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'Unsupported :url, must be String, Hash, or URI: 7' do
|
79
|
+
lambda { @array.convert_remote_url( 7 ) }.should raise_error(ArgumentError, /Unsupported :url, must be String, Hash, or URI: 7/)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should insert as standardized Hash" do
|
83
|
+
@array << 'url1' << 'url3'
|
84
|
+
@array.insert( 1, 'url2', 'url2.5' )
|
85
|
+
|
86
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
87
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
88
|
+
@array[2].should eql( {:url => URI.parse('url2.5')} )
|
89
|
+
@array[3].should eql( {:url => URI.parse('url3')} )
|
90
|
+
|
91
|
+
@array.insert( -3, 'url2.2', 'url2.3' )
|
92
|
+
|
93
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
94
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
95
|
+
@array[2].should eql( {:url => URI.parse('url2.2')} )
|
96
|
+
@array[3].should eql( {:url => URI.parse('url2.3')} )
|
97
|
+
@array[4].should eql( {:url => URI.parse('url2.5')} )
|
98
|
+
@array[5].should eql( {:url => URI.parse('url3')} )
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should replace as standardized Hash" do
|
102
|
+
@array << 'test'
|
103
|
+
@array.replace( ['url1', 'url2'] )
|
104
|
+
|
105
|
+
@array[0].should eql( {:url => URI.parse('url1')} )
|
106
|
+
@array[1].should eql( {:url => URI.parse('url2')} )
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/spec/sandbox.rb
ADDED
@@ -0,0 +1,165 @@
|
|
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
|
+
# The local repository we use for testing is void of any artifacts, which will break given
|
18
|
+
# that the code requires several artifacts. So we establish them first using the real local
|
19
|
+
# repository and cache these across test cases.
|
20
|
+
Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
|
21
|
+
repositories.remote << 'http://repo1.maven.org/maven2'
|
22
|
+
repositories.remote << 'http://scala-tools.org/repo-releases'
|
23
|
+
|
24
|
+
# Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
|
25
|
+
Buildr.settings.build['scala.version'] = "2.8.1"
|
26
|
+
|
27
|
+
# Add a 'require' here only for optional extensions, not for extensions that should be loaded by default.
|
28
|
+
require 'buildr/clojure'
|
29
|
+
require 'buildr/groovy'
|
30
|
+
require 'buildr/scala'
|
31
|
+
require 'buildr/bnd'
|
32
|
+
require 'buildr/jaxb_xjc'
|
33
|
+
|
34
|
+
Java.load # Anything added to the classpath.
|
35
|
+
artifacts(
|
36
|
+
TestFramework.frameworks.map(&:dependencies).flatten,
|
37
|
+
JUnit.ant_taskdef,
|
38
|
+
Buildr::Groovy.dependencies,
|
39
|
+
Buildr::JaxbXjc.dependencies,
|
40
|
+
Buildr::Bnd.dependencies,
|
41
|
+
Buildr::Scala::Specs.dependencies,
|
42
|
+
Buildr::Shell::BeanShell.artifact,
|
43
|
+
Buildr::Clojure.dependencies
|
44
|
+
).each do |path|
|
45
|
+
file(path).invoke
|
46
|
+
end
|
47
|
+
|
48
|
+
ENV['HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'home'))
|
49
|
+
mkpath ENV['HOME']
|
50
|
+
|
51
|
+
# We need to run all tests inside a _sandbox, tacking a snapshot of Buildr before the test,
|
52
|
+
# and restoring everything to its previous state after the test. Damn state changes.
|
53
|
+
module Sandbox
|
54
|
+
|
55
|
+
class << self
|
56
|
+
attr_reader :tasks, :rules
|
57
|
+
|
58
|
+
def included(spec)
|
59
|
+
spec.before(:each) { sandbox }
|
60
|
+
spec.after(:each) { reset }
|
61
|
+
end
|
62
|
+
|
63
|
+
# Require an optional extension without letting its callbacks pollute the Project class.
|
64
|
+
def require_optional_extension(extension_require_path)
|
65
|
+
project_callbacks_without_extension = Project.class_eval { @global_callbacks }.dup
|
66
|
+
begin
|
67
|
+
require extension_require_path
|
68
|
+
ensure
|
69
|
+
Project.class_eval { @global_callbacks = project_callbacks_without_extension }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
@tasks = Buildr.application.tasks.collect do |original|
|
75
|
+
prerequisites = original.send(:prerequisites).map(&:to_s)
|
76
|
+
actions = original.instance_eval { @actions }.clone
|
77
|
+
lambda do
|
78
|
+
original.class.send(:define_task, original.name=>prerequisites).tap do |task|
|
79
|
+
task.comment = original.comment
|
80
|
+
actions.each { |action| task.enhance &action }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
@rules = Buildr.application.instance_variable_get(:@rules)
|
85
|
+
|
86
|
+
def sandbox
|
87
|
+
@_sandbox = {}
|
88
|
+
|
89
|
+
# Create a temporary directory where we can create files, e.g,
|
90
|
+
# for projects, compilation. We need a place that does not depend
|
91
|
+
# on the current directory.
|
92
|
+
@_sandbox[:original_dir] = Dir.pwd
|
93
|
+
@temp = File.join(File.dirname(__FILE__), '../tmp')
|
94
|
+
FileUtils.mkpath @temp
|
95
|
+
Dir.chdir @temp
|
96
|
+
|
97
|
+
ARGV.clear
|
98
|
+
Buildr.application = Buildr::Application.new
|
99
|
+
Sandbox.tasks.each { |block| block.call }
|
100
|
+
Buildr.application.instance_variable_set :@rules, Sandbox.rules.clone
|
101
|
+
Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
|
102
|
+
|
103
|
+
@_sandbox[:load_path] = $LOAD_PATH.clone
|
104
|
+
#@_sandbox[:loaded_features] = $LOADED_FEATURES.clone
|
105
|
+
|
106
|
+
# Later on we'll want to lose all the on_define created during the test.
|
107
|
+
@_sandbox[:on_define] = Project.class_eval { (@on_define || []).dup }
|
108
|
+
@_sandbox[:extension_modules] = Project.class_eval { (@extension_modules || []).dup }
|
109
|
+
@_sandbox[:global_callbacks] = Project.class_eval { (@global_callbacks || []).dup }
|
110
|
+
@_sandbox[:layout] = Layout.default.clone
|
111
|
+
|
112
|
+
# Create a local repository we can play with. However, our local repository will be void
|
113
|
+
# of some essential artifacts (e.g. JUnit artifacts required by build task), so we create
|
114
|
+
# these first (see above) and keep them across test cases.
|
115
|
+
@_sandbox[:artifacts] = Artifact.class_eval { @artifacts }.clone
|
116
|
+
Buildr.repositories.local = File.expand_path('repository')
|
117
|
+
ENV['HOME'] = File.expand_path('home')
|
118
|
+
ENV['BUILDR_ENV'] = 'development'
|
119
|
+
|
120
|
+
@_sandbox[:env_keys] = ENV.keys
|
121
|
+
['DEBUG', 'TEST', 'HTTP_PROXY', 'HTTPS_PROXY', 'USER'].each { |k| ENV.delete(k) ; ENV.delete(k.downcase) }
|
122
|
+
|
123
|
+
# Remove testing local repository, and reset all repository settings.
|
124
|
+
Buildr.repositories.instance_eval do
|
125
|
+
@local = @remote = @release_to = nil
|
126
|
+
end
|
127
|
+
Buildr.options.proxy.http = nil
|
128
|
+
|
129
|
+
# Don't output crap to the console.
|
130
|
+
trace false
|
131
|
+
verbose false
|
132
|
+
end
|
133
|
+
|
134
|
+
# Call this from teardown.
|
135
|
+
def reset
|
136
|
+
# Get rid of all the projects and the on_define blocks we used.
|
137
|
+
Project.clear
|
138
|
+
|
139
|
+
on_define = @_sandbox[:on_define]
|
140
|
+
extension_modules = @_sandbox[:extension_modules]
|
141
|
+
global_callbacks = @_sandbox[:global_callbacks]
|
142
|
+
|
143
|
+
Project.class_eval do
|
144
|
+
@on_define = on_define
|
145
|
+
@global_callbacks = global_callbacks
|
146
|
+
@extension_modules = extension_modules
|
147
|
+
end
|
148
|
+
|
149
|
+
Layout.default = @_sandbox[:layout].clone
|
150
|
+
|
151
|
+
$LOAD_PATH.replace @_sandbox[:load_path]
|
152
|
+
FileUtils.rm_rf @temp
|
153
|
+
mkpath ENV['HOME']
|
154
|
+
|
155
|
+
# Get rid of all artifacts.
|
156
|
+
@_sandbox[:artifacts].tap { |artifacts| Artifact.class_eval { @artifacts = artifacts } }
|
157
|
+
|
158
|
+
# Restore options.
|
159
|
+
Buildr.options.test = nil
|
160
|
+
(ENV.keys - @_sandbox[:env_keys]).each { |key| ENV.delete key }
|
161
|
+
|
162
|
+
Dir.chdir @_sandbox[:original_dir]
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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::Scala::Specs do
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
# Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
|
23
|
+
Buildr.settings.build['scala.version'] = "2.8.1"
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should be the default when tests in src/spec/scala' do
|
27
|
+
write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
|
28
|
+
package com.example
|
29
|
+
object MySpecs extends org.specs.Specification {
|
30
|
+
"it" should {
|
31
|
+
"add" in {
|
32
|
+
val sum = 1 + 1
|
33
|
+
sum mustEqual 2
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
SCALA
|
38
|
+
define 'foo'
|
39
|
+
project('foo').test.framework.should eql(:specs)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should include Specs dependencies' do
|
43
|
+
define('foo') { test.using(:specs) }
|
44
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::Specs.dependencies))
|
45
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::Specs.dependencies))
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should include ScalaCheck dependencies' do
|
49
|
+
define('foo') { test.using(:specs) }
|
50
|
+
project('foo').test.compile.dependencies.should include(*artifacts(Scala::Check.dependencies))
|
51
|
+
project('foo').test.dependencies.should include(*artifacts(Scala::Check.dependencies))
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should include JMock dependencies' do
|
55
|
+
define('foo') { test.using(:scalatest) }
|
56
|
+
project('foo').test.compile.dependencies.should include(*artifacts(JMock.dependencies))
|
57
|
+
project('foo').test.dependencies.should include(*artifacts(JMock.dependencies))
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should include public objects extending org.specs.Specification' do
|
61
|
+
write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
|
62
|
+
package com.example
|
63
|
+
object MySpecs extends org.specs.Specification {
|
64
|
+
"it" should {
|
65
|
+
"add" in {
|
66
|
+
val sum = 1 + 1
|
67
|
+
sum mustEqual 2
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
SCALA
|
72
|
+
define('foo').test.invoke
|
73
|
+
project('foo').test.tests.should include('com.example.MySpecs')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should include public objects extending org.specs.Specification even with companion classes' do
|
77
|
+
write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
|
78
|
+
package com.example
|
79
|
+
object MySpecs extends org.specs.Specification {
|
80
|
+
"it" should {
|
81
|
+
"add" in {
|
82
|
+
val sum = 1 + 1
|
83
|
+
sum mustEqual 2
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
class MySpecs extends org.specs.runner.JUnit4(MySpecs)
|
88
|
+
SCALA
|
89
|
+
define('foo').test.invoke
|
90
|
+
project('foo').test.tests.should include('com.example.MySpecs')
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should pass when spec passes' do
|
94
|
+
write 'src/spec/scala/PassingSpecs.scala', <<-SCALA
|
95
|
+
object PassingSpecs extends org.specs.Specification {
|
96
|
+
"it" should {
|
97
|
+
"add" in {
|
98
|
+
val sum = 1 + 1
|
99
|
+
sum mustEqual 2
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
SCALA
|
104
|
+
lambda { define('foo').test.invoke }.should_not raise_error
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should fail when spec fails' do
|
108
|
+
write 'src/spec/scala/StringSpecs.scala', <<-SCALA
|
109
|
+
import org.specs._
|
110
|
+
import org.specs.runner._
|
111
|
+
|
112
|
+
object StringSpecs extends Specification {
|
113
|
+
"empty string" should {
|
114
|
+
"have a zero length" in {
|
115
|
+
("".length) mustEqual(1)
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
SCALA
|
120
|
+
define('foo')
|
121
|
+
project('foo').test.invoke rescue
|
122
|
+
project('foo').test.failed_tests.should include('StringSpecs')
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,289 @@
|
|
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
|
+
# need to test both with and without SCALA_HOME
|
20
|
+
share_as :ScalacCompiler do
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
# Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
|
24
|
+
Buildr.settings.build['scala.version'] = "2.8.1"
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should identify itself from source directories' do
|
28
|
+
write 'src/main/scala/com/example/Test.scala', 'package com.example; class Test { val i = 1 }'
|
29
|
+
define('foo').compile.compiler.should eql(:scalac)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should report the language as :scala' do
|
33
|
+
define('foo').compile.using(:scalac).language.should eql(:scala)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should set the target directory to target/classes' do
|
37
|
+
define 'foo' do
|
38
|
+
lambda { compile.using(:scalac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should not override existing target directory' do
|
43
|
+
define 'foo' do
|
44
|
+
compile.into('classes')
|
45
|
+
lambda { compile.using(:scalac) }.should_not change { compile.target }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should not change existing list of sources' do
|
50
|
+
define 'foo' do
|
51
|
+
compile.from('sources')
|
52
|
+
lambda { compile.using(:scalac) }.should_not change { compile.sources }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should include as classpath dependency' do
|
57
|
+
write 'src/dependency/Dependency.scala', 'class Dependency {}'
|
58
|
+
define 'dependency', :version=>'1.0' do
|
59
|
+
compile.from('src/dependency').into('target/dependency')
|
60
|
+
package(:jar)
|
61
|
+
end
|
62
|
+
write 'src/test/DependencyTest.scala', 'class DependencyTest { var d: Dependency = _ }'
|
63
|
+
lambda { define('foo').compile.from('src/test').with(project('dependency')).invoke }.should run_task('foo:compile')
|
64
|
+
file('target/classes/DependencyTest.class').should exist
|
65
|
+
end
|
66
|
+
|
67
|
+
def define_test1_project
|
68
|
+
write 'src/main/scala/com/example/Test1.scala', 'package com.example; class Test1 { val i = 1 }'
|
69
|
+
define 'test1', :version=>'1.0' do
|
70
|
+
package(:jar)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should compile a simple .scala file into a .class file' do
|
75
|
+
define_test1_project
|
76
|
+
task('test1:compile').invoke
|
77
|
+
file('target/classes/com/example/Test1.class').should exist
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should package .class into a .jar file' do
|
81
|
+
define_test1_project
|
82
|
+
task('test1:package').invoke
|
83
|
+
file('target/test1-1.0.jar').should exist
|
84
|
+
Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
|
85
|
+
zip.file.exist?('com/example/Test1.class').should be_true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should compile scala class depending on java class in same project' do
|
90
|
+
write 'src/main/java/com/example/Foo.java', 'package com.example; public class Foo {}'
|
91
|
+
write 'src/main/scala/com/example/Bar.scala', 'package com.example; class Bar extends Foo'
|
92
|
+
define 'test1', :version=>'1.0' do
|
93
|
+
package(:jar)
|
94
|
+
end
|
95
|
+
task('test1:package').invoke
|
96
|
+
file('target/test1-1.0.jar').should exist
|
97
|
+
Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
|
98
|
+
zip.file.exist?('com/example/Foo.class').should be_true
|
99
|
+
zip.file.exist?('com/example/Bar.class').should be_true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should compile java class depending on scala class in same project' do
|
104
|
+
write 'src/main/scala/com/example/Foo.scala', 'package com.example; class Foo'
|
105
|
+
write 'src/main/java/com/example/Bar.java', 'package com.example; public class Bar extends Foo {}'
|
106
|
+
define 'test1', :version=>'1.0' do
|
107
|
+
package(:jar)
|
108
|
+
end
|
109
|
+
task('test1:package').invoke
|
110
|
+
file('target/test1-1.0.jar').should exist
|
111
|
+
Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
|
112
|
+
zip.file.exist?('com/example/Foo.class').should be_true
|
113
|
+
zip.file.exist?('com/example/Bar.class').should be_true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
describe 'scala compiler (installed in SCALA_HOME)' do
|
120
|
+
it 'requires present SCALA_HOME' do
|
121
|
+
ENV['SCALA_HOME'].should_not be_nil
|
122
|
+
end
|
123
|
+
|
124
|
+
it_should_behave_like ScalacCompiler
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
describe 'scala compiler (downloaded from repository)' do
|
129
|
+
old_home = ENV['SCALA_HOME']
|
130
|
+
|
131
|
+
before :all do
|
132
|
+
ENV['SCALA_HOME'] = nil
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'requires absent SCALA_HOME' do
|
136
|
+
ENV['SCALA_HOME'].should be_nil
|
137
|
+
end
|
138
|
+
|
139
|
+
it_should_behave_like ScalacCompiler
|
140
|
+
|
141
|
+
after :all do
|
142
|
+
ENV['SCALA_HOME'] = old_home
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
describe 'scalac compiler options' do
|
148
|
+
def compile_task
|
149
|
+
@compile_task ||= define('foo').compile.using(:scalac)
|
150
|
+
end
|
151
|
+
|
152
|
+
def scalac_args
|
153
|
+
compile_task.instance_eval { @compiler }.send(:scalac_args)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should set warnings option to false by default' do
|
157
|
+
compile_task.options.warnings.should be_false
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should set warnings option to true when running with --verbose option' do
|
161
|
+
verbose true
|
162
|
+
compile_task.options.warnings.should be_true
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should use -nowarn argument when warnings is false' do
|
166
|
+
compile_task.using(:warnings=>false)
|
167
|
+
scalac_args.should include('-nowarn')
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should not use -nowarn argument when warnings is true' do
|
171
|
+
compile_task.using(:warnings=>true)
|
172
|
+
scalac_args.should_not include('-nowarn')
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should not use -verbose argument by default' do
|
176
|
+
scalac_args.should_not include('-verbose')
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should use -verbose argument when running with --trace=scalac option' do
|
180
|
+
Buildr.application.options.trace_categories = [:scalac]
|
181
|
+
scalac_args.should include('-verbose')
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should set debug option to true by default' do
|
185
|
+
compile_task.options.debug.should be_true
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should set debug option to false based on Buildr.options' do
|
189
|
+
Buildr.options.debug = false
|
190
|
+
compile_task.options.debug.should be_false
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should set debug option to false based on debug environment variable' do
|
194
|
+
ENV['debug'] = 'no'
|
195
|
+
compile_task.options.debug.should be_false
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should set debug option to false based on DEBUG environment variable' do
|
199
|
+
ENV['DEBUG'] = 'no'
|
200
|
+
compile_task.options.debug.should be_false
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should use -g argument when debug option is true' do
|
204
|
+
compile_task.using(:debug=>true)
|
205
|
+
scalac_args.should include('-g')
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should not use -g argument when debug option is false' do
|
209
|
+
compile_task.using(:debug=>false)
|
210
|
+
scalac_args.should_not include('-g')
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should set deprecation option to false by default' do
|
214
|
+
compile_task.options.deprecation.should be_false
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should use -deprecation argument when deprecation is true' do
|
218
|
+
compile_task.using(:deprecation=>true)
|
219
|
+
scalac_args.should include('-deprecation')
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'should not use -deprecation argument when deprecation is false' do
|
223
|
+
compile_task.using(:deprecation=>false)
|
224
|
+
scalac_args.should_not include('-deprecation')
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'should set optimise option to false by default' do
|
228
|
+
compile_task.options.optimise.should be_false
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should use -optimise argument when deprecation is true' do
|
232
|
+
compile_task.using(:optimise=>true)
|
233
|
+
scalac_args.should include('-optimise')
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'should not use -optimise argument when deprecation is false' do
|
237
|
+
compile_task.using(:optimise=>false)
|
238
|
+
scalac_args.should_not include('-optimise')
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'should not set target option by default' do
|
242
|
+
compile_task.options.target.should be_nil
|
243
|
+
scalac_args.should_not include('-target')
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'should use -target:xxx argument if target option set' do
|
247
|
+
compile_task.using(:target=>'1.5')
|
248
|
+
scalac_args.should include('-target:jvm-1.5')
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should not set other option by default' do
|
252
|
+
compile_task.options.other.should be_nil
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'should pass other argument if other option is string' do
|
256
|
+
compile_task.using(:other=>'-unchecked')
|
257
|
+
scalac_args.should include('-unchecked')
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'should pass other argument if other option is array' do
|
261
|
+
compile_task.using(:other=>['-unchecked', '-Xprint-types'])
|
262
|
+
scalac_args.should include('-unchecked', '-Xprint-types')
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'should complain about options it doesn\'t know' do
|
266
|
+
write 'source/Test.scala', 'class Test {}'
|
267
|
+
compile_task.using(:unknown=>'option')
|
268
|
+
lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'should inherit options from parent' do
|
272
|
+
define 'foo' do
|
273
|
+
compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :target=>'1.4')
|
274
|
+
define 'bar' do
|
275
|
+
compile.using(:scalac)
|
276
|
+
compile.options.warnings.should be_true
|
277
|
+
compile.options.debug.should be_true
|
278
|
+
compile.options.deprecation.should be_true
|
279
|
+
compile.options.target.should eql('1.4')
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
after do
|
285
|
+
Buildr.options.debug = nil
|
286
|
+
ENV.delete "debug"
|
287
|
+
ENV.delete "DEBUG"
|
288
|
+
end
|
289
|
+
end
|