lib/core/build.rb in buildr-0.18.0 vs lib/core/build.rb in buildr-0.19.0
- old
+ new
@@ -1,44 +1,53 @@
require "open3"
+require "core/project"
-
module Buildr
- BUILD_TASKS = {
- :build =>"Build the project",
- :clean =>"Clean files generated during a build",
- :package =>"Create packages",
- :install =>"Install packages created by the project",
- :uninstall=>"Remove previously installed packages",
- :deploy =>"Deploy packages created by the project"
- }
+ desc "Build the project"
+ Project.local_task("build") { |name| "Building #{name}" }
+ desc "Clean files generated during a build"
+ Project.local_task("clean") { |name| "Cleaning #{name}" }
+ desc "Create packages"
+ Project.local_task("package") { |name| "Packaging #{name}" }
+ desc "Install packages created by the project"
+ Project.local_task("install") { |name| "Installing packages from #{name}" }
+ desc "Remove previously installed packages"
+ Project.local_task("uninstall") { |name| "Uninstalling packages from #{name}" }
+ desc "Deploy packages created by the project"
+ Project.local_task("deploy") { |name| "Deploying packages from #{name}" }
- # Handles the build and clean tasks.
- BUILD_TASKS.each { |name, comment| Project.local_task(task(name)).add_comment(comment) }
-
- Project.on_define do |project|
- BUILD_TASKS.each { |name, comment| project.recursive_task name }
+ [ :build, :clean, :package, :install, :uninstall, :deploy ].each do |name|
+ Project.on_define { |project| project.recursive_task name }
end
class Project
- def build(*args, &block)
- task("build").enhance args, &block
+
+ # :call-seq:
+ # build(*prereqs) => task
+ # build { |task| .. } => task
+ #
+ # Returns the project's build task. With arguments or block, also enhances that task.
+ def build(*prereqs, &block)
+ task("build").enhance prereqs, &block
end
- def clean(*args, &block)
- task("clean").enhance args, &block
+ # :call-seq:
+ # build(*prereqs) => task
+ # build { |task| .. } => task
+ #
+ # Returns the project's clean task. With arguments or block, also enhances that task.
+ def clean(*prereqs, &block)
+ task("clean").enhance prereqs, &block
end
- end
- Project.on_define do |project|
- # Make sure these tasks are defined in the project.
- project.build
- project.clean
end
+ desc "The default task it build"
+ task "default"=>"build"
- class Release
+ class Release #:nodoc:
VERSION_NUMBER_PATTERN = /VERSION_NUMBER\s*=\s*(["'])(.*)\1/
NEXT_VERSION_PATTERN = /NEXT_VERSION\s*=\s*(["'])(.*)\1/
class << self
@@ -46,11 +55,11 @@
@ignores = (@ignores || []).map { |pat| pat.is_a?(Regexp) ? pat : Regexp.new("^.*\s+#{Regexp.escape pat}$") }
end
end
def initialize(rakefile = nil)
- @rakefile = rakefile || File.read(Rake.application.rakefile)
+ @rakefile = rakefile || Rake.application.rakefile
end
attr_reader :rakefile
def invoke()
@@ -143,22 +152,22 @@
puts ["svn", *args].join(" ") if options[:verbose]
Open3.popen3("svn", *args) do |stdin, stdout, stderr|
stdin.close
error = stderr.read
fail error unless error.empty?
- returning(stdout.read) { |output| puts output if Rake.application.options.trace }
+ stdout.read.tap { |output| puts output if Rake.application.options.trace }
end
end
end
desc "Make a release"
- task("release").tap do |release|
- class << release
+ task("release").tap do |task|
+ class << task
def release()
@release ||= Release.new
end
end
- release.enhance { release.invoke }
+ task.enhance { task.release.invoke }
end
end