ittayd-buildr 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/CHANGELOG +62 -9
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +20 -39
  5. data/_buildr +1 -0
  6. data/{spec/java/ant.rb → _jbuildr} +11 -15
  7. metadata +30 -210
  8. data/DISCLAIMER +0 -7
  9. data/addon/buildr/antlr.rb +0 -65
  10. data/addon/buildr/cobertura.rb +0 -22
  11. data/addon/buildr/drb.rb +0 -281
  12. data/addon/buildr/emma.rb +0 -22
  13. data/addon/buildr/hibernate.rb +0 -142
  14. data/addon/buildr/javacc.rb +0 -85
  15. data/addon/buildr/jdepend.rb +0 -60
  16. data/addon/buildr/jetty.rb +0 -248
  17. data/addon/buildr/jibx.rb +0 -86
  18. data/addon/buildr/nailgun.rb +0 -221
  19. data/addon/buildr/openjpa.rb +0 -90
  20. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.java +0 -41
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.java +0 -144
  27. data/addon/buildr/path.rb +0 -136
  28. data/addon/buildr/xmlbeans.rb +0 -93
  29. data/buildr.buildfile +0 -53
  30. data/buildr.gemspec +0 -58
  31. data/doc/css/default.css +0 -228
  32. data/doc/css/print.css +0 -100
  33. data/doc/css/syntax.css +0 -52
  34. data/doc/images/apache-incubator-logo.png +0 -0
  35. data/doc/images/buildr-hires.png +0 -0
  36. data/doc/images/buildr.png +0 -0
  37. data/doc/images/favicon.png +0 -0
  38. data/doc/images/growl-icon.tiff +0 -0
  39. data/doc/images/note.png +0 -0
  40. data/doc/images/project-structure.png +0 -0
  41. data/doc/images/tip.png +0 -0
  42. data/doc/images/zbuildr.tif +0 -0
  43. data/doc/pages/artifacts.textile +0 -207
  44. data/doc/pages/building.textile +0 -240
  45. data/doc/pages/contributing.textile +0 -208
  46. data/doc/pages/download.textile +0 -62
  47. data/doc/pages/extending.textile +0 -175
  48. data/doc/pages/getting_started.textile +0 -273
  49. data/doc/pages/index.textile +0 -42
  50. data/doc/pages/languages.textile +0 -407
  51. data/doc/pages/mailing_lists.textile +0 -17
  52. data/doc/pages/more_stuff.textile +0 -314
  53. data/doc/pages/packaging.textile +0 -427
  54. data/doc/pages/projects.textile +0 -274
  55. data/doc/pages/recipes.textile +0 -103
  56. data/doc/pages/settings_profiles.textile +0 -274
  57. data/doc/pages/testing.textile +0 -212
  58. data/doc/pages/troubleshooting.textile +0 -103
  59. data/doc/pages/whats_new.textile +0 -323
  60. data/doc/print.haml +0 -51
  61. data/doc/print.toc.yaml +0 -29
  62. data/doc/scripts/buildr-git.rb +0 -412
  63. data/doc/scripts/install-jruby.sh +0 -44
  64. data/doc/scripts/install-linux.sh +0 -64
  65. data/doc/scripts/install-osx.sh +0 -52
  66. data/doc/site.haml +0 -56
  67. data/doc/site.toc.yaml +0 -47
  68. data/etc/KEYS +0 -151
  69. data/etc/git-svn-authors +0 -16
  70. data/lib/buildr.rb +0 -33
  71. data/lib/buildr/core.rb +0 -29
  72. data/lib/buildr/core/application.rb +0 -665
  73. data/lib/buildr/core/build.rb +0 -311
  74. data/lib/buildr/core/checks.rb +0 -254
  75. data/lib/buildr/core/common.rb +0 -150
  76. data/lib/buildr/core/compile.rb +0 -590
  77. data/lib/buildr/core/environment.rb +0 -117
  78. data/lib/buildr/core/filter.rb +0 -366
  79. data/lib/buildr/core/generate.rb +0 -195
  80. data/lib/buildr/core/help.rb +0 -119
  81. data/lib/buildr/core/osx.rb +0 -49
  82. data/lib/buildr/core/progressbar.rb +0 -156
  83. data/lib/buildr/core/project.rb +0 -923
  84. data/lib/buildr/core/test.rb +0 -715
  85. data/lib/buildr/core/transports.rb +0 -560
  86. data/lib/buildr/core/util.rb +0 -294
  87. data/lib/buildr/groovy.rb +0 -18
  88. data/lib/buildr/groovy/bdd.rb +0 -106
  89. data/lib/buildr/groovy/compiler.rb +0 -138
  90. data/lib/buildr/ide.rb +0 -19
  91. data/lib/buildr/ide/eclipse.rb +0 -222
  92. data/lib/buildr/ide/idea.ipr.template +0 -300
  93. data/lib/buildr/ide/idea.rb +0 -190
  94. data/lib/buildr/ide/idea7x.ipr.template +0 -290
  95. data/lib/buildr/ide/idea7x.rb +0 -212
  96. data/lib/buildr/java.rb +0 -23
  97. data/lib/buildr/java/ant.rb +0 -92
  98. data/lib/buildr/java/bdd.rb +0 -451
  99. data/lib/buildr/java/cobertura.rb +0 -236
  100. data/lib/buildr/java/commands.rb +0 -211
  101. data/lib/buildr/java/compiler.rb +0 -348
  102. data/lib/buildr/java/deprecated.rb +0 -141
  103. data/lib/buildr/java/emma.rb +0 -238
  104. data/lib/buildr/java/jruby.rb +0 -117
  105. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  106. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  107. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
  108. data/lib/buildr/java/packaging.rb +0 -717
  109. data/lib/buildr/java/pom.rb +0 -174
  110. data/lib/buildr/java/rjb.rb +0 -155
  111. data/lib/buildr/java/test_result.rb +0 -307
  112. data/lib/buildr/java/tests.rb +0 -329
  113. data/lib/buildr/java/version_requirement.rb +0 -172
  114. data/lib/buildr/packaging.rb +0 -24
  115. data/lib/buildr/packaging/archive.rb +0 -488
  116. data/lib/buildr/packaging/artifact.rb +0 -759
  117. data/lib/buildr/packaging/artifact_namespace.rb +0 -972
  118. data/lib/buildr/packaging/artifact_search.rb +0 -140
  119. data/lib/buildr/packaging/gems.rb +0 -102
  120. data/lib/buildr/packaging/package.rb +0 -233
  121. data/lib/buildr/packaging/tar.rb +0 -186
  122. data/lib/buildr/packaging/version_requirement.rb +0 -172
  123. data/lib/buildr/packaging/zip.rb +0 -64
  124. data/lib/buildr/packaging/ziptask.rb +0 -313
  125. data/lib/buildr/resources/buildr.icns +0 -0
  126. data/lib/buildr/scala.rb +0 -19
  127. data/lib/buildr/scala/compiler.rb +0 -109
  128. data/lib/buildr/scala/tests.rb +0 -203
  129. data/rakelib/apache.rake +0 -191
  130. data/rakelib/changelog.rake +0 -57
  131. data/rakelib/doc.rake +0 -103
  132. data/rakelib/package.rake +0 -76
  133. data/rakelib/release.rake +0 -65
  134. data/rakelib/rspec.rake +0 -83
  135. data/rakelib/rubyforge.rake +0 -56
  136. data/rakelib/scm.rake +0 -49
  137. data/rakelib/setup.rake +0 -81
  138. data/rakelib/stage.rake +0 -48
  139. data/spec/addon/drb_spec.rb +0 -328
  140. data/spec/core/application_spec.rb +0 -419
  141. data/spec/core/build_spec.rb +0 -423
  142. data/spec/core/checks_spec.rb +0 -519
  143. data/spec/core/common_spec.rb +0 -670
  144. data/spec/core/compile_spec.rb +0 -582
  145. data/spec/core/generate_spec.rb +0 -33
  146. data/spec/core/project_spec.rb +0 -776
  147. data/spec/core/test_spec.rb +0 -1098
  148. data/spec/core/transport_spec.rb +0 -500
  149. data/spec/groovy/bdd_spec.rb +0 -80
  150. data/spec/groovy/compiler_spec.rb +0 -239
  151. data/spec/ide/eclipse_spec.rb +0 -311
  152. data/spec/java/bdd_spec.rb +0 -358
  153. data/spec/java/cobertura_spec.rb +0 -77
  154. data/spec/java/compiler_spec.rb +0 -446
  155. data/spec/java/emma_spec.rb +0 -120
  156. data/spec/java/java_spec.rb +0 -96
  157. data/spec/java/packaging_spec.rb +0 -1120
  158. data/spec/java/test_coverage_spec.rb +0 -255
  159. data/spec/java/tests_spec.rb +0 -471
  160. data/spec/packaging/archive_spec.rb +0 -503
  161. data/spec/packaging/artifact_namespace_spec.rb +0 -646
  162. data/spec/packaging/artifact_spec.rb +0 -795
  163. data/spec/packaging/packaging_helper.rb +0 -63
  164. data/spec/packaging/packaging_spec.rb +0 -589
  165. data/spec/sandbox.rb +0 -139
  166. data/spec/scala/compiler_spec.rb +0 -228
  167. data/spec/scala/tests_spec.rb +0 -215
  168. data/spec/spec_helpers.rb +0 -327
  169. data/spec/version_requirement_spec.rb +0 -123
