Author: assaf
Date: Fri Apr 25 00:59:03 2008
New Revision: 651522

URL: http://svn.apache.org/viewvc?rev=651522&view=rev
Log:
Separating release process into staging and releasing

Added:
    incubator/buildr/trunk/rakelib/changelog.rake
    incubator/buildr/trunk/rakelib/rubyforge.rake
    incubator/buildr/trunk/rakelib/scm.rake
    incubator/buildr/trunk/rakelib/stage.rake
Modified:
    incubator/buildr/trunk/CHANGELOG
    incubator/buildr/trunk/Rakefile
    incubator/buildr/trunk/doc/scripts/buildr-git.rb
    incubator/buildr/trunk/rakelib/apache.rake
    incubator/buildr/trunk/rakelib/doc.rake
    incubator/buildr/trunk/rakelib/package.rake
    incubator/buildr/trunk/rakelib/release.rake
    incubator/buildr/trunk/rakelib/rspec.rake

Modified: incubator/buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/CHANGELOG?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/CHANGELOG (original)
+++ incubator/buildr/trunk/CHANGELOG Fri Apr 25 00:59:03 2008
@@ -1,4 +1,4 @@
-1.3.0 (Pending) 
+1.3.0 (2008-04-25)
 * Added: Testing with EasyB (Nicolas Modrzyk).
 * Added: Testing with JBehave (John Layton).
 * Added: Testing with RSpec (Nick Sieger).

Modified: incubator/buildr/trunk/Rakefile
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Fri Apr 25 00:59:03 2008
@@ -64,30 +64,31 @@
 end
 
 
-$license_excluded = ['spec/spec.opts', '.textile', '.haml']
-
-
 desc 'Compile Java libraries used by Buildr'
 task 'compile' do
   puts 'Compiling Java libraries ...'
   sh Config::CONFIG['ruby_install_name'], '-Ilib', '-Iaddon', 'bin/buildr', 
'compile'
   puts 'OK'
 end
+file Rake::GemPackageTask.new(spec).package_dir=>'compile'
+file Rake::GemPackageTask.new(spec).package_dir_path=>'compile'
 
-Rake::GemPackageTask.new(spec('ruby')) do |pkg|
-  pkg.need_tar = pkg.need_zip = true
-  file pkg.package_dir_path=>'compile'
-  file pkg.package_dir=>'compile'
-end
-Rake::GemPackageTask.new(spec('java')) do |pkg|
-  file pkg.package_dir_path=>'compile'
+# We also need the other package (JRuby if building on Ruby, and vice versa)
+Rake::GemPackageTask.new spec(RUBY_PLATFORM =~ /java/ ? 'ruby' : 'java') do 
|task|
+  # Block necessary otherwise doesn't do full job.
 end
 
-namespace 'release' do
 
-  task 'make' do
-    task('rubyforge').invoke
-    task('apache:upload').invoke('buildr', true)
-  end
+ENV['staging'] = "people.apache.org:~/public_html/#{spec.name}-#{spec.version}"
 
+task 'apache:license'=>spec.files
+# TODO: Switch fully to our own coloring scheme.
+task('apache:license').prerequisites.exclude('doc/css/syntax.css')
+
+task 'spec:check' do
+  print 'Checking that we have JRuby, Scala and Groovy available ... '
+  fail 'Full testing requires JRuby!' unless which('jruby')
+  fail 'Full testing requires Scala!' unless which('scala')
+  fail 'Full testing requires Groovy!' unless which('groovy')
+  puts 'OK'
 end

Modified: incubator/buildr/trunk/doc/scripts/buildr-git.rb
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/doc/scripts/buildr-git.rb?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/doc/scripts/buildr-git.rb (original)
+++ incubator/buildr/trunk/doc/scripts/buildr-git.rb Fri Apr 25 00:59:03 2008
@@ -1,3 +1,20 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
 # This script helps buildr developers to obtain their own git clone from
 # github, having a set of pre-defined aliases to work with Apache's SVN.
 #

