lib/core/build.rb in buildr-0.22.0 vs lib/core/build.rb in buildr-1.0.0

- old
+ new

@@ -1,6 +1,5 @@ -require "open3" require "core/project" module Buildr desc "Build the project" @@ -18,10 +17,41 @@ [ :build, :clean, :package, :install, :uninstall, :deploy ].each do |name| Project.on_define { |project| project.recursive_task name } 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 + # 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 # :call-seq: # build(*prereqs) => task # build { |task| .. } => task @@ -57,11 +87,11 @@ # make() # # Make a release. def make() check - version = with_next_version { |filename, version| sh "rake deploy --rakefile #{filename}" } + version = with_next_version { |filename, version| sh "rake clean deploy DEBUG=no --rakefile #{filename}" } tag version commit version + "-SNAPSHOT" end protected @@ -173,7 +203,27 @@ end 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