@@ -1,29 +0,0 @@
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/transports'
28
- require 'buildr/core/generate'
29
- require 'buildr/core/osx' if RUBY_PLATFORM =~ /darwin/
@@ -1,665 +0,0 @@
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'
42
- require 'buildr/core/util'
43
- Gem.autoload :SourceInfoCache, 'rubygems/source_info_cache'
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'] + 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, :verbose=>false unless File.exist?(@home_dir)
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-seq:
191
- # deprecated(message)
192
- #
193
- # Use with deprecated methods and classes. This method automatically adds the file name and line number,
194
- # and the text 'Deprecated' before the message, and eliminated duplicate warnings. It only warns when
195
- # running in verbose mode.
196
- #
197
- # For example:
198
- # deprecated 'Please use new_foo instead of foo.'
199
- def deprecated(message) #:nodoc:
200
- return unless verbose
201
- "#{caller[1]}: Deprecated: #{message}".tap do |message|
202
- @deprecated ||= {}
203
- unless @deprecated[message]
204
- @deprecated[message] = true
205
- warn message
206
- end
207
- end
208
- end
209
-
210
- protected
211
-
212
- def load_buildfile # replaces load_rakefile
213
- standard_exception_handling do
214
- find_buildfile
215
- load_gems
216
- load_artifact_ns
217
- load_tasks
218
- raw_load_buildfile
219
- end
220
- end
221
-
222
- def top_level # adds on_completion hook
223
- standard_exception_handling do
224
- if options.show_tasks
225
- display_tasks_and_comments
226
- elsif options.show_prereqs
227
- display_prerequisites
228
- elsif options.execute
229
- eval options.execute
230
- else
231
- @start = Time.now
232
- top_level_tasks.each { |task_name| invoke_task(task_name) }
233
- if verbose
234
- elapsed = Time.now - @start
235
- real = []
236
- real << ('%ih' % (elapsed / 3600)) if elapsed >= 3600
237
- real << ('%im' % ((elapsed / 60) % 60)) if elapsed >= 60
238
- real << ('%.3fs' % (elapsed % 60))
239
- puts $terminal.color("Completed in #{real.join}", :green)
240
- end
241
- # On OS X this will load Cocoa and Growl which takes half a second we
242
- # don't want to measure, so put this after the console message.
243
- title, message = "Your build has completed", "#{Dir.pwd}\nbuildr #{@top_level_tasks.join(' ')}"
244
- @on_completion.each do |block|
245
- block.call(title, message) rescue nil
246
- end
247
- end
248
- end
249
- end
250
-
251
- def handle_options
252
- options.rakelib = ['tasks']
253
-
254
- opts = OptionParser.new
255
- opts.banner = "buildr [-f rakefile] {options} targets..."
256
- opts.separator ""
257
- opts.separator "Options are ..."
258
-
259
- argv = ARGV.dup
260
- while idx = argv.index('--require-early')
261
- raise "missing argument: --require-early" unless val = argv[idx+1]
262
- argv[idx,2] = []
263
- require val
264
- end
265
-
266
- opts.on_tail("-h", "--help", "-H", "Display this help message.") do
267
- puts opts
268
- exit
269
- end
270
- standard_buildr_options.each { |args| opts.on(*args) }
271
- parsed_argv = opts.parse(argv)
272
- parsed_argv
273
- end
274
-
275
- def standard_buildr_options # replaces standard_rake_options
276
- [
277
- ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.",
278
- lambda { |value|
279
- options.show_tasks = true
280
- options.full_description = true
281
- options.show_task_pattern = Regexp.new(value || '')
282
- }
283
- ],
284
- ['--execute', '-E CODE',
285
- "Execute some Ruby code after loading the buildfile",
286
- lambda { |value| options.execute = value }
287
- ],
288
- ['--environment', '-e ENV',
289
- "Environment name (e.g. development, test, production).",
290
- lambda { |value| ENV['BUILDR_ENV'] = value }
291
- ],
292
- ['--generate [PATH]',
293
- "Generate buildfile from either pom.xml file or directory path.",
294
- lambda { |value|
295
- value ||= File.exist?('pom.xml') ? 'pom.xml' : Dir.pwd
296
- raw_generate_buildfile value
297
- exit
298
- }
299
- ],
300
- ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
301
- lambda { |value| $:.push(value) }
302
- ],
303
- ['--prereqs', '-P [PATTERN]', "Display the tasks and dependencies (matching optional PATTERN), then exit.",
304
- lambda { |value|
305
- options.show_prereqs = true
306
- options.show_task_pattern = Regexp.new(value || '')
307
- }
308
- ],
309
- ['--quiet', '-q', "Do not log messages to standard output.",
310
- lambda { |value| verbose(false) }
311
- ],
312
- ['--buildfile', '-f FILE', "Use FILE as the buildfile.",
313
- lambda { |value|
314
- @rakefiles.clear
315
- @rakefiles << value
316
- }
317
- ],
318
- ['--rakelibdir', '--rakelib', '-R PATH',
319
- "Auto-import any .rake files in PATH. (default is 'tasks')",
320
- lambda { |value| options.rakelib = value.split(':') }
321
- ],
322
- ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
323
- lambda { |value|
324
- begin
325
- require value
326
- rescue LoadError => ex
327
- begin
328
- rake_require value
329
- rescue LoadError => ex2
330
- raise ex
331
- end
332
- end
333
- }
334
- ],
335
- ['--require-early MODULE', "Require module early"],
336
- ['--rules', "Trace the rules resolution.",
337
- lambda { |value| options.trace_rules = true }
338
- ],
339
- ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
340
- lambda { |value| options.nosearch = true }
341
- ],
342
- ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
343
- lambda { |value|
344
- verbose(false)
345
- options.silent = true
346
- }
347
- ],
348
- ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.",
349
- lambda { |value|
350
- options.show_tasks = true
351
- options.show_task_pattern = Regexp.new(value || '')
352
- options.full_description = false
353
- }
354
- ],
355
- ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
356
- lambda { |value|
357
- options.trace = true
358
- verbose(true)
359
- }
360
- ],
361
- ['--verbose', '-v', "Log message to standard output (default).",
362
- lambda { |value| verbose(true) }
363
- ],
364
- ['--version', '-V', "Display the program version.",
365
- lambda { |value|
366
- puts "Buildr #{Buildr::VERSION} #{RUBY_PLATFORM[/java/] && '(JRuby '+JRUBY_VERSION+')'}"
367
- exit
368
- }
369
- ]
370
- ]
371
- end
372
-
373
- def find_buildfile
374
- buildfile, location = find_rakefile_location || (tty_output? && ask_generate_buildfile)
375
- fail "No Buildfile found (looking for: #{@rakefiles.join(', ')})" if buildfile.nil?
376
- @rakefile = buildfile
377
- Dir.chdir(location)
378
- end
379
-
380
- def ask_generate_buildfile
381
- source = choose do |menu|
382
- menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
383
- menu.choice("From Maven2 POM file") { 'pom.xml' } if File.exist?('pom.xml')
384
- menu.choice("From directory structure") { Dir.pwd }
385
- menu.choice("Cancel") { }
386
- end
387
- if source
388
- buildfile = raw_generate_buildfile(source)
389
- [buildfile, File.dirname(buildfile)]
390
- end
391
- end
392
-
393
- def raw_generate_buildfile(source)
394
- # We need rakefile to be known, for settings.build to be accessible.
395
- @rakefile = File.expand_path(DEFAULT_BUILDFILES.first)
396
- fail "Buildfile already exists" if File.exist?(@rakefile) && !(tty_output? && agree('Buildfile exists, overwrite?'))
397
- script = File.directory?(source) ? Generate.from_directory(source) : Generate.from_maven2_pom(source)
398
- File.open @rakefile, 'w' do |file|
399
- file.puts script
400
- end
401
- puts "Created #{@rakefile}" if verbose
402
- @rakefile
403
- end
404
-
405
- def raw_load_buildfile # replaces raw_load_rakefile
406
- puts "(in #{Dir.pwd}, #{environment})" unless options.silent
407
- load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
408
- options.rakelib.each do |rlib|
409
- glob("#{rlib}/*.rake") do |name|
410
- add_import name
411
- end
412
- end
413
- load_imports
414
- initialize_projects
415
- end
416
-
417
- def initialize_projects
418
- top_level_tasks.each do |task_name|
419
- projects = task_name.split(':').inject([]) { |projects, part| projects << (projects.last.to_a + [part]) }.reverse
420
- projects.each do |project|
421
- name = project.join(':')
422
- begin
423
- break if Buildr.project(name)
424
- rescue Project::NoSuchProject => detail
425
- raise unless detail.name == name
426
- end
427
- end
428
- end
429
- end
430
-
431
- # Load/install all Gems specified in build.yaml file.
432
- def load_gems #:nodoc:
433
- missing_deps, installed = listed_gems.partition { |gem| gem.is_a?(Gem::Dependency) }
434
- unless missing_deps.empty?
435
- newly_installed = Util::Gems.install(*missing_deps)
436
- installed += newly_installed
437
- end
438
- installed.each do |spec|
439
- if gem(spec.name, spec.version.to_s)
440
- # TODO: is this intended to load rake tasks from the installed gems?
441
- # We should use a convention like .. if the gem has a _buildr.rb file, load it.
442
-
443
- #FileList[spec.require_paths.map { |path| File.expand_path("#{path}/*.rb", spec.full_gem_path) }].
444
- # map { |path| File.basename(path) }.each { |file| require file }
445
- #FileList[File.expand_path('tasks/*.rake', spec.full_gem_path)].each do |file|
446
- # Buildr.application.add_import file
447
- #end
448
- end
449
- end
450
- @gems = installed
451
- end
452
-
453
- # Returns Gem::Specification for every listed and installed Gem, Gem::Dependency
454
- # for listed and uninstalled Gem, which is the installed before loading the buildfile.
455
- def listed_gems #:nodoc:
456
- Array(settings.build['gems']).map do |dep|
457
- name, trail = dep.scan(/^\s*(\S*)\s*(.*)\s*$/).first
458
- versions = trail.scan(/[=><~!]{0,2}\s*[\d\.]+/)
459
- versions = ['>= 0'] if versions.empty?
460
- dep = Gem::Dependency.new(name, versions)
461
- Gem::SourceIndex.from_installed_gems.search(dep).last || dep
462
- end
463
- end
464
-
465
- # Load artifact specs from the build.yaml file, making them available
466
- # by name ( ruby symbols ).
467
- def load_artifact_ns #:nodoc:
468
- hash = settings.build['artifacts']
469
- return unless hash
470
- raise "Expected 'artifacts' element to be a hash" unless Hash === hash
471
- # Currently we only use one artifact namespace to rule them all. (the root NS)
472
- Buildr::ArtifactNamespace.load(:root => hash)
473
- end
474
-
475
- # Loads buildr.rb files from users home directory and project directory.
476
- # Loads custom tasks from .rake files in tasks directory.
477
- def load_tasks #:nodoc:
478
- # TODO: this might need to be split up, look for deprecated features, better method name.
479
- files = [ File.expand_path('buildr.rb', ENV['HOME']), 'buildr.rb' ].select { |file| File.exist?(file) }
480
- files += [ File.expand_path('buildr.rake', ENV['HOME']), File.expand_path('buildr.rake') ].
481
- select { |file| File.exist?(file) }.each { |file| warn "Please use '#{file.ext('rb')}' instead of '#{file}'" }
482
- #Load local tasks that can be used in the Buildfile.
483
- files += Dir[File.expand_path('tasks/*.rake')]
484
- files.each do |file|
485
- unless $LOADED_FEATURES.include?(file)
486
- load file
487
- $LOADED_FEATURES << file
488
- end
489
- end
490
- buildfile.enhance files
491
- true
492
- end
493
-
494
- def display_tasks_and_comments
495
- displayable_tasks = tasks.select { |t| t.comment && t.name =~ options.show_task_pattern }
496
- if options.full_description
497
- displayable_tasks.each do |t|
498
- puts "buildr #{t.name_with_args}"
499
- t.full_comment.split("\n").each do |line|
500
- puts " #{line}"
501
- end
502
- puts
503
- end
504
- else
505
- width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
506
- max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
507
- displayable_tasks.each do |t|
508
- printf "#{name} %-#{width}s # %s\n",
509
- t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
510
- end
511
- end
512
- end
513
-
514
- def display_prerequisites
515
- displayable_tasks = tasks.select { |t| t.name =~ options.show_task_pattern }
516
- displayable_tasks.each do |t|
517
- puts "buildr #{t.name}"
518
- t.prerequisites.each { |pre| puts " #{pre}" }
519
- end
520
- end
521
-
522
- def standard_exception_handling # adds on_failure hook
523
- begin
524
- yield
525
- rescue SystemExit => ex
526
- # Exit silently with current status
527
- exit(ex.status)
528
- rescue OptionParser::ParseError => ex
529
- $stderr.puts $terminal.color(ex.message, :red)
530
- exit(1)
531
- rescue Exception => ex
532
- title, message = "Your build failed with an error", "#{Dir.pwd}:\n#{ex.message}"
533
- @on_failure.each do |block|
534
- block.call(title, message, ex) rescue nil
535
- end
536
- # Exit with error message
537
- $stderr.puts "Buildr aborted!"
538
- $stderr.puts $terminal.color(ex.message, :red)
539
- if options.trace
540
- $stderr.puts ex.backtrace.join("\n")
541
- else
542
- $stderr.puts ex.backtrace.select { |str| str =~ /#{rakefile}/ }.map { |line| $terminal.color(line, :red) }.join("\n") if rakefile
543
- $stderr.puts "(See full trace by running task with --trace)"
544
- end
545
- exit(1)
546
- end
547
- end
548
-
549
- end
550
-
551
-
552
- # This task stands for the buildfile and all its associated helper files (e.g., buildr.rb, build.yaml).
553
- # By using this task as a prerequisite for other tasks, you can ensure these tasks will be needed
554
- # whenever the buildfile changes.
555
- class BuildfileTask < Rake::FileTask
556
-
557
- def timestamp
558
- ([name] + prerequisites).map { |f| File.stat(f).mtime }.max rescue Time.now
559
- end
560
- end
561
-
562
-
563
- class << self
564
-
565
- # Returns the Buildr::Application object.
566
- def application
567
- Rake.application
568
- end
569
-
570
- def application=(app) #:nodoc:
571
- Rake.application = app
572
- end
573
-
574
- # Returns the Settings associated with this build.
575
- def settings
576
- Buildr.application.settings
577
- end
578
-
579
- # Copied from BUILD_ENV.
580
- def environment
581
- Buildr.application.environment
582
- end
583
-
584
- end
585
-
586
- Buildr.application = Buildr::Application.new
587
-
588
- end
589
-
590
-
591
- # Add a touch of color when available and running in terminal.
592
- if $stdout.isatty
593
- begin
594
- require 'Win32/Console/ANSI' if Config::CONFIG['host_os'] =~ /mswin/
595
- HighLine.use_color = true
596
- rescue LoadError
597
- end
598
- else
599
- HighLine.use_color = false
600
- end
601
-
602
-
603
- alias :warn_without_color :warn
604
-
605
- # Show warning message.
606
- def warn(message)
607
- warn_without_color $terminal.color(message.to_s, :blue) if verbose
608
- end
609
-
610
- # Show error message. Use this when you need to show an error message and not throwing
611
- # an exception that will stop the build.
612
- def error(message)
613
- puts $terminal.color(message.to_s, :red)
614
- end
615
-
616
- # Show optional information. The message is printed only when running in verbose
617
- # mode (the default).
618
- def info(message)
619
- puts message if verbose
620
- end
621
-
622
- # Show message. The message is printed out only when running in trace mode.
623
- def trace(message)
624
- puts message if Buildr.application.options.trace
625
- end
626
-
627
-
628
- module Rake #:nodoc
629
- # Rake's circular dependency checks (InvocationChain) only applies to task prerequisites,
630
- # all other cases result in the non too-descriptive thread sleeping error. This change can
631
- # deal with circular dependencies that occur from direct task invocation, e.g:
632
- # task 'foo'=>'bar'
633
- # task 'bar' do
634
- # task('foo').invoke
635
- # end
636
- class Task #:nodoc:
637
- def invoke(*args)
638
- task_args = TaskArguments.new(arg_names, args)
639
- invoke_with_call_chain(task_args, Thread.current[:rake_chain] || InvocationChain::EMPTY)
640
- end
641
-
642
- def invoke_with_call_chain(task_args, invocation_chain)
643
- new_chain = InvocationChain.append(self, invocation_chain)
644
- @lock.synchronize do
645
- if application.options.trace
646
- puts "** Invoke #{name} #{format_trace_flags}"
647
- end
648
- return if @already_invoked
649
- @already_invoked = true
650
- begin
651
- invoke_prerequisites(task_args, new_chain)
652
- rescue
653
- trace "Exception while invoking prerequisites of task #{self.inspect}"
654
- raise
655
- end
656
- begin
657
- old_chain, Thread.current[:rake_chain] = Thread.current[:rake_chain], new_chain
658
- execute(task_args) if needed?
659
- ensure
660
- Thread.current[:rake_chain] = nil
661
- end
662
- end
663
- end
664
- end
665
- end