Modified: incubator/buildr/trunk/rakelib/apache.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/apache.rake?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/rakelib/apache.rake (original)
+++ incubator/buildr/trunk/rakelib/apache.rake Fri Apr 25 00:59:03 2008
@@ -22,10 +22,9 @@
 namespace 'apache' do
 
   desc 'Check that source files contain the Apache license'
-  task 'license' do
+  task 'license' do |task|
     print 'Checking that files contain the Apache license ... '
-    excluded = ['.class', '.png', '.jar', '.tif', 'README', 'LICENSE', 
'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'KEYS']
-    required = 
FileList[spec.files].exclude(*excluded).exclude(*Array($license_excluded)).select
 { |fn| File.file?(fn) }
+    required = task.prerequisites.select { |fn| File.file?(fn) }
     missing = required.reject { |fn| 
       comments = 
File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|<!--(.*?)-->/m).
         map { |match| match.compact }.flatten.join("\n")
@@ -34,57 +33,62 @@
     fail "#{missing.join(', ')} missing Apache License, please add it before 
making a release!" unless missing.empty?
     puts 'OK'
   end
+  task('license').prerequisites.exclude('.class', '.png', '.jar', '.tif', 
'.textile', '.haml',
+    'README', 'LICENSE', 'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'KEYS', 
'spec/spec.opts')
 
-  file 'incubating'=>'package' do
-    rm_rf 'incubating'
-    mkpath 'incubating'
-    print 'Creating -incubating packages ... '
-    packages = FileList['pkg/*.{gem,zip,tgz}'].map do |package|
-      package.pathmap('incubating/%n-incubating%x').tap do |incubating|
-        cp package, incubating
-      end
-    end
-    puts 'Done'
+  task 'check' do
+    ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment 
variable so we know which key to use.'
   end
 
-  task 'sign', :incubating do |task, args|
-    file('incubating').invoke if args.incubating
-    sources = FileList[args.incubating ? 'incubating/*' : 'pkg/*']
 
+  file 'staged/distro'=>'package' do
+    puts 'Copying and signing release files ...'
+    mkpath 'staged/distro'
+    FileList['pkg/*.{gem,zip,tgz}'].each do |pkg|
+      cp pkg, pkg.pathmap('staged/distro/%n-incubating%x') 
+    end
+  end
+
+  task 'sign'=>['KEYS', 'staged/distro'] do
     gpg_user = ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) 
environment variable so we know which key to use.'
-    print 'Signing release files ...'
-    sources.each do |fn|
-      contents = File.open(fn, 'rb') { |file| file.read }
-      File.open(fn + '.md5', 'w') { |file| file.write MD5.hexdigest(contents) 
<< ' ' << File.basename(fn) }
-      File.open(fn + '.sha1', 'w') { |file| file.write 
SHA1.hexdigest(contents) << ' ' << File.basename(fn) }
-      sh 'gpg', '--local-user', gpg_user, '--armor', '--output', fn + '.asc', 
'--detach-sig', fn, :verbose=>true
+    FileList['staged/distro/*.{gem,zip,tgz}'].each do |pkg|
+      bytes = File.open(pkg, 'rb') { |file| file.read }
+      File.open(pkg + '.md5', 'w') { |file| file.write MD5.hexdigest(bytes) << 
' ' << File.basename(pkg) }
+      File.open(pkg + '.sha1', 'w') { |file| file.write SHA1.hexdigest(bytes) 
<< ' ' << File.basename(pkg) }
+      sh 'gpg', '--local-user', gpg_user, '--armor', '--output', pkg + '.asc', 
'--detach-sig', pkg, :verbose=>true
     end
