lib/core/build.rb in buildr-1.1.3 vs lib/core/build.rb in buildr-1.2.0
- old
+ new
@@ -1,6 +1,8 @@
require "core/project"
+require "core/common"
+require "core/checks"
module Buildr
desc "Build the project"
Project.local_task("build") { |name| "Building #{name}" }
@@ -10,83 +12,90 @@
Project.local_task("package"=>"build") { |name| "Packaging #{name}" }
desc "Install packages created by the project"
Project.local_task("install"=>"package") { |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"=>"package") { |name| "Deploying packages from #{name}" }
+ desc "Upload packages created by the project"
+ Project.local_task("upload"=>"package") { |name| "Deploying packages from #{name}" }
- [ :build, :clean, :package, :install, :uninstall, :deploy ].each do |name|
+ [ :build, :clean, :package, :install, :uninstall, :upload ].each do |name|
Project.on_define { |project| project.recursive_task name }
end
+ task("deploy"=>"upload") do
+ warn_deprecated "Please use the 'upload' task instead of 'deploy'."
+ end
- # Collection of options for controlling Buildr. For example for running builds without running
- # test cases, or running builds in parallel.
+
class Options
# Runs the build in parallel when true (defaults to false). You can force a parallel build by
# setting this option directly, or by running the parallel task ahead of the build task.
#
# This option only affects recurvise tasks. For example:
- # rake parallel package
+ # buildr parallel package
# will run all package tasks (from the sub-projects) in parallel, but each sub-project's package
# task runs its child tasks (prepare, compile, resources, etc) in sequence.
attr_accessor :parallel
end
- class << self
-
- # :call-seq:
- # options() => Options
- #
- # Returns the Buildr options. See Options.
- def options()
- @options ||= Options.new
- end
-
- end
-
task("parallel") { Buildr.options.parallel = true }
class Project
- # The target directory. By default, it's the target directory inside the project. Various tasks
+ # The target directory. By default, it's the "target" directory inside the project. Various tasks
# use it to determine where to place files, e.g. when compiling or packaging. The clean task
# nukes it.
def target()
@target ||= _("target")
end
def target=(dir)
@target = _(dir)
end
+ # The reports directory. By default, it's the "reports" directory inside the project. Various tasks
+ # use it to determine where to place reports, e.g. when running test cases or code analysis.
+ # The clean task nukes it.
+ def reports()
+ @reports ||= _("reports")
+ end
+
+ def reports=(dir)
+ @reports = _(dir)
+ end
+
# :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
# :call-seq:
- # build(*prereqs) => task
- # build { |task| .. } => task
+ # clean(*prereqs) => task
+ # clean { |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|
- project.clean { verbose(false) { rm_rf project.path_to(:target) } }
+ project.clean do
+ verbose(true) do
+ rm_rf project.path_to(:target)
+ rm_rf project.path_to(:reports)
+ end
+ end
end
desc "The default task it build"
task "default"=>"build"
@@ -102,11 +111,11 @@
# make()
#
# Make a release.
def make()
check
- version = with_next_version { |filename, version| sh "rake clean deploy DEBUG=no --rakefile #{filename}" }
+ version = with_next_version { |filename, version| sh "buildr clean upload DEBUG=no --buildfile #{filename}" }
tag version
commit version + "-SNAPSHOT"
end
protected
@@ -127,13 +136,13 @@
# with_next_version() { |filename| ... } => version
#
# Yields to block with upgraded version number, before committing to use it. Returns the *new*
# current version number.
#
- # We need a Rakefile with upgraded version numbers to run the build, but we don't want the
- # Rakefile modified unless the build succeeds. So this method updates the version numbers in
- # a separate (Rakefile.next) file, yields to the block with that filename, and if successful
+ # We need a Buildfile with upgraded version numbers to run the build, but we don't want the
+ # Buildfile modified unless the build succeeds. So this method updates the version numbers in
+ # a separate (Buildfile.next) file, yields to the block with that filename, and if successful
# copies the new file over the existing one.
#
# Version numbers are updated as follows. The next release version becomes the current one,
# and the next version is upgraded by one to become the new next version. So:
# THIS_VERSION = 1.1.0
@@ -158,23 +167,23 @@
end
File.read(Rake.application.rakefile).scan(THIS_VERSION_PATTERN)[0][1]
end
# :call-seq:
- # change_version() { |this, next| ... } => rakefile
+ # change_version() { |this, next| ... } => buildfile
#
- # Change version numbers in the current Rakefile, but without writing a new file (yet).
- # Returns the contents of the Rakefile with the modified version numbers.
+ # Change version numbers in the current Buildfile, but without writing a new file (yet).
+ # Returns the contents of the Buildfile with the modified version numbers.
#
# This method yields to the block with the current (this) and next version numbers and expects
# an array with the new this and next version numbers.
def change_version()
rakefile = File.read(Rake.application.rakefile)
this_version = rakefile.scan(THIS_VERSION_PATTERN)[0][1] or
- fail "Looking for THIS_VERSION = \"...\" in your Rakefile, none found"
+ fail "Looking for THIS_VERSION = \"...\" in your Buildfile, none found"
next_version = rakefile.scan(NEXT_VERSION_PATTERN)[0][1] or
- fail "Looking for NEXT_VERSION = \"...\" in your Rakefile, none found"
+ fail "Looking for NEXT_VERSION = \"...\" in your Buildfile, none found"
this_version, next_version = yield(this_version, next_version)
if verbose
puts "Upgrading version numbers:"
puts " This: #{this_version}"
puts " Next: #{next_version}"
@@ -220,25 +229,6 @@
desc "Make a release"
task "release" do |task|
Release.make
end
-
- namespace "buildr" do
-
- desc "Freezes the Rakefile so it always uses Buildr version #{Buildr::VERSION}"
- task "freeze" do
- gem = %Q{gem "buildr", "#{Buildr::VERSION}"}
- rakefile = read(Rake.application.rakefile)
- puts "Freezing the Rakefile so it always uses Buildr version #{Buildr::VERSION}"
- write Rake.application.rakefile, rakefile =~ /gem\s*(["'])buildr\1/ ?
- rakefile.sub(/gem\s*(["'])buildr\1\s*,\s*(["']).*\2/, gem) : gem + "\n" + rakefile
- end
-
- desc "Unfreezes the Rakefile to use the latest version of Buildr"
- task "unfreeze" do
- puts "Unfreezing the Rakefile to use the latest version of Buildr from your Gems repository"
- write Rake.application.rakefile, read(Rake.application.rakefile).sub(/^\s*gem\s*(["'])buildr\1.*\n/, "")
- end
-
- end
end