buildr 1.2.10 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +566 -268
- data/DISCLAIMER +7 -1
- data/KEYS +151 -0
- data/NOTICE +23 -8
- data/README +122 -22
- data/Rakefile +49 -229
- data/{lib → addon}/buildr/antlr.rb +23 -10
- data/addon/buildr/cobertura.rb +232 -0
- data/{lib → addon}/buildr/hibernate.rb +20 -4
- data/{lib → addon}/buildr/javacc.rb +27 -12
- data/addon/buildr/jdepend.rb +60 -0
- data/{lib → addon}/buildr/jetty.rb +34 -18
- data/addon/buildr/nailgun.rb +892 -0
- data/{lib → addon}/buildr/openjpa.rb +23 -6
- 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/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
- data/{lib → addon}/buildr/xmlbeans.rb +39 -14
- data/bin/buildr +21 -7
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +28 -45
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/{core → buildr/core}/build.rb +91 -77
- data/lib/{core → buildr/core}/checks.rb +116 -95
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/{core → buildr/core}/generate.rb +22 -5
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/{core → buildr/core}/project.rb +468 -213
- data/lib/buildr/core/test.rb +690 -0
- data/lib/{core → buildr/core}/transports.rb +107 -127
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/{java → buildr/ide}/eclipse.rb +86 -60
- data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/{java → buildr/java}/pom.rb +20 -4
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/{java → buildr/packaging}/artifact.rb +170 -179
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
- data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +188 -77
- data/lib/buildr/cobertura.rb +0 -89
- data/lib/buildr/jdepend.rb +0 -40
- data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/scala.rb +0 -368
- data/lib/core/application.rb +0 -188
- data/lib/core/common.rb +0 -562
- data/lib/core/help.rb +0 -72
- data/lib/core/rake_ext.rb +0 -81
- data/lib/java/ant.rb +0 -71
- data/lib/java/compile.rb +0 -589
- data/lib/java/idea.rb +0 -159
- data/lib/java/java.rb +0 -432
- data/lib/java/packaging.rb +0 -581
- data/lib/java/test.rb +0 -795
- data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,45 @@
|
|
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
|
+
begin
|
18
|
+
require 'rubyforge'
|
19
|
+
rescue LoadError
|
20
|
+
puts 'Please run rake setup to install the RubyForge gem'
|
21
|
+
task 'setup' do
|
22
|
+
install_gem 'rubyforge'
|
23
|
+
end
|
24
|
+
task 'release:check' do
|
25
|
+
fail 'Please run rake setup to install the RubyForge gem'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
namespace 'rubyforge' do
|
31
|
+
|
32
|
+
task 'release'=>'published' do |task|
|
33
|
+
changes = FileList['published/CHANGES'].first
|
34
|
+
files = FileList['published/*.{gem,tgz,zip}'].exclude(changes).existing
|
35
|
+
print "Uploading #{spec.version} to RubyForge ... "
|
36
|
+
rubyforge = RubyForge.new
|
37
|
+
rubyforge.login
|
38
|
+
rubyforge.userconfig.merge!('release_changes'=>changes, 'preformatted' => true) if changes
|
39
|
+
rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files
|
40
|
+
puts 'Done'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
task 'release:publish'=>'rubyforge:release'
|
data/rakelib/scm.rake
ADDED
@@ -0,0 +1,49 @@
|
|
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
|
+
# Handling of source control.
|
18
|
+
namespace 'scm' do
|
19
|
+
|
20
|
+
task 'check' do
|
21
|
+
print 'Checking there are no local changes ... '
|
22
|
+
svn = `svn status`
|
23
|
+
fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
|
24
|
+
git = `git status`
|
25
|
+
fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^#\t/]
|
26
|
+
puts 'OK'
|
27
|
+
end
|
28
|
+
|
29
|
+
task 'tag' do
|
30
|
+
info = `svn info` + `git svn info` # Using either svn or git-svn
|
31
|
+
url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
|
32
|
+
break unless url
|
33
|
+
new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
|
34
|
+
break if url == new_url
|
35
|
+
print "Tagging release as tags/#{spec.version} ... "
|
36
|
+
sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}", :verbose=>false do |ok, res|
|
37
|
+
if ok
|
38
|
+
puts 'Done'
|
39
|
+
else
|
40
|
+
puts 'Could not create tag, please do it yourself!'
|
41
|
+
puts %{ svn copy #{url} #{new_url} -m "#{spec.version}"}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
task 'stage:check'=>'scm:check'
|
49
|
+
task 'release:wrapup'=>'scm:tag'
|
data/rakelib/setup.rake
ADDED
@@ -0,0 +1,59 @@
|
|
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
|
+
# True if running on the Windows operating sytem. Different from Gem.win_platform?
|
16
|
+
# which returns true if running on the Windows platform of MRI, false when using JRuby.
|
17
|
+
|
18
|
+
|
19
|
+
require 'rubygems/source_info_cache'
|
20
|
+
|
21
|
+
|
22
|
+
def windows?
|
23
|
+
Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# Finds and returns path to executable. Consults PATH environment variable.
|
28
|
+
# Returns nil if executable not found.
|
29
|
+
def which(name)
|
30
|
+
if windows?
|
31
|
+
path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| path.gsub('\\', '/') }.map { |path| "#{path}/#{name}.{exe,bat,com}" }
|
32
|
+
else
|
33
|
+
path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| "#{path}/#{name}" }
|
34
|
+
end
|
35
|
+
FileList[path].existing.first
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def install_gem(name, ver_requirement = nil)
|
40
|
+
dep = Gem::Dependency.new(name, ver_requirement)
|
41
|
+
if Gem::SourceIndex.from_installed_gems.search(dep).empty?
|
42
|
+
spec = Gem::SourceInfoCache.search(dep).last
|
43
|
+
fail "#{dep} not found in local or remote repository!" unless spec
|
44
|
+
puts "Installing #{spec} ..."
|
45
|
+
args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', spec.name, '-v', spec.version.to_s]
|
46
|
+
args.unshift('sudo', 'env', 'JAVA_HOME=' + ENV['JAVA_HOME']) unless windows?
|
47
|
+
sh *args
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Setup environment for running this Rakefile (RSpec, Docter, etc).
|
52
|
+
desc "If you're building from sources, run this task one to setup the necessary dependencies."
|
53
|
+
missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
|
54
|
+
task 'setup' do
|
55
|
+
missing.each do |dep|
|
56
|
+
install_gem dep.name, dep.version_requirements
|
57
|
+
end
|
58
|
+
end
|
59
|
+
puts "Missing Gems #{missing.join(', ')}, please run rake setup first!" unless missing.empty?
|
data/rakelib/stage.rake
ADDED
@@ -0,0 +1,45 @@
|
|
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
|
+
# Staged files are copied to this directory first, and from there uploaded to the staging server.
|
18
|
+
directory 'staged'
|
19
|
+
|
20
|
+
task 'clobber' do
|
21
|
+
rm_rf 'staged'
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace 'stage' do
|
25
|
+
# stage:check verifies that we're able to stage a release: check for a changelog,
|
26
|
+
# local changes, run all the test cases, etc. You can add more actions, e.g.
|
27
|
+
# checking license files, spell checking documentation.
|
28
|
+
task 'check'=>['setup', 'clobber']
|
29
|
+
|
30
|
+
# stage:prepare prepares all the files necessary for making a successful release:
|
31
|
+
# binary and source packages, documentation, Web site, change file, checksums, etc.
|
32
|
+
# This task depends on stage:check, and also performs its own verification of the
|
33
|
+
# produced artifacts. Staged files are placed in the staged directory.
|
34
|
+
task 'prepare'=>'staged'
|
35
|
+
|
36
|
+
# stage:upload moves the stage directory to the staging server.
|
37
|
+
task 'upload' do |task, args|
|
38
|
+
puts "Uploading staged directory to #{args.staging} ..."
|
39
|
+
sh 'rsync', '--progress', '--recursive', 'staged/', args.staging
|
40
|
+
puts 'Done'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Stage files for the release, upload them to staging server'
|
45
|
+
task 'stage'=>['stage:check', 'stage:prepare', 'stage:upload']
|
@@ -0,0 +1,316 @@
|
|
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
|
+
describe Buildr::Application do
|
21
|
+
|
22
|
+
describe 'home_dir' do
|
23
|
+
it 'should point to ~/.buildr' do
|
24
|
+
Buildr.application.home_dir.should eql(File.expand_path('.buildr', ENV['HOME']))
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should point to existing directory' do
|
28
|
+
File.directory?(Buildr.application.home_dir).should be_true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'environment' do
|
33
|
+
it 'should return value of BUILDR_ENV' do
|
34
|
+
ENV['BUILDR_ENV'] = 'qa'
|
35
|
+
Buildr::Application.new.environment.should eql('qa')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should default to development' do
|
39
|
+
Buildr::Application.new.environment.should eql('development')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should set environment name from -e argument' do
|
43
|
+
ARGV.push('-e', 'test')
|
44
|
+
Buildr::Application.new.environment.should eql('test')
|
45
|
+
ENV['BUILDR_ENV'].should eql('test')
|
46
|
+
end
|
47
|
+
|
48
|
+
after do
|
49
|
+
ENV['BUILDR_ENV'] = nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'gems' do
|
54
|
+
|
55
|
+
def load_with_yaml
|
56
|
+
write 'build.yaml', <<-YAML
|
57
|
+
gems:
|
58
|
+
- rspec
|
59
|
+
- rake >= 0.8
|
60
|
+
YAML
|
61
|
+
Buildr.application.load_gems
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should return empty array if no gems specified' do
|
65
|
+
Buildr.application.load_gems
|
66
|
+
Buildr.application.gems.should be_empty
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should return one entry for each gem specified in buildr.yaml' do
|
70
|
+
load_with_yaml
|
71
|
+
Buildr.application.gems.size.should be(2)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should return a Gem::Specification for each installed gem' do
|
75
|
+
load_with_yaml
|
76
|
+
Buildr.application.gems.each { |gem| gem.should be_kind_of(Gem::Specification) }
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should parse Gem name correctly' do
|
80
|
+
load_with_yaml
|
81
|
+
Buildr.application.gems.map(&:name).should include('rake', 'rspec')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should find installed version of Gem' do
|
85
|
+
load_with_yaml
|
86
|
+
Buildr.application.gems.each { |gem| gem.version.should eql(Gem.loaded_specs[gem.name].version) }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
describe 'load_gems' do
|
92
|
+
before do
|
93
|
+
@spec = Gem::Specification.new do |spec|
|
94
|
+
spec.name = 'foo'
|
95
|
+
spec.version = '1.2'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should do nothing if no gems specified' do
|
100
|
+
lambda { Buildr.application.load_gems }.should_not raise_error
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should install nothing if specified gems already installed' do
|
104
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
|
105
|
+
Util.should_not_receive(:ruby)
|
106
|
+
lambda { Buildr.application.load_gems }.should_not raise_error
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should fail if required gem not found in remote repository' do
|
110
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
111
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([])
|
112
|
+
lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot be found/i)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should fail if need to install gem and not running in interactive mode' do
|
116
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
117
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
118
|
+
$stdout.should_receive(:isatty).and_return(false)
|
119
|
+
lambda { Buildr.application.load_gems }.should raise_error(LoadError, /this build requires the gems/i)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should ask permission before installing required gems' do
|
123
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
124
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
125
|
+
$terminal.should_receive(:agree).with(/install/, true)
|
126
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should fail if permission not granted to install gem' do
|
130
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
131
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
132
|
+
$terminal.should_receive(:agree).and_return(false)
|
133
|
+
lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot build without/i)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should install gem if permission granted' do
|
137
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
138
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
139
|
+
$terminal.should_receive(:agree).and_return(true)
|
140
|
+
Util.should_receive(:ruby) do |*args|
|
141
|
+
args.should include('install', 'foo', '-v', '1.2')
|
142
|
+
end
|
143
|
+
Buildr.application.should_receive(:gem).and_return(false)
|
144
|
+
Buildr.application.load_gems
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should reload gem cache after installing required gems' do
|
148
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
149
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
150
|
+
$terminal.should_receive(:agree).and_return(true)
|
151
|
+
Util.should_receive(:ruby)
|
152
|
+
Gem.source_index.should_receive(:load_gems_in).with(Gem::SourceIndex.installed_spec_directories)
|
153
|
+
Buildr.application.should_receive(:gem).and_return(false)
|
154
|
+
Buildr.application.load_gems
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'should load previously installed gems' do
|
158
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
|
159
|
+
Buildr.application.should_receive(:gem).with('rspec', Gem.loaded_specs['rspec'].version.to_s)
|
160
|
+
Buildr.application.load_gems
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should load newly installed gems' do
|
164
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
165
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
166
|
+
$terminal.should_receive(:agree).and_return(true)
|
167
|
+
Util.should_receive(:ruby)
|
168
|
+
Buildr.application.should_receive(:gem).with('foo', @spec.version.to_s)
|
169
|
+
Buildr.application.load_gems
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'should default to >=0 version requirement if not specified' do
|
173
|
+
write 'build.yaml', 'gems: foo'
|
174
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '>=0')).and_return([])
|
175
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should parse exact version requirement' do
|
179
|
+
write 'build.yaml', 'gems: foo 2.5'
|
180
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '=2.5')).and_return([])
|
181
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should parse range version requirement' do
|
185
|
+
write 'build.yaml', 'gems: foo ~>2.3'
|
186
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '~>2.3')).and_return([])
|
187
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should parse multiple version requirements' do
|
191
|
+
write 'build.yaml', 'gems: foo >=2.0 !=2.1'
|
192
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', ['>=2.0', '!=2.1'])).and_return([])
|
193
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
describe Buildr, 'settings' do
|
201
|
+
|
202
|
+
describe 'user' do
|
203
|
+
|
204
|
+
it 'should be empty hash if no settings.yaml file' do
|
205
|
+
Buildr.settings.user.should == {}
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should return loaded settings.yaml file' do
|
209
|
+
write 'home/.buildr/settings.yaml', 'foo: bar'
|
210
|
+
Buildr.settings.user.should == { 'foo'=>'bar' }
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should fail if settings.yaml file is not a hash' do
|
214
|
+
write 'home/.buildr/settings.yaml', 'foo bar'
|
215
|
+
lambda { Buildr.settings.user }.should raise_error(RuntimeError, /expecting.*settings.yaml/i)
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should be empty hash if settings.yaml file is empty' do
|
219
|
+
write 'home/.buildr/settings.yaml'
|
220
|
+
Buildr.settings.user.should == {}
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe 'configuration' do
|
225
|
+
it 'should be empty hash if no build.yaml file' do
|
226
|
+
Buildr.settings.build.should == {}
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should return loaded build.yaml file' do
|
230
|
+
write 'build.yaml', 'foo: bar'
|
231
|
+
Buildr.settings.build.should == { 'foo'=>'bar' }
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'should fail if build.yaml file is not a hash' do
|
235
|
+
write 'build.yaml', 'foo bar'
|
236
|
+
lambda { Buildr.settings.build }.should raise_error(RuntimeError, /expecting.*build.yaml/i)
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'should be empty hash if build.yaml file is empty' do
|
240
|
+
write 'build.yaml'
|
241
|
+
Buildr.settings.build.should == {}
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe 'profiles' do
|
246
|
+
it 'should be empty hash if no profiles.yaml file' do
|
247
|
+
Buildr.settings.profiles.should == {}
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'should return loaded profiles.yaml file' do
|
251
|
+
write 'profiles.yaml', <<-YAML
|
252
|
+
development:
|
253
|
+
foo: bar
|
254
|
+
YAML
|
255
|
+
Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'should fail if profiles.yaml file is not a hash' do
|
259
|
+
write 'profiles.yaml', 'foo bar'
|
260
|
+
lambda { Buildr.settings.profiles }.should raise_error(RuntimeError, /expecting.*profiles.yaml/i)
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'should be empty hash if profiles.yaml file is empty' do
|
264
|
+
write 'profiles.yaml'
|
265
|
+
Buildr.settings.profiles.should == {}
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
describe 'profile' do
|
270
|
+
it 'should be empty hash if no profiles.yaml' do
|
271
|
+
Buildr.settings.profile.should == {}
|
272
|
+
end
|
273
|
+
|
274
|
+
it 'should be empty hash if no matching profile' do
|
275
|
+
write 'profiles.yaml', <<-YAML
|
276
|
+
test:
|
277
|
+
foo: bar
|
278
|
+
YAML
|
279
|
+
Buildr.settings.profile.should == {}
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'should return profile matching environment name' do
|
283
|
+
write 'profiles.yaml', <<-YAML
|
284
|
+
development:
|
285
|
+
foo: bar
|
286
|
+
test:
|
287
|
+
foo: baz
|
288
|
+
YAML
|
289
|
+
Buildr.settings.profile.should == { 'foo'=>'bar' }
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
293
|
+
|
294
|
+
end
|
295
|
+
|
296
|
+
|
297
|
+
describe Buildr do
|
298
|
+
|
299
|
+
describe 'environment' do
|
300
|
+
it 'should be same as Buildr.application.environment' do
|
301
|
+
Buildr.environment.should eql(Buildr.application.environment)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
describe 'application' do
|
306
|
+
it 'should be same as Rake.application' do
|
307
|
+
Buildr.application.should == Rake.application
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe 'settings' do
|
312
|
+
it 'should be same as Buildr.application.settings' do
|
313
|
+
Buildr.settings.should == Buildr.application.settings
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|