+    cp 'KEYS', 'staged/distro'
+  end
+
+  # Publish prerequisites to distro server.
+  task 'publish:distro' do |task, args|
+    target = args.incubating ? 
"people.apache.org:/www/www.apache.org/dist/incubator/#{spec.name}" :
+      "people.apache.org:/www/www.apache.org/dist/#{spec.name}"
+      "people.apache.org:/www/#{spec.name}.apache.org"
+    puts 'Uploading packages to Apache distro ...'
+    sh 'rsync', '--progress', 'published/distro/*', target
     puts 'Done'
   end
 
-  task 'upload', :project, :incubating, :depends=>['site', 'KEYS', 'sign'] do 
|task, args|
-    fail 'No project specified' unless project
 
-    target = 'people.apache.org:/www.apache.org/dist/'
-    target << 'incubator/' if args.incubating
-    target << "#{project}/"
-
-    dir = task('sign').prerequisite.find { |prereq| 
File.directory?(prereq.name) }
-    fail 'Please enhance sign task with directory containing files to release' 
unless dir
-    puts 'Uploading packages to Apache dist ...'
-    args = FileList["#{dir}/*", 'KEYS'].flatten << target
-    
-    sh 'rsync', '-progress', *args
+  file 'staged/site'=>'site' do
+    mkpath 'staged'
+    rm_rf 'staged/site'
+    cp_r 'site', 'staged'
+  end
+
+  # Publish prerequisites to Web site.
+  task 'publish:site' do |task, args|
+    target = args.incubating ? 
"people.apache.org:/www/incubator.apache.org/#{spec.name}" :
+      "people.apache.org:/www/#{spec.name}.apache.org"
+    puts 'Uploading Apache Web site ...'
+    sh 'rsync', '--progress', 'published/distro/site/', target
     puts 'Done'
   end
 
 end
 
 
-task 'clobber' do
-  rm_rf 'incubating'
-end
-
-namespace 'release' do
-  task 'check'=>'apache:license'
-end
+task 'stage:check'=>['apache:license', 'apache:check']
+task 'stage:prepare'=>['staged/distro', 'apache:sign', 'staged/site']
+task 'release:publish'=>['apache:publish:distro', 'apache:publish:site']

Added: incubator/buildr/trunk/rakelib/changelog.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/changelog.rake?rev=651522&view=auto
==============================================================================
--- incubator/buildr/trunk/rakelib/changelog.rake (added)
+++ incubator/buildr/trunk/rakelib/changelog.rake Fri Apr 25 00:59:03 2008
@@ -0,0 +1,55 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+# Handling of CHANGELOG.
+namespace 'changelog' do
+
+  task 'check'=>'CHANGELOG' do
+    print 'Checking that CHANGELOG indicates most recent version and today\'s 
date ... '
+    expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
+    header = File.readlines('CHANGELOG').first.chomp
+    fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} 
instead" unless expecting == header
+    puts 'OK'
+  end
+
+  task 'prepare'=>'CHANGELOG' do
+    # Read the changes for this release.
+    print 'Looking for changes between this release and previous one ... '
+    pattern = 
/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
+    changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| 
hash[set[1]] = set[2] ; hash }
+    current = changes[spec.version.to_s]
+    fail "No changeset found for version #{spec.version}" unless current
+    File.open 'stage/CHANGES', 'w' do |file|
+      file.write current
+    end
+    puts 'OK'
+  end
+
+  task 'wrapup'=>'CHANGELOG' do
+    next_version = spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { 
|t,i| t + i } }.join('.')
+    print 'Adding new entry to CHANGELOG ... '
+    modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
+    File.open 'CHANGELOG', 'w' do |file|
+      file.write modified
+    end
+    puts 'Done'
+  end
+
+end
+
+task 'stage:check'=>'changelog:check'
+task 'stage:prepare'=>'changelog:prepare'
+task 'release:wrapup'=>'changelog:wrapup'

Modified: incubator/buildr/trunk/rakelib/doc.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/doc.rake?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/rakelib/doc.rake (original)
+++ incubator/buildr/trunk/rakelib/doc.rake Fri Apr 25 00:59:03 2008
@@ -44,15 +44,14 @@
   require 'docter'
   require 'docter/server'
 
