assaf-buildr 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +887 -0
- data/DISCLAIMER +7 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +146 -0
- data/Rakefile +62 -0
- data/_buildr +38 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +236 -0
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -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 +817 -0
- data/addon/buildr/openjpa.rb +90 -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/xmlbeans.rb +93 -0
- data/bin/buildr +28 -0
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +58 -0
- data/doc/css/default.css +228 -0
- data/doc/css/print.css +100 -0
- data/doc/css/syntax.css +52 -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/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.tif +0 -0
- data/doc/pages/artifacts.textile +207 -0
- data/doc/pages/building.textile +240 -0
- data/doc/pages/contributing.textile +208 -0
- data/doc/pages/download.textile +62 -0
- data/doc/pages/extending.textile +175 -0
- data/doc/pages/getting_started.textile +273 -0
- data/doc/pages/index.textile +42 -0
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +286 -0
- data/doc/pages/packaging.textile +427 -0
- data/doc/pages/projects.textile +274 -0
- data/doc/pages/recipes.textile +103 -0
- data/doc/pages/settings_profiles.textile +274 -0
- data/doc/pages/testing.textile +212 -0
- data/doc/pages/troubleshooting.textile +103 -0
- data/doc/pages/whats_new.textile +323 -0
- data/doc/print.haml +51 -0
- data/doc/print.toc.yaml +29 -0
- data/doc/scripts/buildr-git.rb +412 -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 +56 -0
- data/doc/site.toc.yaml +47 -0
- data/etc/KEYS +151 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +35 -0
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +489 -0
- data/lib/buildr/core/application_cli.rb +139 -0
- data/lib/buildr/core/build.rb +311 -0
- data/lib/buildr/core/checks.rb +382 -0
- data/lib/buildr/core/common.rb +154 -0
- data/lib/buildr/core/compile.rb +596 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +892 -0
- data/lib/buildr/core/test.rb +715 -0
- data/lib/buildr/core/transports.rb +558 -0
- data/lib/buildr/core/util.rb +289 -0
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +212 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +189 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +92 -0
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +211 -0
- data/lib/buildr/java/compiler.rb +348 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/jruby.rb +117 -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 +119 -0
- data/lib/buildr/java/packaging.rb +713 -0
- data/lib/buildr/java/pom.rb +178 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/buildr/packaging/artifact.rb +730 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -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/buildr/packaging/tar.rb +104 -0
- data/lib/buildr/packaging/zip.rb +722 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +191 -0
- data/rakelib/changelog.rake +57 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +65 -0
- data/rakelib/rspec.rake +83 -0
- data/rakelib/rubyforge.rake +53 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +86 -0
- data/rakelib/stage.rake +48 -0
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +255 -0
- data/spec/core/application_spec.rb +412 -0
- data/spec/core/artifact_namespace_spec.rb +646 -0
- data/spec/core/build_spec.rb +415 -0
- data/spec/core/checks_spec.rb +537 -0
- data/spec/core/common_spec.rb +664 -0
- data/spec/core/compile_spec.rb +566 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +754 -0
- data/spec/core/test_spec.rb +1091 -0
- data/spec/core/transport_spec.rb +500 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +239 -0
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/java/ant.rb +28 -0
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/java_spec.rb +88 -0
- data/spec/java/packaging_spec.rb +1103 -0
- data/spec/java/tests_spec.rb +466 -0
- data/spec/packaging/archive_spec.rb +503 -0
- data/spec/packaging/artifact_spec.rb +754 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +589 -0
- data/spec/sandbox.rb +137 -0
- data/spec/scala/compiler_spec.rb +228 -0
- data/spec/scala/tests_spec.rb +215 -0
- data/spec/spec_helpers.rb +304 -0
- data/spec/version_requirement_spec.rb +123 -0
- metadata +369 -0
data/lib/buildr/core.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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 'buildr/core/common'
|
|
18
|
+
require 'buildr/core/application'
|
|
19
|
+
require 'buildr/core/project'
|
|
20
|
+
require 'buildr/core/environment'
|
|
21
|
+
require 'buildr/core/help'
|
|
22
|
+
require 'buildr/core/build'
|
|
23
|
+
require 'buildr/core/filter'
|
|
24
|
+
require 'buildr/core/compile'
|
|
25
|
+
require 'buildr/core/test'
|
|
26
|
+
require 'buildr/core/checks'
|
|
27
|
+
require 'buildr/core/generate'
|
|
@@ -0,0 +1,489 @@
|
|
|
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
|
+
# Portion of this file derived from Rake.
|
|
17
|
+
# Copyright (c) 2003, 2004 Jim Weirich
|
|
18
|
+
#
|
|
19
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
20
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
21
|
+
# in the Software without restriction, including without limitation the rights
|
|
22
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
24
|
+
# furnished to do so, subject to the following conditions:
|
|
25
|
+
#
|
|
26
|
+
# The above copyright notice and this permission notice shall be included in
|
|
27
|
+
# all copies or substantial portions of the Software.
|
|
28
|
+
#
|
|
29
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
30
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
31
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
32
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
33
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
34
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
|
+
# SOFTWARE.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
require 'highline/import'
|
|
39
|
+
require 'rake'
|
|
40
|
+
require 'rubygems/source_info_cache'
|
|
41
|
+
require 'buildr/core/application_cli'
|
|
42
|
+
require 'buildr/core/util'
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# Gem::user_home is nice, but ENV['HOME'] lets you override from the environment.
|
|
46
|
+
ENV["HOME"] ||= File.expand_path(Gem::user_home)
|
|
47
|
+
ENV['BUILDR_ENV'] ||= 'development'
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
module Buildr
|
|
51
|
+
|
|
52
|
+
# Provide settings that come from three sources.
|
|
53
|
+
#
|
|
54
|
+
# User settings are placed in the .buildr/settings.yaml file located in the user's home directory.
|
|
55
|
+
# They should only be used for settings that are specific to the user and applied the same way
|
|
56
|
+
# across all builds. Example for user settings are preferred repositories, path to local repository,
|
|
57
|
+
# user/name password for uploading to remote repository.
|
|
58
|
+
#
|
|
59
|
+
# Build settings are placed in the build.yaml file located in the build directory. They help keep
|
|
60
|
+
# the buildfile and build.yaml file simple and readable, working to the advantages of each one.
|
|
61
|
+
# Example for build settings are gems, repositories and artifacts used by that build.
|
|
62
|
+
#
|
|
63
|
+
# Profile settings are placed in the profiles.yaml file located in the build directory. They provide
|
|
64
|
+
# settings that differ in each environment the build runs in. For example, URLs and database
|
|
65
|
+
# connections will be different when used in development, test and production environments.
|
|
66
|
+
# The settings for the current environment are obtained by calling #profile.
|
|
67
|
+
class Settings
|
|
68
|
+
|
|
69
|
+
def initialize(application) #:nodoc:
|
|
70
|
+
@application = application
|
|
71
|
+
@user = load_from('settings', @application.home_dir)
|
|
72
|
+
@build = load_from('build')
|
|
73
|
+
@profiles = load_from('profiles')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# User settings loaded from setting.yaml file in user's home directory.
|
|
77
|
+
attr_reader :user
|
|
78
|
+
|
|
79
|
+
# Build settings loaded from build.yaml file in build directory.
|
|
80
|
+
attr_reader :build
|
|
81
|
+
|
|
82
|
+
# Profiles loaded from profiles.yaml file in build directory.
|
|
83
|
+
attr_reader :profiles
|
|
84
|
+
|
|
85
|
+
# :call-seq:
|
|
86
|
+
# profile => hash
|
|
87
|
+
#
|
|
88
|
+
# Returns the profile for the current environment.
|
|
89
|
+
def profile
|
|
90
|
+
profiles[@application.environment] ||= {}
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
|
|
95
|
+
def load_from(base_name, dir = nil)
|
|
96
|
+
base_name = File.expand_path(base_name, dir) if dir
|
|
97
|
+
file_name = ['yaml', 'yml'].map { |ext| "#{base_name}.#{ext}" }.find { |fn| File.exist?(fn) }
|
|
98
|
+
return {} unless file_name
|
|
99
|
+
yaml = YAML.load(File.read(file_name)) || {}
|
|
100
|
+
fail "Expecting #{file_name} to be a map (name: value)!" unless Hash === yaml
|
|
101
|
+
@application.buildfile.enhance [file_name]
|
|
102
|
+
yaml
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class Application < Rake::Application #:nodoc:
|
|
109
|
+
|
|
110
|
+
DEFAULT_BUILDFILES = ['buildfile', 'Buildfile'] + DEFAULT_RAKEFILES
|
|
111
|
+
|
|
112
|
+
include CommandLineInterface
|
|
113
|
+
|
|
114
|
+
attr_reader :rakefiles, :requires
|
|
115
|
+
private :rakefiles, :requires
|
|
116
|
+
|
|
117
|
+
def initialize
|
|
118
|
+
super
|
|
119
|
+
@rakefiles = DEFAULT_BUILDFILES
|
|
120
|
+
@name = 'Buildr'
|
|
121
|
+
@requires = []
|
|
122
|
+
@top_level_tasks = []
|
|
123
|
+
parse_options
|
|
124
|
+
collect_tasks
|
|
125
|
+
@home_dir = File.expand_path('.buildr', ENV['HOME'])
|
|
126
|
+
mkpath @home_dir, :verbose=>false unless File.exist?(@home_dir)
|
|
127
|
+
@environment = ENV['BUILDR_ENV'] ||= 'development'
|
|
128
|
+
@on_completion = []
|
|
129
|
+
@on_failure = []
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Returns list of Gems associated with this buildfile, as listed in build.yaml.
|
|
133
|
+
# Each entry is of type Gem::Specification.
|
|
134
|
+
attr_reader :gems
|
|
135
|
+
|
|
136
|
+
# Buildr home directory, .buildr under user's home directory.
|
|
137
|
+
attr_reader :home_dir
|
|
138
|
+
|
|
139
|
+
# Copied from BUILD_ENV.
|
|
140
|
+
attr_reader :environment
|
|
141
|
+
|
|
142
|
+
# Returns the Settings associated with this build.
|
|
143
|
+
def settings
|
|
144
|
+
fail "Internal error: Called Buildr.settings before buildfile located" unless rakefile
|
|
145
|
+
@settings ||= Settings.new(self)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# :call-seq:
|
|
149
|
+
# buildfile
|
|
150
|
+
# Returns the buildfile as a task that you can use as a dependency.
|
|
151
|
+
def buildfile
|
|
152
|
+
@buildfile_task ||= BuildfileTask.define_task(File.expand_path(rakefile))
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Files that complement the buildfile itself
|
|
156
|
+
def build_files #:nodoc:
|
|
157
|
+
buildfile.prerequisites
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def run
|
|
161
|
+
standard_exception_handling do
|
|
162
|
+
find_buildfile
|
|
163
|
+
load_gems
|
|
164
|
+
load_artifacts
|
|
165
|
+
load_tasks
|
|
166
|
+
load_requires
|
|
167
|
+
load_buildfile
|
|
168
|
+
load_imports
|
|
169
|
+
task('buildr:initialize').invoke
|
|
170
|
+
top_level
|
|
171
|
+
end
|
|
172
|
+
title, message = 'Your build has completed', "#{Dir.pwd}\nbuildr #{@top_level_tasks.join(' ')}"
|
|
173
|
+
@on_completion.each { |block| block.call(title, message) rescue nil }
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Yields to block on successful completion. Primarily used for notifications.
|
|
177
|
+
def on_completion(&block)
|
|
178
|
+
@on_completion << block
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Yields to block on failure with exception. Primarily used for notifications.
|
|
182
|
+
def on_failure(&block)
|
|
183
|
+
@on_failure << block
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Not for external consumption.
|
|
187
|
+
def switch_to_namespace(names) #:nodoc:
|
|
188
|
+
current, @scope = @scope, names
|
|
189
|
+
begin
|
|
190
|
+
yield
|
|
191
|
+
ensure
|
|
192
|
+
@scope = current
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# :call-seq:
|
|
197
|
+
# deprecated(message)
|
|
198
|
+
#
|
|
199
|
+
# Use with deprecated methods and classes. This method automatically adds the file name and line number,
|
|
200
|
+
# and the text 'Deprecated' before the message, and eliminated duplicate warnings. It only warns when
|
|
201
|
+
# running in verbose mode.
|
|
202
|
+
#
|
|
203
|
+
# For example:
|
|
204
|
+
# deprecated 'Please use new_foo instead of foo.'
|
|
205
|
+
def deprecated(message) #:nodoc:
|
|
206
|
+
return unless verbose
|
|
207
|
+
"#{caller[1]}: Deprecated: #{message}".tap do |message|
|
|
208
|
+
@deprecated ||= {}
|
|
209
|
+
unless @deprecated[message]
|
|
210
|
+
@deprecated[message] = true
|
|
211
|
+
warn message
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
private
|
|
217
|
+
|
|
218
|
+
# Returns Gem::Specification for every listed and installed Gem, Gem::Dependency
|
|
219
|
+
# for listed and uninstalled Gem, which is the installed before loading the buildfile.
|
|
220
|
+
def listed_gems #:nodoc:
|
|
221
|
+
Array(settings.build['gems']).map do |dep|
|
|
222
|
+
name, trail = dep.scan(/^\s*(\S*)\s*(.*)\s*$/).first
|
|
223
|
+
versions = trail.scan(/[=><~!]{0,2}\s*[\d\.]+/)
|
|
224
|
+
versions = ['>= 0'] if versions.empty?
|
|
225
|
+
dep = Gem::Dependency.new(name, versions)
|
|
226
|
+
Gem::SourceIndex.from_installed_gems.search(dep).last || dep
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Load artifact specs from the build.yaml file, making them available
|
|
231
|
+
# by name ( ruby symbols ).
|
|
232
|
+
def load_artifacts #:nodoc:
|
|
233
|
+
hash = settings.build['artifacts']
|
|
234
|
+
return unless hash
|
|
235
|
+
raise "Expected 'artifacts' element to be a hash" unless Hash === hash
|
|
236
|
+
# Currently we only use one artifact namespace to rule them all. (the root NS)
|
|
237
|
+
Buildr::ArtifactNamespace.load(:root => hash)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Load/install all Gems specified in build.yaml file.
|
|
241
|
+
def load_gems #:nodoc:
|
|
242
|
+
missing_deps, installed = listed_gems.partition { |gem| gem.is_a?(Gem::Dependency) }
|
|
243
|
+
unless missing_deps.empty?
|
|
244
|
+
newly_installed = Util::Gems.install(*missing_deps)
|
|
245
|
+
installed += newly_installed
|
|
246
|
+
end
|
|
247
|
+
installed.each do |spec|
|
|
248
|
+
if gem(spec.name, spec.version.to_s)
|
|
249
|
+
# TODO: is this intended to load rake tasks from the installed gems?
|
|
250
|
+
# We should use a convention like .. if the gem has a _buildr.rb file, load it.
|
|
251
|
+
|
|
252
|
+
#FileList[spec.require_paths.map { |path| File.expand_path("#{path}/*.rb", spec.full_gem_path) }].
|
|
253
|
+
# map { |path| File.basename(path) }.each { |file| require file }
|
|
254
|
+
#FileList[File.expand_path('tasks/*.rake', spec.full_gem_path)].each do |file|
|
|
255
|
+
# Buildr.application.add_import file
|
|
256
|
+
#end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
@gems = installed
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def find_buildfile #:nodoc:
|
|
263
|
+
here = original_dir
|
|
264
|
+
Dir.chdir(here) unless Dir.pwd == here
|
|
265
|
+
while ! have_rakefile
|
|
266
|
+
Dir.chdir('..')
|
|
267
|
+
if Dir.pwd == here || options.nosearch
|
|
268
|
+
error = "No Buildfile found (looking for: #{@rakefiles.join(', ')})"
|
|
269
|
+
if STDIN.isatty
|
|
270
|
+
chdir(original_dir) { task('generate').invoke }
|
|
271
|
+
exit 1
|
|
272
|
+
else
|
|
273
|
+
raise error
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
here = Dir.pwd
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def load_buildfile #:nodoc:
|
|
281
|
+
info "(in #{Dir.pwd}, #{environment})"
|
|
282
|
+
load File.expand_path(@rakefile) if @rakefile != ''
|
|
283
|
+
buildfile.enhance @requires.select { |f| File.file?(f) }.map{ |f| File.expand_path(f) }
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def load_requires #:nodoc:
|
|
287
|
+
@requires.each { |name| require name }
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# Loads buildr.rb files from users home directory and project directory.
|
|
291
|
+
# Loads custom tasks from .rake files in tasks directory.
|
|
292
|
+
def load_tasks #:nodoc:
|
|
293
|
+
files = [ File.expand_path('buildr.rb', ENV['HOME']), 'buildr.rb' ].select { |file| File.exist?(file) }
|
|
294
|
+
files += [ File.expand_path('buildr.rake', ENV['HOME']), File.expand_path('buildr.rake') ].
|
|
295
|
+
select { |file| File.exist?(file) }.each { |file| warn "Please use '#{file.ext('rb')}' instead of '#{file}'" }
|
|
296
|
+
#Load local tasks that can be used in the Buildfile.
|
|
297
|
+
files += Dir[File.expand_path('tasks/*.rake')]
|
|
298
|
+
files.each do |file|
|
|
299
|
+
unless $LOADED_FEATURES.include?(file)
|
|
300
|
+
load file
|
|
301
|
+
$LOADED_FEATURES << file
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
buildfile.enhance files
|
|
305
|
+
true
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def display_prerequisites
|
|
309
|
+
invoke_task('buildr:initialize')
|
|
310
|
+
tasks.each do |task|
|
|
311
|
+
if task.name =~ options.show_task_pattern
|
|
312
|
+
puts "buildr #{task.name}"
|
|
313
|
+
task.prerequisites.each { |prereq| puts " #{prereq}" }
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# Provide standard execption handling for the given block.
|
|
319
|
+
def standard_exception_handling
|
|
320
|
+
begin
|
|
321
|
+
yield
|
|
322
|
+
rescue SystemExit => ex
|
|
323
|
+
# Exit silently with current status
|
|
324
|
+
exit(ex.status)
|
|
325
|
+
rescue SystemExit, GetoptLong::InvalidOption => ex
|
|
326
|
+
# Exit silently
|
|
327
|
+
exit(1)
|
|
328
|
+
rescue Exception => ex
|
|
329
|
+
title, message = 'Your build failed with an error', "#{Dir.pwd}:\n#{ex.message}"
|
|
330
|
+
@on_failure.each { |block| block.call(title, message, ex) rescue nil }
|
|
331
|
+
# Exit with error message
|
|
332
|
+
$stderr.puts "buildr aborted!"
|
|
333
|
+
$stderr.puts $terminal.color(ex.message, :red)
|
|
334
|
+
if options.trace
|
|
335
|
+
$stderr.puts ex.backtrace.join("\n")
|
|
336
|
+
else
|
|
337
|
+
$stderr.puts ex.backtrace.select { |str| str =~ /#{buildfile}/ }.map { |line| $terminal.color(line, :red) }.join("\n")
|
|
338
|
+
$stderr.puts "(See full trace by running task with --trace)"
|
|
339
|
+
end
|
|
340
|
+
exit(1)
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# This task stands for the buildfile and all its associated helper files (e.g., buildr.rb, build.yaml).
|
|
348
|
+
# By using this task as a prerequisite for other tasks, you can ensure these tasks will be needed
|
|
349
|
+
# whenever the buildfile changes.
|
|
350
|
+
class BuildfileTask < Rake::FileTask
|
|
351
|
+
|
|
352
|
+
def timestamp
|
|
353
|
+
([name] + prerequisites).map { |f| File.stat(f).mtime }.max rescue Time.now
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class << self
|
|
359
|
+
|
|
360
|
+
task 'buildr:initialize' do
|
|
361
|
+
Buildr.load_tasks_and_local_files
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
# Returns the Buildr::Application object.
|
|
365
|
+
def application
|
|
366
|
+
Rake.application
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def application=(app) #:nodoc:
|
|
370
|
+
Rake.application = app
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
# Returns the Settings associated with this build.
|
|
374
|
+
def settings
|
|
375
|
+
Buildr.application.settings
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# Copied from BUILD_ENV.
|
|
379
|
+
def environment
|
|
380
|
+
Buildr.application.environment
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
Buildr.application = Buildr::Application.new
|
|
386
|
+
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
# Add a touch of color when available and running in terminal.
|
|
391
|
+
if $stdout.isatty
|
|
392
|
+
begin
|
|
393
|
+
require 'Win32/Console/ANSI' if Config::CONFIG['host_os'] =~ /mswin/
|
|
394
|
+
HighLine.use_color = true
|
|
395
|
+
rescue LoadError
|
|
396
|
+
end
|
|
397
|
+
else
|
|
398
|
+
HighLine.use_color = false
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
# Let's see if we can use Growl. We do this at the very end, loading Ruby Cocoa
|
|
403
|
+
# could slow the build down, so later is better. We only do this when running
|
|
404
|
+
# from the console in verbose mode.
|
|
405
|
+
if $stdout.isatty && verbose && RUBY_PLATFORM =~ /darwin/
|
|
406
|
+
begin
|
|
407
|
+
require 'osx/cocoa'
|
|
408
|
+
icon = OSX::NSApplication.sharedApplication.applicationIconImage
|
|
409
|
+
icon = OSX::NSImage.alloc.initWithContentsOfFile(File.join(File.dirname(__FILE__), '../resources/buildr.icns'))
|
|
410
|
+
|
|
411
|
+
# Register with Growl, that way you can turn notifications on/off from system preferences.
|
|
412
|
+
OSX::NSDistributedNotificationCenter.defaultCenter.
|
|
413
|
+
postNotificationName_object_userInfo_deliverImmediately(:GrowlApplicationRegistrationNotification, nil,
|
|
414
|
+
{ :ApplicationName=>'Buildr', :AllNotifications=>['Completed', 'Failed'],
|
|
415
|
+
:ApplicationIcon=>icon.TIFFRepresentation }, true)
|
|
416
|
+
|
|
417
|
+
notify = lambda do |type, title, message|
|
|
418
|
+
OSX::NSDistributedNotificationCenter.defaultCenter.
|
|
419
|
+
postNotificationName_object_userInfo_deliverImmediately(:GrowlNotification, nil,
|
|
420
|
+
{ :ApplicationName=>'Buildr', :NotificationName=>type,
|
|
421
|
+
:NotificationTitle=>title, :NotificationDescription=>message }, true)
|
|
422
|
+
end
|
|
423
|
+
Buildr.application.on_completion { |title, message| notify['Completed', title, message] }
|
|
424
|
+
Buildr.application.on_failure { |title, message, ex| notify['Failed', title, message] }
|
|
425
|
+
rescue Exception # No growl
|
|
426
|
+
end
|
|
427
|
+
elsif $stdout.isatty && verbose
|
|
428
|
+
notify = lambda { |type, title, message| $stdout.puts "[#{type}] #{title}: #{message}" }
|
|
429
|
+
Buildr.application.on_completion { |title, message| notify['Completed', title, message] }
|
|
430
|
+
Buildr.application.on_failure { |title, message, ex| notify['Failed', title, message] }
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
alias :warn_without_color :warn
|
|
435
|
+
|
|
436
|
+
# Show warning message.
|
|
437
|
+
def warn(message)
|
|
438
|
+
warn_without_color $terminal.color(message.to_s, :blue) if verbose
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
# Show error message. Use this when you need to show an error message and not throwing
|
|
442
|
+
# an exception that will stop the build.
|
|
443
|
+
def error(message)
|
|
444
|
+
puts $terminal.color(message.to_s, :red)
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
# Show optional information. The message is printed only when running in verbose
|
|
448
|
+
# mode (the default).
|
|
449
|
+
def info(message)
|
|
450
|
+
puts message if verbose
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# Show message. The message is printed out only when running in trace mode.
|
|
454
|
+
def trace(message)
|
|
455
|
+
puts message if Buildr.application.options.trace
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
module Rake #:nodoc
|
|
460
|
+
class Task #:nodoc:
|
|
461
|
+
def invoke(*args)
|
|
462
|
+
task_args = TaskArguments.new(arg_names, args)
|
|
463
|
+
invoke_with_call_chain(task_args, Thread.current[:rake_chain] || InvocationChain::EMPTY)
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
def invoke_with_call_chain(task_args, invocation_chain)
|
|
467
|
+
new_chain = InvocationChain.append(self, invocation_chain)
|
|
468
|
+
@lock.synchronize do
|
|
469
|
+
if application.options.trace
|
|
470
|
+
puts "** Invoke #{name} #{format_trace_flags}"
|
|
471
|
+
end
|
|
472
|
+
return if @already_invoked
|
|
473
|
+
@already_invoked = true
|
|
474
|
+
begin
|
|
475
|
+
invoke_prerequisites(task_args, new_chain)
|
|
476
|
+
rescue
|
|
477
|
+
trace "Exception while invoking prerequisites of task #{self.inspect}"
|
|
478
|
+
raise
|
|
479
|
+
end
|
|
480
|
+
begin
|
|
481
|
+
old_chain, Thread.current[:rake_chain] = Thread.current[:rake_chain], new_chain
|
|
482
|
+
execute(task_args) if needed?
|
|
483
|
+
ensure
|
|
484
|
+
Thread.current[:rake_chain] = nil
|
|
485
|
+
end
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
end
|