buildr 1.4.4-x86-mswin32 → 1.4.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +46 -0
- data/Rakefile +0 -1
- data/addon/buildr/bnd.rb +147 -0
- data/addon/buildr/jaxb_xjc.rb +72 -0
- data/addon/buildr/protobuf.rb +14 -1
- data/buildr.gemspec +6 -2
- data/doc/artifacts.textile +6 -0
- data/doc/contributing.textile +3 -0
- data/doc/download.textile +60 -0
- data/doc/index.textile +9 -15
- data/doc/installing.textile +23 -6
- data/doc/mailing_lists.textile +4 -0
- data/doc/more_stuff.textile +333 -6
- data/doc/packaging.textile +187 -1
- data/lib/buildr.rb +8 -1
- data/lib/buildr/clojure.rb +34 -0
- data/lib/buildr/clojure/shell.rb +52 -0
- data/lib/buildr/core.rb +3 -0
- data/lib/buildr/core/#application.rb# +700 -0
- data/lib/buildr/core/application.rb +18 -8
- data/lib/buildr/core/build.rb +2 -2
- data/lib/buildr/core/cc.rb +57 -63
- data/lib/buildr/core/checks.rb +4 -5
- data/lib/buildr/core/doc.rb +3 -1
- data/lib/buildr/core/generate.rb +2 -0
- data/lib/buildr/core/jrebel.rb +42 -0
- data/lib/buildr/core/linux.rb +30 -0
- data/lib/buildr/core/project.rb +9 -8
- data/lib/buildr/core/run.rb +3 -3
- data/lib/buildr/core/shell.rb +29 -90
- data/lib/buildr/core/test.rb +3 -3
- data/lib/buildr/core/transports.rb +5 -5
- data/lib/buildr/core/util.rb +2 -2
- data/lib/buildr/groovy.rb +1 -0
- data/lib/buildr/groovy/compiler.rb +12 -1
- data/lib/buildr/groovy/doc.rb +76 -0
- data/lib/buildr/groovy/shell.rb +24 -15
- data/lib/buildr/ide.rb +1 -1
- data/lib/buildr/ide/idea.rb +527 -141
- data/lib/buildr/java/bdd.rb +18 -13
- data/lib/buildr/java/ecj.rb +1 -3
- data/lib/buildr/java/jtestr_result.rb +295 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +4 -6
- data/lib/buildr/java/packaging.rb +14 -3
- data/lib/buildr/java/pom.rb +6 -2
- data/lib/buildr/java/test_result.rb +15 -243
- data/lib/buildr/java/tests.rb +1 -1
- data/lib/buildr/packaging.rb +2 -1
- data/lib/buildr/packaging/#package.rb.rej# +19 -0
- data/lib/buildr/packaging/archive.rb +13 -3
- data/lib/buildr/packaging/artifact.rb +11 -12
- data/lib/buildr/packaging/tar.rb +4 -1
- data/lib/buildr/packaging/zip.rb +106 -1
- 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 +7 -14
- data/lib/buildr/scala/#Untitled-2# +7 -0
- data/lib/buildr/scala/bdd.rb +1 -1
- data/lib/buildr/scala/compiler.rb +1 -1
- data/lib/buildr/scala/doc.rb +20 -2
- data/lib/buildr/scala/shell.rb +14 -22
- data/lib/buildr/scala/tests.rb +2 -2
- data/lib/buildr/shell.rb +113 -108
- data/lib/buildr/version.rb +1 -1
- data/rakelib/checks.rake +9 -7
- data/rakelib/doc.rake +10 -0
- data/rakelib/release.rake +9 -0
- data/rakelib/rspec.rake +27 -28
- data/rakelib/setup.rake +1 -1
- data/rakelib/stage.rake +2 -2
- data/spec/addon/bnd_spec.rb +330 -0
- data/spec/addon/jaxb_xjc_spec.rb +125 -0
- data/spec/core/application_spec.rb +1 -1
- data/spec/core/build_spec.rb +7 -7
- data/spec/core/cc_spec.rb +154 -104
- data/spec/core/compile_spec.rb +3 -3
- data/spec/core/project_spec.rb +10 -0
- data/spec/core/run_spec.rb +1 -0
- data/spec/core/shell_spec.rb +146 -0
- data/spec/groovy/doc_spec.rb +65 -0
- data/spec/ide/eclipse_spec.rb +1 -1
- data/spec/ide/idea_spec.rb +1145 -0
- data/spec/java/bdd_spec.rb +3 -3
- data/spec/java/emma_spec.rb +2 -0
- data/spec/java/packaging_spec.rb +40 -11
- data/spec/java/test_coverage_helper.rb +1 -1
- data/spec/packaging/archive_spec.rb +76 -21
- data/spec/packaging/artifact_namespace_spec.rb +1 -1
- data/spec/packaging/artifact_spec.rb +14 -7
- data/spec/sandbox.rb +11 -4
- data/spec/scala/bdd_spec.rb +2 -2
- data/spec/scala/compiler_spec.rb +2 -2
- data/spec/scala/doc_spec.rb +24 -4
- data/spec/scala/scala.rb +2 -2
- data/spec/scala/tests_spec.rb +2 -2
- data/spec/spec_helpers.rb +9 -8
- data/spec/xpath_matchers.rb +121 -0
- metadata +246 -166
- data/lib/buildr/ide/idea.ipr.template +0 -300
- data/lib/buildr/ide/idea7x.ipr.template +0 -290
- data/lib/buildr/ide/idea7x.rb +0 -231
- data/spec/ide/idea7x_spec.rb +0 -96
data/lib/buildr.rb
CHANGED
@@ -27,11 +27,18 @@ require 'buildr/run'
|
|
27
27
|
# Methods defined in Buildr are both instance methods (e.g. when included in Project)
|
28
28
|
# and class methods when invoked like Buildr.artifacts().
|
29
29
|
module Buildr ; extend self ; end
|
30
|
+
|
30
31
|
# The Buildfile object (self) has access to all the Buildr methods and constants.
|
31
32
|
class << self ; include Buildr ; end
|
33
|
+
|
34
|
+
# All modules defined under Buildr::* can be referenced without Buildr:: prefix
|
35
|
+
# unless a conflict exists (e.g. Buildr::RSpec vs ::RSpec)
|
32
36
|
class Object #:nodoc:
|
33
37
|
Buildr.constants.each do |name|
|
34
38
|
const = Buildr.const_get(name)
|
35
|
-
|
39
|
+
if const.is_a?(Module)
|
40
|
+
const_set name, const unless const_defined?(name)
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
44
|
+
|
@@ -0,0 +1,34 @@
|
|
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/util'
|
18
|
+
|
19
|
+
module Buildr::Clojure
|
20
|
+
|
21
|
+
REQUIRES = ArtifactNamespace.for(self) do |ns|
|
22
|
+
ns.clojure! 'org.clojure:clojure:jar:1.2.0'
|
23
|
+
ns.jline! 'jline:jline:jar:0.9.94'
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def dependencies #:nodoc:
|
28
|
+
REQUIRES.artifacts
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'buildr/clojure/shell'
|
@@ -0,0 +1,52 @@
|
|
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
|
+
module Buildr::Shell
|
17
|
+
|
18
|
+
class Clojure < Base
|
19
|
+
include JRebel
|
20
|
+
|
21
|
+
specify :name => :clj, :lang => :clojure
|
22
|
+
|
23
|
+
# don't build if it's *only* Clojure sources
|
24
|
+
def build?
|
25
|
+
!has_source?(:clojure) or has_source?(:java) or has_source?(:scala) or has_source?(:groovy)
|
26
|
+
end
|
27
|
+
|
28
|
+
def launch(task)
|
29
|
+
cp = project.compile.dependencies +
|
30
|
+
::Buildr::Clojure.dependencies +
|
31
|
+
[ build? ? project.path_to(:target, :classes) : project.path_to(:src, :main, :clojure) ]
|
32
|
+
|
33
|
+
Java::Commands.java 'jline.ConsoleRunner', 'clojure.lang.Repl', {
|
34
|
+
:properties => jrebel_props(project).merge(task.properties),
|
35
|
+
:classpath => cp,
|
36
|
+
:java_args => jrebel_args + task.java_args
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def clojure_home
|
42
|
+
@home ||= ENV['CLOJURE_HOME']
|
43
|
+
end
|
44
|
+
|
45
|
+
def has_source?(lang)
|
46
|
+
File.exists? project.path_to(:src, :main, lang)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Buildr::Shell.providers << Buildr::Shell::Clojure
|
52
|
+
|
data/lib/buildr/core.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
require 'buildr/core/common'
|
17
17
|
require 'buildr/core/application'
|
18
|
+
require 'buildr/core/jrebel'
|
18
19
|
require 'buildr/core/project'
|
19
20
|
require 'buildr/core/environment'
|
20
21
|
require 'buildr/core/help'
|
@@ -29,3 +30,5 @@ require 'buildr/core/transports'
|
|
29
30
|
require 'buildr/core/generate'
|
30
31
|
require 'buildr/core/cc'
|
31
32
|
require 'buildr/core/osx' if RUBY_PLATFORM =~ /darwin/
|
33
|
+
require 'buildr/core/linux' if RUBY_PLATFORM =~ /linux/
|
34
|
+
|
@@ -0,0 +1,700 @@
|
|
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
|
+
# Portion of this file derived from Rake.
|
18
|
+
# Copyright (c) 2003, 2004 Jim Weirich
|
19
|
+
#
|
20
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
21
|
+
# of this software and associated documentation files (the "Software"), to deal
|
22
|
+
# in the Software without restriction, including without limitation the rights
|
23
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
24
|
+
# copies of the Software, and to permit persons to whom the Software is
|
25
|
+
# furnished to do so, subject to the following conditions:
|
26
|
+
#
|
27
|
+
# The above copyright notice and this permission notice shall be included in
|
28
|
+
# all copies or substantial portions of the Software.
|
29
|
+
#
|
30
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
31
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
32
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
33
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
34
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
35
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
36
|
+
# SOFTWARE.
|
37
|
+
|
38
|
+
|
39
|
+
require 'rake'
|
40
|
+
require 'highline/import'
|
41
|
+
require 'rubygems/source_info_cache' if Gem::VERSION =~ /1.[0-4]/
|
42
|
+
require 'buildr/core/util'
|
43
|
+
Gem.autoload :SourceInfoCache, 'rubygems/source_info_cache' if Gem::VERSION =~ /1.[0-4]2/
|
44
|
+
|
45
|
+
|
46
|
+
# Gem::user_home is nice, but ENV['HOME'] lets you override from the environment.
|
47
|
+
ENV['HOME'] ||= File.expand_path(Gem::user_home)
|
48
|
+
ENV['BUILDR_ENV'] ||= 'development'
|
49
|
+
|
50
|
+
|
51
|
+
module Buildr
|
52
|
+
|
53
|
+
# Provide settings that come from three sources.
|
54
|
+
#
|
55
|
+
# User settings are placed in the .buildr/settings.yaml file located in the user's home directory.
|
56
|
+
# They should only be used for settings that are specific to the user and applied the same way
|
57
|
+
# across all builds. Example for user settings are preferred repositories, path to local repository,
|
58
|
+
# user/name password for uploading to remote repository.
|
59
|
+
#
|
60
|
+
# Build settings are placed in the build.yaml file located in the build directory. They help keep
|
61
|
+
# the buildfile and build.yaml file simple and readable, working to the advantages of each one.
|
62
|
+
# Example for build settings are gems, repositories and artifacts used by that build.
|
63
|
+
#
|
64
|
+
# Profile settings are placed in the profiles.yaml file located in the build directory. They provide
|
65
|
+
# settings that differ in each environment the build runs in. For example, URLs and database
|
66
|
+
# connections will be different when used in development, test and production environments.
|
67
|
+
# The settings for the current environment are obtained by calling #profile.
|
68
|
+
class Settings
|
69
|
+
|
70
|
+
def initialize(application) #:nodoc:
|
71
|
+
@application = application
|
72
|
+
end
|
73
|
+
|
74
|
+
# User settings loaded from setting.yaml file in user's home directory.
|
75
|
+
def user
|
76
|
+
@user ||= load_from('settings', @application.home_dir)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Build settings loaded from build.yaml file in build directory.
|
80
|
+
def build
|
81
|
+
@build ||= load_from('build')
|
82
|
+
end
|
83
|
+
|
84
|
+
# Profiles loaded from profiles.yaml file in build directory.
|
85
|
+
def profiles
|
86
|
+
@profiles ||= load_from('profiles')
|
87
|
+
end
|
88
|
+
|
89
|
+
# :call-seq:
|
90
|
+
# profile => hash
|
91
|
+
#
|
92
|
+
# Returns the profile for the current environment.
|
93
|
+
def profile
|
94
|
+
profiles[@application.environment] ||= {}
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def load_from(name, path = nil)
|
100
|
+
unless path
|
101
|
+
fail "Internal error: attempting to access local setting before buildfile located" unless @application.rakefile
|
102
|
+
path = File.dirname(@application.rakefile)
|
103
|
+
end
|
104
|
+
file_name = ['yaml', 'yml'].map { |ext| File.join(path, "#{name}.#{ext}") }.find { |fn| File.exist?(fn) }
|
105
|
+
return {} unless file_name
|
106
|
+
yaml = YAML.load(File.read(file_name)) || {}
|
107
|
+
fail "Expecting #{file_name} to be a map (name: value)!" unless Hash === yaml
|
108
|
+
@application.buildfile.enhance [file_name]
|
109
|
+
yaml
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
class Application < Rake::Application #:nodoc:
|
116
|
+
|
117
|
+
# Deprecated: rakefile/Rakefile, removed in 1.5
|
118
|
+
DEFAULT_BUILDFILES = ['buildfile', 'Buildfile', 'buildfile.rb', 'Buildfile.rb'] + DEFAULT_RAKEFILES
|
119
|
+
|
120
|
+
attr_reader :rakefiles, :requires
|
121
|
+
private :rakefiles, :requires
|
122
|
+
|
123
|
+
def initialize
|
124
|
+
super
|
125
|
+
@rakefiles = DEFAULT_BUILDFILES.dup
|
126
|
+
@top_level_tasks = []
|
127
|
+
@home_dir = File.expand_path('.buildr', ENV['HOME'])
|
128
|
+
mkpath @home_dir if !File.exist?(@home_dir) && File.writable?(ENV['HOME'])
|
129
|
+
@settings = Settings.new(self)
|
130
|
+
@on_completion = []
|
131
|
+
@on_failure = []
|
132
|
+
end
|
133
|
+
|
134
|
+
def run
|
135
|
+
standard_exception_handling do
|
136
|
+
init 'Buildr'
|
137
|
+
load_buildfile
|
138
|
+
top_level
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Not for external consumption.
|
143
|
+
def switch_to_namespace(names) #:nodoc:
|
144
|
+
current, @scope = @scope, names
|
145
|
+
begin
|
146
|
+
yield
|
147
|
+
ensure
|
148
|
+
@scope = current
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns list of Gems associated with this buildfile, as listed in build.yaml.
|
153
|
+
# Each entry is of type Gem::Specification.
|
154
|
+
attr_reader :gems
|
155
|
+
|
156
|
+
# Buildr home directory, .buildr under user's home directory.
|
157
|
+
attr_reader :home_dir
|
158
|
+
|
159
|
+
# Copied from BUILD_ENV.
|
160
|
+
def environment
|
161
|
+
ENV['BUILDR_ENV']
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns the Settings associated with this build.
|
165
|
+
attr_reader :settings
|
166
|
+
|
167
|
+
# :call-seq:
|
168
|
+
# buildfile
|
169
|
+
# Returns the buildfile as a task that you can use as a dependency.
|
170
|
+
def buildfile
|
171
|
+
@buildfile_task ||= BuildfileTask.define_task(File.expand_path(rakefile))
|
172
|
+
end
|
173
|
+
|
174
|
+
# Files that complement the buildfile itself
|
175
|
+
def build_files #:nodoc:
|
176
|
+
deprecated 'Please call buildfile.prerequisites instead'
|
177
|
+
buildfile.prerequisites
|
178
|
+
end
|
179
|
+
|
180
|
+
# Yields to block on successful completion. Primarily used for notifications.
|
181
|
+
def on_completion(&block)
|
182
|
+
@on_completion << block
|
183
|
+
end
|
184
|
+
|
185
|
+
# Yields to block on failure with exception. Primarily used for notifications.
|
186
|
+
def on_failure(&block)
|
187
|
+
@on_failure << block
|
188
|
+
end
|
189
|
+
|
190
|
+
# Call on_completion hooks with the given title and message
|
191
|
+
def build_completed(title, message)
|
192
|
+
@on_completion.each do |block|
|
193
|
+
block.call(title, message) rescue nil
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Call on_failure hooks with the given title, message and exception
|
198
|
+
def build_failed(title, message, ex = nil)
|
199
|
+
@on_failure.each do |block|
|
200
|
+
block.call(title, message, ex) rescue nil
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# :call-seq:
|
205
|
+
# deprecated(message)
|
206
|
+
#
|
207
|
+
# Use with deprecated methods and classes. This method automatically adds the file name and line number,
|
208
|
+
# and the text 'Deprecated' before the message, and eliminated duplicate warnings. It only warns when
|
209
|
+
# running in verbose mode.
|
210
|
+
#
|
211
|
+
# For example:
|
212
|
+
# deprecated 'Please use new_foo instead of foo.'
|
213
|
+
def deprecated(message) #:nodoc:
|
214
|
+
return unless verbose
|
215
|
+
"#{caller[1]}: Deprecated: #{message}".tap do |message|
|
216
|
+
@deprecated ||= {}
|
217
|
+
unless @deprecated[message]
|
218
|
+
@deprecated[message] = true
|
219
|
+
warn message
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
protected
|
225
|
+
|
226
|
+
def load_buildfile # replaces load_rakefile
|
227
|
+
standard_exception_handling do
|
228
|
+
find_buildfile
|
229
|
+
load_gems
|
230
|
+
load_artifact_ns
|
231
|
+
load_tasks
|
232
|
+
raw_load_buildfile
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def top_level # adds on_completion hook
|
237
|
+
standard_exception_handling do
|
238
|
+
if options.show_tasks
|
239
|
+
display_tasks_and_comments
|
240
|
+
elsif options.show_prereqs
|
241
|
+
display_prerequisites
|
242
|
+
elsif options.execute
|
243
|
+
eval options.execute
|
244
|
+
else
|
245
|
+
@start = Time.now
|
246
|
+
top_level_tasks.each { |task_name| invoke_task(task_name) }
|
247
|
+
if verbose
|
248
|
+
elapsed = Time.now - @start
|
249
|
+
real = []
|
250
|
+
real << ('%ih' % (elapsed / 3600)) if elapsed >= 3600
|
251
|
+
real << ('%im' % ((elapsed / 60) % 60)) if elapsed >= 60
|
252
|
+
real << ('%.3fs' % (elapsed % 60))
|
253
|
+
puts $terminal.color("Completed in #{real.join}", :green)
|
254
|
+
end
|
255
|
+
# On OS X this will load Cocoa and Growl which takes half a second we
|
256
|
+
# don't want to measure, so put this after the console message.
|
257
|
+
title, message = "Your build has completed", "#{Dir.pwd}\nbuildr #{@top_level_tasks.join(' ')}"
|
258
|
+
build_completed(title, message)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def handle_options
|
264
|
+
options.rakelib = ['tasks']
|
265
|
+
|
266
|
+
OptionParser.new do |opts|
|
267
|
+
opts.banner = "buildr [-f rakefile] {options} targets..."
|
268
|
+
opts.separator ""
|
269
|
+
opts.separator "Options are ..."
|
270
|
+
|
271
|
+
opts.on_tail("-h", "--help", "-H", "Display this help message.") do
|
272
|
+
puts opts
|
273
|
+
exit 0
|
274
|
+
end
|
275
|
+
standard_buildr_options.each { |args| opts.on(*args) }
|
276
|
+
end.parse!
|
277
|
+
end
|
278
|
+
|
279
|
+
def standard_buildr_options # replaces standard_rake_options
|
280
|
+
[
|
281
|
+
['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
|
282
|
+
lambda { |value|
|
283
|
+
options.show_tasks = true
|
284
|
+
options.full_description = true
|
285
|
+
options.show_task_pattern = Regexp.new(value || '')
|
286
|
+
}
|
287
|
+
],
|
288
|
+
['--execute', '-E CODE',
|
289
|
+
"Execute some Ruby code after loading the buildfile",
|
290
|
+
lambda { |value| options.execute = value }
|
291
|
+
],
|
292
|
+
['--environment', '-e ENV',
|
293
|
+
"Environment name (e.g. development, test, production).",
|
294
|
+
lambda { |value| ENV['BUILDR_ENV'] = value }
|
295
|
+
],
|
296
|
+
['--generate [PATH]',
|
297
|
+
"Generate buildfile from either pom.xml file or directory path.",
|
298
|
+
lambda { |value|
|
299
|
+
value ||= File.exist?('pom.xml') ? 'pom.xml' : Dir.pwd
|
300
|
+
raw_generate_buildfile value
|
301
|
+
exit 0
|
302
|
+
}
|
303
|
+
],
|
304
|
+
['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
|
305
|
+
lambda { |value| $:.push(value) }
|
306
|
+
],
|
307
|
+
['--prereqs', '-P [PATTERN]', "Display the tasks and dependencies (matching optional PATTERN), then exit.",
|
308
|
+
lambda { |value|
|
309
|
+
options.show_prereqs = true
|
310
|
+
options.show_task_pattern = Regexp.new(value || '')
|
311
|
+
}
|
312
|
+
],
|
313
|
+
['--quiet', '-q', "Do not log messages to standard output.",
|
314
|
+
lambda { |value| verbose(false) }
|
315
|
+
],
|
316
|
+
['--buildfile', '-f FILE', "Use FILE as the buildfile.",
|
317
|
+
lambda { |value|
|
318
|
+
@rakefiles.clear
|
319
|
+
@rakefiles << value
|
320
|
+
}
|
321
|
+
],
|
322
|
+
['--rakelibdir', '--rakelib', '-R PATH',
|
323
|
+
"Auto-import any .rake files in PATH. (default is 'tasks')",
|
324
|
+
lambda { |value| options.rakelib = value.split(':') }
|
325
|
+
],
|
326
|
+
['--require', '-r MODULE', "Require MODULE before executing rakefile.",
|
327
|
+
lambda { |value|
|
328
|
+
begin
|
329
|
+
require value
|
330
|
+
rescue LoadError => ex
|
331
|
+
begin
|
332
|
+
rake_require value
|
333
|
+
rescue LoadError => ex2
|
334
|
+
raise ex
|
335
|
+
end
|
336
|
+
end
|
337
|
+
}
|
338
|
+
],
|
339
|
+
['--rules', "Trace the rules resolution.",
|
340
|
+
lambda { |value| options.trace_rules = true }
|
341
|
+
],
|
342
|
+
['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
|
343
|
+
lambda { |value| options.nosearch = true }
|
344
|
+
],
|
345
|
+
['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
|
346
|
+
lambda { |value|
|
347
|
+
verbose(false)
|
348
|
+
options.silent = true
|
349
|
+
}
|
350
|
+
],
|
351
|
+
['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
|
352
|
+
lambda { |value|
|
353
|
+
options.show_tasks = true
|
354
|
+
options.show_task_pattern = Regexp.new(value || '')
|
355
|
+
options.full_description = false
|
356
|
+
}
|
357
|
+
],
|
358
|
+
['--trace', '-t [CATEGORIES]', "Turn on invoke/execute tracing, enable full backtrace.",
|
359
|
+
lambda { |value|
|
360
|
+
options.trace = true
|
361
|
+
options.trace_categories = value ? value.split(',').map { |v| v.downcase.to_sym } : []
|
362
|
+
options.trace_all = options.trace_categories.include? :all
|
363
|
+
verbose(true)
|
364
|
+
}
|
365
|
+
],
|
366
|
+
['--verbose', '-v', "Log message to standard output (default).",
|
367
|
+
lambda { |value| verbose(true) }
|
368
|
+
],
|
369
|
+
['--version', '-V', "Display the program version.",
|
370
|
+
lambda { |value|
|
371
|
+
puts "Buildr #{Buildr::VERSION}#{RUBY_PLATFORM[/java/] ? " (JRuby #{JRUBY_VERSION})" : ""}"
|
372
|
+
exit 0
|
373
|
+
}
|
374
|
+
],
|
375
|
+
['--offline', '-o', "Do not try to download anything",
|
376
|
+
lambda { |value|
|
377
|
+
trace 'Working in offline mode; snapshot will not be updated.'
|
378
|
+
options.work_offline = true
|
379
|
+
}
|
380
|
+
],
|
381
|
+
['--update-snapshots', '-u', "Force updating all dependencies whose version contains SNAPSHOT",
|
382
|
+
lambda { |value|
|
383
|
+
trace 'Force update of SNAPSHOT artifacts.'
|
384
|
+
options.update_snapshots = true
|
385
|
+
}
|
386
|
+
]
|
387
|
+
]
|
388
|
+
end
|
389
|
+
|
390
|
+
def find_buildfile
|
391
|
+
buildfile, location = find_rakefile_location || (tty_output? && ask_generate_buildfile)
|
392
|
+
fail "No Buildfile found (looking for: #{@rakefiles.join(', ')})" if buildfile.nil?
|
393
|
+
@rakefile = buildfile
|
394
|
+
Dir.chdir(location)
|
395
|
+
end
|
396
|
+
|
397
|
+
def ask_generate_buildfile
|
398
|
+
source = choose do |menu|
|
399
|
+
menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
|
400
|
+
menu.choice("From Maven2 POM file") { 'pom.xml' } if File.exist?('pom.xml')
|
401
|
+
menu.choice("From directory structure") { Dir.pwd }
|
402
|
+
menu.choice("Cancel") { }
|
403
|
+
end
|
404
|
+
if source
|
405
|
+
buildfile = raw_generate_buildfile(source)
|
406
|
+
[buildfile, File.dirname(buildfile)]
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
def raw_generate_buildfile(source)
|
411
|
+
# We need rakefile to be known, for settings.build to be accessible.
|
412
|
+
@rakefile = File.expand_path(DEFAULT_BUILDFILES.first)
|
413
|
+
fail "Buildfile already exists" if File.exist?(@rakefile) && !(tty_output? && agree('Buildfile exists, overwrite?'))
|
414
|
+
script = File.directory?(source) ? Generate.from_directory(source) : Generate.from_maven2_pom(source)
|
415
|
+
File.open @rakefile, 'w' do |file|
|
416
|
+
file.puts script
|
417
|
+
end
|
418
|
+
puts "Created #{@rakefile}" if verbose
|
419
|
+
@rakefile
|
420
|
+
end
|
421
|
+
|
422
|
+
def raw_load_buildfile # replaces raw_load_rakefile
|
423
|
+
puts "(in #{Dir.pwd}, #{environment})" unless options.silent
|
424
|
+
load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
|
425
|
+
load_imports
|
426
|
+
Buildr.projects
|
427
|
+
end
|
428
|
+
|
429
|
+
# Load/install all Gems specified in build.yaml file.
|
430
|
+
def load_gems #:nodoc:
|
431
|
+
missing_deps, installed = listed_gems.partition { |gem| gem.is_a?(Gem::Dependency) }
|
432
|
+
unless missing_deps.empty?
|
433
|
+
newly_installed = Util::Gems.install(*missing_deps)
|
434
|
+
installed += newly_installed
|
435
|
+
end
|
436
|
+
installed.each do |spec|
|
437
|
+
if gem(spec.name, spec.version.to_s)
|
438
|
+
# TODO: is this intended to load rake tasks from the installed gems?
|
439
|
+
# We should use a convention like .. if the gem has a _buildr.rb file, load it.
|
440
|
+
|
441
|
+
#FileList[spec.require_paths.map { |path| File.expand_path("#{path}/*.rb", spec.full_gem_path) }].
|
442
|
+
# map { |path| File.basename(path) }.each { |file| require file }
|
443
|
+
#FileList[File.expand_path('tasks/*.rake', spec.full_gem_path)].each do |file|
|
444
|
+
# Buildr.application.add_import file
|
445
|
+
#end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
@gems = installed
|
449
|
+
end
|
450
|
+
|
451
|
+
# Returns Gem::Specification for every listed and installed Gem, Gem::Dependency
|
452
|
+
# for listed and uninstalled Gem, which is the installed before loading the buildfile.
|
453
|
+
def listed_gems #:nodoc:
|
454
|
+
Array(settings.build['gems']).map do |dep|
|
455
|
+
name, trail = dep.scan(/^\s*(\S*)\s*(.*)\s*$/).first
|
456
|
+
versions = trail.scan(/[=><~!]{0,2}\s*[\d\.]+/)
|
457
|
+
versions = ['>= 0'] if versions.empty?
|
458
|
+
dep = Gem::Dependency.new(name, versions)
|
459
|
+
Gem::SourceIndex.from_installed_gems.search(dep).last || dep
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
# Load artifact specs from the build.yaml file, making them available
|
464
|
+
# by name ( ruby symbols ).
|
465
|
+
def load_artifact_ns #:nodoc:
|
466
|
+
hash = settings.build['artifacts']
|
467
|
+
return unless hash
|
468
|
+
raise "Expected 'artifacts' element to be a hash" unless Hash === hash
|
469
|
+
# Currently we only use one artifact namespace to rule them all. (the root NS)
|
470
|
+
Buildr::ArtifactNamespace.load(:root => hash)
|
471
|
+
end
|
472
|
+
|
473
|
+
# Loads buildr.rb files from home/.buildr directory and project directory.
|
474
|
+
# Loads custom tasks from .rake files in tasks directory.
|
475
|
+
def load_tasks #:nodoc:
|
476
|
+
# TODO: this might need to be split up, look for deprecated features, better method name.
|
477
|
+
old = File.expand_path('buildr.rb', ENV['HOME'])
|
478
|
+
new = File.expand_path('buildr.rb', home_dir)
|
479
|
+
if File.exist?(old) && !File.exist?(new)
|
480
|
+
warn "Deprecated: Please move buildr.rb from your home directory to the .buildr directory in your home directory"
|
481
|
+
end
|
482
|
+
|
483
|
+
# Load home/.buildr/buildr.rb in preference
|
484
|
+
files = [ File.exist?(new) ? new : old, 'buildr.rb' ].select { |file| File.exist?(file) }
|
485
|
+
files += [ File.expand_path('buildr.rake', ENV['HOME']), File.expand_path('buildr.rake') ].
|
486
|
+
select { |file| File.exist?(file) }.each { |file| warn "Please use '#{file.ext('rb')}' instead of '#{file}'" }
|
487
|
+
files += (options.rakelib || []).collect { |rlib| Dir["#{rlib}/*.rake"] }.flatten
|
488
|
+
|
489
|
+
# Load .buildr/_buildr.rb same directory as buildfile
|
490
|
+
%w{.buildr.rb _buildr.rb}.each do |f|
|
491
|
+
local_buildr = File.expand_path("#{File.dirname(Buildr.application.buildfile.to_s)}/#{f}")
|
492
|
+
files << local_buildr if File.exist?( local_buildr )
|
493
|
+
end
|
494
|
+
|
495
|
+
files.each do |file|
|
496
|
+
unless $LOADED_FEATURES.include?(file)
|
497
|
+
load file
|
498
|
+
$LOADED_FEATURES << file
|
499
|
+
end
|
500
|
+
end
|
501
|
+
buildfile.enhance files
|
502
|
+
true
|
503
|
+
end
|
504
|
+
|
505
|
+
def display_tasks_and_comments
|
506
|
+
displayable_tasks = tasks.select { |t| t.comment && t.name =~ options.show_task_pattern }
|
507
|
+
if options.full_description
|
508
|
+
displayable_tasks.each do |t|
|
509
|
+
puts "buildr #{t.name_with_args}"
|
510
|
+
t.full_comment.split("\n").each do |line|
|
511
|
+
puts " #{line}"
|
512
|
+
end
|
513
|
+
puts
|
514
|
+
end
|
515
|
+
else
|
516
|
+
width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
|
517
|
+
max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
|
518
|
+
displayable_tasks.each do |t|
|
519
|
+
printf "buildr %-#{width}s # %s\n",
|
520
|
+
t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
|
521
|
+
end
|
522
|
+
end
|
523
|
+
end
|
524
|
+
|
525
|
+
def display_prerequisites
|
526
|
+
displayable_tasks = tasks.select { |t| t.name =~ options.show_task_pattern }
|
527
|
+
displayable_tasks.each do |t|
|
528
|
+
puts "buildr #{t.name}"
|
529
|
+
t.prerequisites.each { |pre| puts " #{pre}" }
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
def standard_exception_handling # adds on_failure hook
|
534
|
+
begin
|
535
|
+
yield
|
536
|
+
rescue SystemExit => ex
|
537
|
+
# Exit silently with current status
|
538
|
+
exit(ex.status)
|
539
|
+
rescue OptionParser::ParseError => ex
|
540
|
+
$stderr.puts $terminal.color(ex.message, :red)
|
541
|
+
exit(1)
|
542
|
+
rescue Exception => ex
|
543
|
+
ex_msg = ex.class.name == "Exception" ? ex.message : "#{ex.class.name} : #{ex.message}"
|
544
|
+
title, message = "Your build failed with an error", "#{Dir.pwd}:\n#{ex_msg}"
|
545
|
+
build_failed(title, message, ex)
|
546
|
+
# Exit with error message
|
547
|
+
$stderr.puts "Buildr aborted!"
|
548
|
+
$stderr.puts $terminal.color(ex_msg, :red)
|
549
|
+
if options.trace
|
550
|
+
$stderr.puts ex.backtrace.join("\n")
|
551
|
+
else
|
552
|
+
$stderr.puts ex.backtrace.select { |str| str =~ /#{rakefile}/ }.map { |line| $terminal.color(line, :red) }.join("\n") if rakefile
|
553
|
+
$stderr.puts "(See full trace by running task with --trace)"
|
554
|
+
end
|
555
|
+
exit(1)
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
end
|
560
|
+
|
561
|
+
|
562
|
+
# This task stands for the buildfile and all its associated helper files (e.g., buildr.rb, build.yaml).
|
563
|
+
# By using this task as a prerequisite for other tasks, you can ensure these tasks will be needed
|
564
|
+
# whenever the buildfile changes.
|
565
|
+
class BuildfileTask < Rake::FileTask #:nodoc:
|
566
|
+
|
567
|
+
def timestamp
|
568
|
+
([name] + prerequisites).map { |f| File.stat(f).mtime }.max rescue Time.now
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
|
573
|
+
class << self
|
574
|
+
|
575
|
+
# Returns the Buildr::Application object.
|
576
|
+
def application
|
577
|
+
Rake.application
|
578
|
+
end
|
579
|
+
|
580
|
+
def application=(app) #:nodoc:
|
581
|
+
Rake.application = app
|
582
|
+
end
|
583
|
+
|
584
|
+
# Returns the Settings associated with this build.
|
585
|
+
def settings
|
586
|
+
Buildr.application.settings
|
587
|
+
end
|
588
|
+
|
589
|
+
# Copied from BUILD_ENV.
|
590
|
+
def environment
|
591
|
+
Buildr.application.environment
|
592
|
+
end
|
593
|
+
|
594
|
+
end
|
595
|
+
|
596
|
+
Buildr.application = Buildr::Application.new
|
597
|
+
|
598
|
+
end
|
599
|
+
|
600
|
+
|
601
|
+
# Add a touch of color when available and running in terminal.
|
602
|
+
HighLine.use_color = false
|
603
|
+
if $stdout.isatty
|
604
|
+
begin
|
605
|
+
require 'Win32/Console/ANSI' if Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
|
606
|
+
HighLine.use_color = true
|
607
|
+
rescue LoadError
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
|
612
|
+
alias :warn_without_color :warn
|
613
|
+
|
614
|
+
# Show warning message.
|
615
|
+
def warn(message)
|
616
|
+
warn_without_color $terminal.color(message.to_s, :blue) if verbose
|
617
|
+
end
|
618
|
+
|
619
|
+
# Show error message. Use this when you need to show an error message and not throwing
|
620
|
+
# an exception that will stop the build.
|
621
|
+
def error(message)
|
622
|
+
puts $terminal.color(message.to_s, :red)
|
623
|
+
end
|
624
|
+
|
625
|
+
# Show optional information. The message is printed only when running in verbose
|
626
|
+
# mode (the default).
|
627
|
+
def info(message)
|
628
|
+
puts message if verbose
|
629
|
+
end
|
630
|
+
|
631
|
+
# Show message. The message is printed out only when running in trace mode.
|
632
|
+
def trace(message)
|
633
|
+
puts message if Buildr.application.options.trace
|
634
|
+
end
|
635
|
+
|
636
|
+
def trace?(*category)
|
637
|
+
options = Buildr.application.options
|
638
|
+
return options.trace if category.empty?
|
639
|
+
return true if options.trace_all
|
640
|
+
return false unless Buildr.application.options.trace_categories
|
641
|
+
options.trace_categories.include?(category.first)
|
642
|
+
end
|
643
|
+
|
644
|
+
module Rake #:nodoc
|
645
|
+
# Rake's circular dependency checks (InvocationChain) only applies to task prerequisites,
|
646
|
+
# all other cases result in the non too-descriptive thread sleeping error. This change can
|
647
|
+
# deal with circular dependencies that occur from direct task invocation, e.g:
|
648
|
+
# task 'foo'=>'bar'
|
649
|
+
# task 'bar' do
|
650
|
+
# task('foo').invoke
|
651
|
+
# end
|
652
|
+
class Task #:nodoc:
|
653
|
+
def invoke(*args)
|
654
|
+
task_args = TaskArguments.new(arg_names, args)
|
655
|
+
invoke_with_call_chain(task_args, Thread.current[:rake_chain] || InvocationChain::EMPTY)
|
656
|
+
end
|
657
|
+
|
658
|
+
def invoke_with_call_chain(task_args, invocation_chain)
|
659
|
+
new_chain = InvocationChain.append(self, invocation_chain)
|
660
|
+
@lock.synchronize do
|
661
|
+
if application.options.trace
|
662
|
+
puts "** Invoke #{name} #{format_trace_flags}"
|
663
|
+
end
|
664
|
+
return if @already_invoked
|
665
|
+
@already_invoked = true
|
666
|
+
begin
|
667
|
+
invoke_prerequisites(task_args, new_chain)
|
668
|
+
rescue
|
669
|
+
trace "Exception while invoking prerequisites of task #{self.inspect}"
|
670
|
+
raise
|
671
|
+
end
|
672
|
+
begin
|
673
|
+
old_chain, Thread.current[:rake_chain] = Thread.current[:rake_chain], new_chain
|
674
|
+
execute(task_args) if needed?
|
675
|
+
ensure
|
676
|
+
Thread.current[:rake_chain] = old_chain
|
677
|
+
end
|
678
|
+
end
|
679
|
+
end
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
|
684
|
+
module RakeFileUtils #:nodoc:
|
685
|
+
FileUtils::OPT_TABLE.each do |name, opts|
|
686
|
+
default_options = []
|
687
|
+
if opts.include?(:verbose) || opts.include?("verbose")
|
688
|
+
default_options << ':verbose => RakeFileUtils.verbose_flag == true'
|
689
|
+
end
|
690
|
+
next if default_options.empty?
|
691
|
+
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
692
|
+
def #{name}( *args, &block )
|
693
|
+
super(
|
694
|
+
*rake_merge_option(args,
|
695
|
+
#{default_options.join(', ')}
|
696
|
+
), &block)
|
697
|
+
end
|
698
|
+
EOS
|
699
|
+
end
|
700
|
+
end
|