-  file 'reports/specs.html'=>'reports'
-
   #Docter.filter_for(:footnote) do |html|
   #  html.gsub(/<p id="fn(\d+)">(.*?)<\/p>/, %{<p id="fn\\1" 
class="footnote">\\2</p>})
   #end
 
   collection = 
Docter.collection(spec.name).using('doc/site.toc.yaml').include('doc/pages', 
'LICENSE', 'CHANGELOG')
+  # TODO:  Add coverage reports when we get them to run.
   template   = Docter.template('doc/site.haml').
-    include('doc/css', 'doc/images', 'doc/scripts', 'reports/specs.html', 
'reports/coverage', 'rdoc', 'print/buildr.pdf')
+    include('doc/css', 'doc/images', 'doc/scripts', 'reports/specs.html', 
'rdoc', 'print/buildr.pdf')
 
   desc 'Run Docter server on port 3000'
   Docter::Rake.serve 'docter', collection, template, :port=>3000
@@ -64,16 +63,19 @@
     
Docter.collection(spec.name).using('doc/print.toc.yaml').include('doc/pages', 
'LICENSE'),
     Docter.template('doc/print.haml').include('doc/css', 'doc/images'), 
:one_page
 
-  file('site/buildr.pdf'=>'print') do |task|
+  file('print/buildr.pdf'=>'print') do |task|
     mkpath 'site'
     sh 'prince', 'print/index.html', '-o', task.name, '--media=print' do |ok, 
res|
       fail 'Failed to create PDF, see errors above' unless ok
     end
   end
+  task 'site'=>'print/buildr.pdf' do
+    cp 'print/buildr.pdf', 'site'
+  end
 
   desc 'Produce PDF'
-  task 'pdf'=>'site/buildr.pdf' do |task|
-    sh 'open', 'site/buildr.pdf'
+  task 'pdf'=>'print/buildr.pdf' do |task|
+    sh 'open', 'print/buildr.pdf'
   end
 
   task 'clobber' do
@@ -81,6 +83,21 @@
     rm_rf 'site'
   end
 
+  task 'site:prepare'=>'site' do
+    print 'Checking that we have site documentation, RDoc and PDF ... '
+    fail 'No PDF generated, you need to install PrinceXML!' unless 
File.exist?('site/buildr.pdf')
+    fail 'No RDocs in site directory' unless 
File.exist?('site/rdoc/files/lib/buildr_rb.html')
+    fail 'No site documentation in site directory' unless 
File.exist?('site/index.html')
+    fail 'No specifications site directory' unless 
File.exist?('site/specs.html')
+    puts 'OK'
+  end
+
+  task 'site:stage' do
+    puts 'Copying site over to release directory ...'
+    cp_r 'site', 'release'
+    puts 'Done'
+  end
+
 rescue LoadError
   puts 'Please run rake setup to install the Docter document generation 
library'
   task 'setup' do
@@ -92,12 +109,5 @@
 end
 
 
-namespace 'release' do
-  task 'prepare'=>'docs' do
-    print 'Checking that we have site documentation, RDoc and PDF ... '
-    fail 'No PDF generated, you need to install PrinceXML!' unless 
File.exist?('site/buildr.pdf')
-    fail 'No RDocs in site directory' unless 
File.exist?('site/rdoc/files/lib/buildr_rb.html')
-    fail 'No site documentation in site directory' unless 
File.exist?('site/index.html')
-    puts 'OK'
-  end
-end
+task 'release:prepare'=>'site:prepare'
+task 'release:stage'=>'site:stage'

Modified: incubator/buildr/trunk/rakelib/package.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/package.rake?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/rakelib/package.rake (original)
+++ incubator/buildr/trunk/rakelib/package.rake Fri Apr 25 00:59:03 2008
@@ -20,15 +20,15 @@
 desc 'Clean up all temporary directories used for running tests, creating 
documentation, packaging, etc.'
 task 'clobber'
 
-Rake::GemPackageTask.new(spec) do |pkg|
-  pkg.need_tar = pkg.need_zip = true
+package = Rake::GemPackageTask.new(spec) do |pkg|
+  pkg.need_tar = true
+  pkg.need_zip = true
 end
 
-current = Rake::GemPackageTask.new(spec)
 desc 'Install the package locally'
-task 'install'=>"#{current.package_dir}/#{current.gem_file}" do |task|
+task 'install'=>"#{package.package_dir}/#{package.gem_file}" do |task|
   print "Installing #{spec.name} ... "
-  args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', 
"#{current.package_dir}/#{current.gem_file}"]
+  args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', 
"#{package.package_dir}/#{package.gem_file}"]
   args.unshift('sudo') unless windows?
   sh *args
   puts 'Done'

Modified: incubator/buildr/trunk/rakelib/release.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/release.rake?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/rakelib/release.rake (original)
+++ incubator/buildr/trunk/rakelib/release.rake Fri Apr 25 00:59:03 2008
@@ -13,121 +13,43 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-
-begin
-  require 'rubyforge'
-rescue LoadError
-  puts 'Please run rake setup to install the RubyForge gem'
-  task 'setup' do
-    install_gem 'rubyforge'
-  end
-  task 'release:check' do
-    fail 'Please run rake setup to install the RubyForge gem'
-  end
+# Released files are placed in this directory first, and from there published 
to various servers.
+file 'published' do |task, args|
+  mkpath task.name
+  puts "Populating published directory from #{args.staging} ..."
+  sh 'rsync', '--progress', "#{args.staging}/", 'published'
+  puts 'Done'
 end
 
+task 'clobber' do
+  rm_rf 'published'
+end
 
 namespace 'release' do
- 
-  # This task does all prerequisites checks before starting the release, for 
example,
-  # that we have Groovy and Scala to run all the test cases, or that we have 
Allison
-  # and PrinceXML to generate the full documentation.
-  task 'check'=>'setup'
-  # This task does all the preparation work before making a release and also 
checks
-  # that we generate all the right material, for example, that we compiled 
Java sources,
-  # created the PDF, have coverage report.
-  task 'prepare'=>['clobber', 'check']
-
-  # Does CHANGELOG reflects current release?
-  task 'check' do
-    print 'Checking that CHANGELOG indicates most recent version and today\'s 
date ... '
-    expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
-    header = File.readlines('CHANGELOG').first.chomp
-    fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} 
instead" unless expecting == header
-    puts 'OK'
-  end
+  #task 'prepare'=>['setup', 'clobber', 'published'] # TODO: uncomment
+  task 'prepare'=>'published'
 
-  # No local changes.
-  task 'check' do
-    print 'Checking there are no local changes ... '
-    status = `svn status`
-    fail "Cannot release unless all local changes are in SVN:\n#{status}" 
unless status.empty?
-    fail "Cannot release unless all local changes are in Git:\n" + `git 
status` if `git status`[/^#\t/]
-    puts 'OK'
-  end
+  task 'publish'
 
-  desc 'Make a release'
-  task 'make'=>'release:prepare' do |task|
-    task.enhance do
-      task('release:wrapup').invoke
-    end
-  end
+  task 'wrapup'
+end
 
-  task 'rubyforge'=>'package' do
-    if File.exist?('CHANGELOG')
-      # Read the changes for this release.
-      print 'Looking for changes between this release and previous one ... '
-      pattern = 
/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
-      changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| 
hash[set[1]] = set[2] ; hash }
-      current = changes[spec.version.to_s]
-      current = changes[spec.version.to_s.split('.')[0..-2].join('.')] if 
!current && spec.version.to_s =~ /\.0$/
-      fail "No changeset found for version #{spec.version}" unless current
-      puts 'OK'
-    end
+desc "Make a release using previously staged files"
+task 'release'=>['release:prepare', 'release:publish', 'release:wrapup']
 
-    print "Uploading #{spec.version} to RubyForge ... "
-    files = Dir.glob('pkg/*.{gem,tgz,zip}')
-    rubyforge = RubyForge.new
-    rubyforge.login 
-    begin
-      if changes
-        File.open('.changes', 'w'){|f| f.write(current)}
-        rubyforge.userconfig.merge!('release_changes' => '.changes',  
'preformatted' => true)
-      end
-      rubyforge.add_release spec.rubyforge_project.downcase, 
spec.name.downcase, spec.version, *files
-    ensure
-      rm '.changes' if changes
-    end
-    puts 'Done'
-  end
 
-  # Tag this release in SVN.
-  task 'tag' do
-    info = `svn info` + `git svn info` # Using either svn or git-svn
-    url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0] 
-    break unless url
-    new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
-    break if url == new_url
-    print "Tagging release as tags/#{spec.version} ... "
-    sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}", 
:verbose=>false do |ok, res|
-      if ok
-        puts 'Done'
-      else
-        puts 'Could not create tag, please do it yourself!'
-        puts %{  svn copy #{url} #{new_url} -m "#{spec.version}"}
-      end
-    end
-  end
 
-  # Update lib/buildr.rb to next vesion number, add new entry in CHANGELOG.
-  task 'next_version'=>'tag' do
+task 'next_version' do
+  ver_file = "lib/#{spec.name}.rb"
+  if File.exist?(ver_file)
     next_version = spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { 
|t,i| t + i } }.join('.')
-    ver_file = "lib/#{spec.name}.rb"
-    if File.exist?(ver_file)
-      print "Updating #{ver_file} to next version number (#{next_version}) ... 
"
-      modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { 
|line| "#{$1}#{$2}#{next_version}#{$2}" } 
-      File.open(ver_file, 'w') { |file| file.write modified }
-      puts 'Done'
-    end
-
-    if File.exist?('CHANGELOG')
-      print 'Adding new entry to CHANGELOG ... '
-      modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
-      File.open('CHANGELOG', 'w') { |file| file.write modified }
-      puts 'Done'
+    print "Updating #{ver_file} to next version number (#{next_version}) ... "
+    modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { 
|line| "#{$1}#{$2}#{next_version}#{$2}" } 
+    File.open ver_file, 'w' do |file|
+      file.write modified
     end
+    puts 'Done'
   end
-
-  task 'wrapup'=>['tag', 'next_version']
-
 end
+
+task 'release:wrapup'=>'next_version'

Modified: incubator/buildr/trunk/rakelib/rspec.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/rspec.rake?rev=651522&r1=651521&r2=651522&view=diff
==============================================================================
--- incubator/buildr/trunk/rakelib/rspec.rake (original)
+++ incubator/buildr/trunk/rakelib/rspec.rake Fri Apr 25 00:59:03 2008
@@ -17,33 +17,66 @@
 begin
   require 'spec/rake/spectask'
 
+  directory 'reports'
+  task 'clobber' do
+    rm 'failing' rescue nil
+    rm_rf 'reports'
+  end
+
   desc 'Run all specs'
-  Spec::Rake::SpecTask.new('spec') do |task|
-    task.spec_files = FileList['spec/**/*_spec.rb']
-    task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 
'failing_examples:failing'
+  Spec::Rake::SpecTask.new('spec'=>'reports') do |task|
+    task.spec_files = FileList['spec/**/common_spec.rb'] # TODO: fix back to *_
+    task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 
'failing_examples:failing' <<
+      '--format' << 'html:reports/specs.html' << '--backtrace'
   end
+  file 'reports/specs.html'=>'spec'
 
   desc 'Run all failing examples from previous run'
   Spec::Rake::SpecTask.new('failing') do |task|
-    task.spec_files = FileList['spec/**/*_spec.rb']
+    task.spec_files = FileList['spec/**/common_spec.rb'] # TODO: fix back to *_
     task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 
'failing_examples:failing' << '--example' << 'failing'
   end
 
-  desc 'Run RSpec and generate Spec and coverage reports (slow)'
-  Spec::Rake::SpecTask.new('reports') do |task|
-    task.spec_files = FileList['spec/**/*_spec.rb']
-    task.spec_opts << '--format' << 'html:reports/specs.html' << '--backtrace'
-    task.rcov = true
-    task.rcov_opts = ['--exclude', 'spec,bin']
-  end
-  task 'reports' do
-    mkpath 'reports'
-    mv 'coverage', 'reports'
-  end
+  # Useful for testing with JRuby when using Ruby and vice versa.
+  namespace 'spec' do
+=begin
+    # TODO: Horribly broken!  Fix some other time.
+    desc 'Run RSpec and generate Spec and coverage reports (slow)'
+    Spec::Rake::SpecTask.new('rcov') do |task|
+      task.spec_files = FileList['spec/**/*spec.rb']
+      task.rcov = true
+      task.rcov_opts = '--exclude', 'spec,bin'
+      task.rcov_dir = 'coverage'
+    end
+=end
+
+    desc 'Run all specs specifically with Ruby'
+    task 'ruby' do
+      puts 'Running test suite using Ruby ...'
+      sh 'ruby -S rake spec'
+    end
+
+    desc 'Run all specs specifically with JRuby'
+    task 'jruby' do
+      puts 'Running test suite using JRuby ...'
+      sh 'jruby -S rake spec'
+    end
+
+    task 'prepare'=>'spec' do
+      print 'Checking we have specs report .... '
+      fail 'No specifications in reports directory!' unless 
File.exist?('reports/specs.html') 
+      puts 'OK'
+    end
+    task 'prepare'=>RUBY_PLATFORM =~ /java/ ? 'ruby' : 'jruby'
+    # TODO:  Add Rcov when we get it implemented.
+=begin
+    task 'prepare'=>'rcov' do
+      print 'Checking we have coverage report .... '
+      fail 'No coverage in reports directory!' unless 
File.exist?('reports/coverage') 
+      puts 'OK'
+    end
+=end
 
-  task 'clobber' do
-    rm 'failing' rescue nil
-    rm_rf 'reports'
   end
 
   task 'setup' do
@@ -58,37 +91,4 @@
 end
 
 
-# Useful for testing with JRuby when using Ruby and vice versa.
-namespace 'spec' do
-  desc 'Run all specs specifically with Ruby'
-  task 'ruby' do
-    puts 'Running test suite using Ruby ...'
-    sh 'ruby -S rake spec'
-  end
-
-  desc 'Run all specs specifically with JRuby'
-  task 'jruby' do
-    puts 'Running test suite using JRuby ...'
-    sh 'jruby -S rake spec'
-  end
-end
-
-namespace 'release' do
-  # Full test suite depends on having JRuby, Scala and Groovy installed.
-  task 'check' do
-    print 'Checking that we have JRuby, Scala and Groovy available ... '
-    fail 'Full testing requires JRuby!' unless which('jruby')
-    fail 'Full testing requires Scala!' unless which('scala')
-    fail 'Full testing requires Groovy!' unless which('groovy')
-    puts 'OK'
-  end
-
-  # Release requires RSpec and test coverage reports, uploaded as part of site.
-  # Primary test environment is Ruby (RCov), also test on JRuby.
-  task 'prepare'=>['compile', 'reports', 'spec:jruby'] do
-    print 'Checking that we have specs and coverage report ... '
-    fail 'No specifications in site directory!' unless 
File.exist?('site/specs.html') 
-    fail 'No coverage reports in site directory!' unless 
File.exist?('site/coverage/index.html')
-    puts 'OK'
-  end
-end
+task 'release:prepare'=>'spec:prepare'

Added: incubator/buildr/trunk/rakelib/rubyforge.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/rubyforge.rake?rev=651522&view=auto
==============================================================================
--- incubator/buildr/trunk/rakelib/rubyforge.rake (added)
+++ incubator/buildr/trunk/rakelib/rubyforge.rake Fri Apr 25 00:59:03 2008
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+begin
+  require 'rubyforge'
+rescue LoadError
+  puts 'Please run rake setup to install the RubyForge gem'
+  task 'setup' do
+    install_gem 'rubyforge'
+  end
+  task 'release:check' do
+    fail 'Please run rake setup to install the RubyForge gem'
+  end
+end
+
+
+namespace 'rubyforge' do
+
+  task 'release'=>'published' do |task|
+    changes = FileList['published/CHANGES'].first
+    files = FileList['published/*.{gem,tgz,zip}'].exclude(changes).existing
+    print "Uploading #{spec.version} to RubyForge ... "
+    rubyforge = RubyForge.new
+    rubyforge.login 
+    rubyforge.userconfig.merge!('release_changes'=>changes,  'preformatted' => 
true) if changes
+    rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, 
spec.version, *files
+    puts 'Done'
+  end
+
+end
+
+task 'release:publish'=>'rubyforge:release'

Added: incubator/buildr/trunk/rakelib/scm.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/scm.rake?rev=651522&view=auto
==============================================================================
--- incubator/buildr/trunk/rakelib/scm.rake (added)
+++ incubator/buildr/trunk/rakelib/scm.rake Fri Apr 25 00:59:03 2008
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+# Handling of source control.
+namespace 'scm' do
+
+  task 'check' do
+    print 'Checking there are no local changes ... '
+    svn = `svn status`
+    fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless 
svn.empty?
+    git = `git status`
+    fail "Cannot release unless all local changes are in Git:\n#{git}" if 
git[/^#\t/]
+    puts 'OK'
+  end
+
+  task 'tag' do
+    info = `svn info` + `git svn info` # Using either svn or git-svn
+    url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0] 
+    break unless url
+    new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
+    break if url == new_url
+    print "Tagging release as tags/#{spec.version} ... "
+    sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}", 
:verbose=>false do |ok, res|
+      if ok
+        puts 'Done'
+      else
+        puts 'Could not create tag, please do it yourself!'
+        puts %{  svn copy #{url} #{new_url} -m "#{spec.version}"}
+      end
+    end
+  end
+
+end
+
+task 'stage:check'=>'scm:check'
+task 'release:wrapup'=>'scm:tag'

Added: incubator/buildr/trunk/rakelib/stage.rake
URL: 
http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/stage.rake?rev=651522&view=auto
==============================================================================
--- incubator/buildr/trunk/rakelib/stage.rake (added)
+++ incubator/buildr/trunk/rakelib/stage.rake Fri Apr 25 00:59:03 2008
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+# Staged files are copied to this directory first, and from there uploaded to 
the staging server.
+directory 'staged'
+
+task 'clobber' do
+  rm_rf 'staged'
+end
+
+namespace 'stage' do
+  # stage:check verifies that we're able to stage a release: check for a 
changelog,
+  # local changes, run all the test cases, etc.  You can add more actions, e.g.
+  # checking license files, spell checking documentation.
+  task 'check'=>['setup', 'clobber']
+
+  # stage:prepare prepares all the files necessary for making a successful 
release:
+  # binary and source packages, documentation, Web site, change file, 
checksums, etc.
+  # This task depends on stage:check, and also performs its own verification 
of the
+  # produced artifacts.  Staged files are placed in the staged directory.
+  task 'prepare'=>'staged'
+
+  # stage:upload moves the stage directory to the staging server.
+  task 'upload' do |task, args|
+    puts "Uploading staged directory to #{args.staging} ..."
+    sh 'rsync', '--progress', 'staged/', args.staging
+    puts 'Done'
+  end
+end
+
+desc 'Stage files for the release, upload them to staging server'
+task 'stage'=>['stage:check', 'stage:prepare', 'stage:upload']


Reply via email to