Return-Path: Delivered-To: apmail-incubator-buildr-commits-archive@locus.apache.org Received: (qmail 66201 invoked from network); 8 Apr 2008 03:07:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Apr 2008 03:07:52 -0000 Received: (qmail 96856 invoked by uid 500); 8 Apr 2008 03:07:52 -0000 Delivered-To: apmail-incubator-buildr-commits-archive@incubator.apache.org Received: (qmail 96842 invoked by uid 500); 8 Apr 2008 03:07:52 -0000 Mailing-List: contact buildr-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: buildr-dev@incubator.apache.org Delivered-To: mailing list buildr-commits@incubator.apache.org Received: (qmail 96828 invoked by uid 99); 8 Apr 2008 03:07:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Apr 2008 20:07:52 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Apr 2008 03:07:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0CB371A9832; Mon, 7 Apr 2008 20:07:23 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r645757 - in /incubator/buildr/trunk: Rakefile rakelib/apache.rake rakelib/doc.rake rakelib/package.rake rakelib/release.rake rakelib/release.rb rakelib/rspec.rake rakelib/setup.rake Date: Tue, 08 Apr 2008 03:07:22 -0000 To: buildr-commits@incubator.apache.org From: assaf@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080408030723.0CB371A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: assaf Date: Mon Apr 7 20:07:18 2008 New Revision: 645757 URL: http://svn.apache.org/viewvc?rev=645757&view=rev Log: Minor cleanup. Please no moving of methods from Rakefile/rakelib into Buildr. Added: incubator/buildr/trunk/rakelib/release.rake incubator/buildr/trunk/rakelib/setup.rake Removed: incubator/buildr/trunk/rakelib/release.rb Modified: incubator/buildr/trunk/Rakefile incubator/buildr/trunk/rakelib/apache.rake incubator/buildr/trunk/rakelib/doc.rake incubator/buildr/trunk/rakelib/package.rake incubator/buildr/trunk/rakelib/rspec.rake Modified: incubator/buildr/trunk/Rakefile URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=645757&r1=645756&r2=645757&view=diff ============================================================================== --- incubator/buildr/trunk/Rakefile (original) +++ incubator/buildr/trunk/Rakefile Mon Apr 7 20:07:18 2008 @@ -13,17 +13,10 @@ # License for the specific language governing permissions and limitations under # the License. -# Load file/system utilities used shared between Buildr's runtime and this Rakefile -require File.expand_path('lib/buildr/core/util', File.dirname(__FILE__)) -extend Buildr::Util - -class << self - alias_method :say, :puts -end unless respond_to?(:say) - -# We need two specifications, for Ruby and Java, and one for the platform we run on. -$specs = ['ruby', 'java'].inject({}) { |hash, platform| - spec = Gem::Specification.new do |spec| + +def spec(platform = 'ruby') + @specs ||= {} + @specs[platform] ||= Gem::Specification.new do |spec| spec.name = 'buildr' spec.version = File.read(__FILE__.pathmap('%d/lib/buildr.rb')).scan(/VERSION\s*=\s*(['"])(.*)\1/)[0][1] spec.author = 'Apache Buildr' @@ -57,27 +50,12 @@ spec.add_dependency 'xml-simple', '~> 1.0' spec.add_dependency 'archive-tar-minitar', '~> 0.5' spec.add_dependency 'rubyforge', '~> 0.4' - spec.add_dependency 'rjb', '~> 1.1' if platform =~ /ruby/ + spec.add_dependency 'rjb', '~> 1.1' unless platform =~ /java/ end - hash.update(platform=>spec) -} -$spec = $specs[java_platform? ? 'java' : 'ruby'] - -$license_excluded = ['lib/core/progressbar.rb', 'spec/spec.opts', 'doc/css/syntax.css', '.textile', '.haml'] - -begin - require 'highline/import' -rescue LoadError - puts 'HighLine required, please run rake setup first' end -# Setup environment for running this Rakefile (RSpec, Docter, etc). -desc "If you're building from sources, run this task one to setup the necessary dependencies." -task 'setup' do - dependencies = $spec.dependencies - dependencies << Gem::Dependency.new('win32console', '> 0') if win_os? # Colors for RSpec. - install_gems(*dependencies) -end + +$license_excluded = ['lib/core/progressbar.rb', 'spec/spec.opts', 'doc/css/syntax.css', '.textile', '.haml'] namespace 'release' do Modified: incubator/buildr/trunk/rakelib/apache.rake URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/apache.rake?rev=645757&r1=645756&r2=645757&view=diff ============================================================================== --- incubator/buildr/trunk/rakelib/apache.rake (original) +++ incubator/buildr/trunk/rakelib/apache.rake Mon Apr 7 20:07:18 2008 @@ -25,7 +25,7 @@ task 'license' do say '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 = FileList[spec.files].exclude(*excluded).exclude(*Array($license_excluded)).select { |fn| File.file?(fn) } missing = required.reject { |fn| comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|/m). map { |match| match.compact }.flatten.join("\n") Modified: incubator/buildr/trunk/rakelib/doc.rake URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/doc.rake?rev=645757&r1=645756&r2=645757&view=diff ============================================================================== --- incubator/buildr/trunk/rakelib/doc.rake (original) +++ incubator/buildr/trunk/rakelib/doc.rake Mon Apr 7 20:07:18 2008 @@ -19,10 +19,10 @@ desc 'Generate RDoc documentation' rdoc = Rake::RDocTask.new('rdoc') do |rdoc| rdoc.rdoc_dir = 'rdoc' - rdoc.title = $spec.name - rdoc.options = $spec.rdoc_options + ['--promiscuous'] + rdoc.title = spec.name + rdoc.options = spec.rdoc_options + ['--promiscuous'] rdoc.rdoc_files.include('lib/**/*.rb') - rdoc.rdoc_files.include $spec.extra_rdoc_files + rdoc.rdoc_files.include spec.extra_rdoc_files end @@ -32,7 +32,7 @@ rescue LoadError puts 'Please run rake setup to install the Allison RDoc template' task 'setup' do - install_gems 'allison' + install_gem 'allison' end task 'release:check' do fail 'Please run rake setup to install the Allison RDoc template' @@ -50,7 +50,7 @@ # html.gsub(/

(.*?)<\/p>/, %{

\\2

}) #end - collection = Docter.collection($spec.name).using('doc/site.toc.yaml').include('doc/pages', 'LICENSE', 'CHANGELOG') + collection = Docter.collection(spec.name).using('doc/site.toc.yaml').include('doc/pages', 'LICENSE', 'CHANGELOG') template = Docter.template('doc/site.haml'). include('doc/css', 'doc/images', 'doc/scripts', 'reports/specs.html', 'reports/coverage', 'rdoc', 'print/buildr.pdf') @@ -60,28 +60,12 @@ desc 'Generate Web site in directory site' Docter::Rake.generate 'site', collection, template - task 'clobber' do - rm_rf 'site' - end - -rescue LoadError - puts 'Please run rake setup to install the Docter document generation library' - task 'setup' do - install_gems 'docter' - end - task 'release:check' do - fail 'Please run rake setup to install the Docter document generation library' - end -end - - -if Object.const_defined?(:Docter) && which('prince') - Docter::Rake.generate 'print', - Docter.collection($spec.name).using('doc/print.toc.yaml').include('doc/pages', 'LICENSE'), + 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('print/buildr.pdf'=>'print') do |task| + file('site/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 @@ -94,21 +78,26 @@ task 'clobber' do rm_rf 'print' + rm_rf 'site' end -else +rescue LoadError + puts 'Please run rake setup to install the Docter document generation library' + task 'setup' do + install_gem 'docter' + end task 'release:check' do - fail 'Release requires PrinceXML to generate PDF documentation!' + fail 'Please run rake setup to install the Docter document generation library' end end namespace 'release' do task 'prepare'=>'docs' do - puts 'Checking that we have site documentation, RDoc and PDF ... ' + say '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' + say 'OK' end end Modified: incubator/buildr/trunk/rakelib/package.rake URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/package.rake?rev=645757&r1=645756&r2=645757&view=diff ============================================================================== --- incubator/buildr/trunk/rakelib/package.rake (original) +++ incubator/buildr/trunk/rakelib/package.rake Mon Apr 7 20:07:18 2008 @@ -23,28 +23,30 @@ desc 'Compile Java libraries used by Buildr' task 'compile' do say 'Compiling Java libraries ... ' - ruby '-Ilib', '-Iaddon', 'bin/buildr', 'compile' + sh Config::CONFIG['ruby_install_name'], '-Ilib', '-Iaddon', 'bin/buildr', 'compile' say 'OK' end -Rake::GemPackageTask.new($specs['ruby']) do |pkg| +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($specs['java']) do |pkg| +Rake::GemPackageTask.new(spec('java')) do |pkg| file pkg.package_dir_path=>'compile' end -current = Rake::GemPackageTask.new($spec) +current = Rake::GemPackageTask.new(spec) desc 'Install the package locally' task 'install'=>"#{current.package_dir}/#{current.gem_file}" do |task| - ruby 'install', "#{current.package_dir}/#{current.gem_file}", :command=>'gem', :sudo=>true + install_gem "#{current.package_dir}/#{current.gem_file}" end desc 'Uninstall previously installed packaged' task 'uninstall' do |task| say "Uninstalling #{$spec.name} ... " - ruby 'install', $spec.name, :command=>'gem', :sudo=>true + args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'uninstall', spec.name, '--version', spec.version] + args.unshift('sudo') unless windows? + sh *args say 'Done' end Added: incubator/buildr/trunk/rakelib/release.rake URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/release.rake?rev=645757&view=auto ============================================================================== --- incubator/buildr/trunk/rakelib/release.rake (added) +++ incubator/buildr/trunk/rakelib/release.rake Mon Apr 7 20:07:18 2008 @@ -0,0 +1,111 @@ +# 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 + say '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 '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 + say 'Checking that CHANGELOG indicates most recent version and today\'s date ... ' + expecting = "#{ruby_spec.version} (#{Time.now.strftime('%Y-%m-%d')})" + header = File.readlines('CHANGELOG').first + fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header + say 'OK' + end + + # No local changes. + task 'check' do + status = `svn status` + fail "Cannot release unless all local changes are in SVN:\n#{status}" unless status.empty? + end + + desc 'Make a release' + task 'make'=>'prepare' do + enhance do + task('release:wrapup').invoke + end + end + + task 'rubyforge'=>'pacakge' do + # Read the changes for this release. + say 'Looking for changes between this release and previous one ... ' + pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/ + changelog = File.read(__FILE__.pathmap('%d/CHANGELOG')) + changes = 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 + say 'OK' + + say "Uploading #{spec.version} to RubyForge ... " + files = Dir.glob('pkg/*.{gem,tgz,zip}') + rubyforge = RubyForge.new + rubyforge.login + File.open('.changes', 'w'){|f| f.write(current)} + rubyforge.userconfig.merge!('release_changes' => '.changes', 'preformatted' => true) + rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files + rm '.changes' + say 'Done' + end + + # Tag this release in SVN. + task 'tag' do + say "Tagging release as tags/#{ruby_spec.version} ... " + cur_url = `svn info`.scan(/URL: (.*)/)[0][0] + new_url = cur_url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{ruby_spec.version.to_s}") + sh 'svn', 'copy', cur_url, new_url, '-m', "Release #{ruby_spec.version.to_s}", :verbose=>false + say "OK" + end + + # Update lib/buildr.rb to next vesion number, add new entry in CHANGELOG. + task 'next_version'=>'tag' do + next_version = ruby_spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.') + say "Updating lib/buildr.rb to next version number (#{next_version}) ... " + buildr_rb = File.read(__FILE__.pathmap('%d/lib/buildr.rb')). + sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" } + File.open(__FILE__.pathmap('%d/lib/buildr.rb'), 'w') { |file| file.write buildr_rb } + say "OK" + + say 'Adding new entry to CHANGELOG ... ' + changelog = File.read(__FILE__.pathmap('%d/CHANGELOG')) + File.open(__FILE__.pathmap('%d/CHANGELOG'), 'w') { |file| file.write "#{next_version} (Pending)\n\n#{changelog}" } + say "OK" + end + + task 'wrapup'=>['tag', 'next_version'] + +end Modified: incubator/buildr/trunk/rakelib/rspec.rake URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/rspec.rake?rev=645757&r1=645756&r2=645757&view=diff ============================================================================== --- incubator/buildr/trunk/rakelib/rspec.rake (original) +++ incubator/buildr/trunk/rakelib/rspec.rake Mon Apr 7 20:07:18 2008 @@ -29,7 +29,6 @@ task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 'failing_examples:failing' << '--example' << 'failing' end - directory 'reports' desc 'Run RSpec and generate Spec and coverage reports (slow)' Spec::Rake::SpecTask.new('reports') do |task| task.spec_files = FileList['spec/**/*_spec.rb'] @@ -38,6 +37,7 @@ task.rcov_opts = ['--exclude', 'spec,bin'] end task 'reports' do + mkpath 'reports' mv 'coverage', 'reports' end @@ -46,11 +46,12 @@ rm_rf 'reports' end -rescue LoadError - say 'Please run rake setup to install RSpec' task 'setup' do - ruby 'install', 'rspec', :command=>'gem', :sudo=>true + install_gem 'win32console' if Gem.win_platform? # Colors for RSpec, only on Windows platform. end + +rescue LoadError + say 'Please run rake setup to install RSpec' task 'release:check' do fail 'Please run rake setup to install RSpec' end @@ -62,13 +63,13 @@ desc 'Run all specs specifically with Ruby' task 'ruby' do say 'Running test suite using Ruby ...' - system 'ruby -S rake spec' + sh 'ruby -S rake spec' end desc 'Run all specs specifically with JRuby' task 'jruby' do say 'Running test suite using JRuby ...' - system 'jruby -S rake spec' + sh 'jruby -S rake spec' end end Added: incubator/buildr/trunk/rakelib/setup.rake URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/setup.rake?rev=645757&view=auto ============================================================================== --- incubator/buildr/trunk/rakelib/setup.rake (added) +++ incubator/buildr/trunk/rakelib/setup.rake Mon Apr 7 20:07:18 2008 @@ -0,0 +1,39 @@ +# True if running on the Windows operating sytem. Different from Gem.win_platform? +# which returns true if running on the Windows platform of MRI, false when using JRuby. +def windows? + Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i +end + + +# Finds and returns path to executable. Consults PATH environment variable. +# Returns nil if executable not found. +def which(name) + if windows? + path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| path.gsub('\\', '/') }.map { |path| "#{path}/#{name}.{exe,bat,com}" } + else + path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| "#{path}/#{name}" } + end + FileList[path].existing.first +end + + +def install_gem(name, ver_requirement = nil) + dep = Gem::Dependency.new(name, ver_requirement) + if Gem::SourceIndex.from_installed_gems.search(dep).empty? + puts "Installing #{name} #{ver_requirement} ..." + args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', name] + args.unshift('sudo') unless windows? + args << '-v' << ver_requirement.to_s if ver_requirement + sh *args + end +end + +# Setup environment for running this Rakefile (RSpec, Docter, etc). +desc "If you're building from sources, run this task one to setup the necessary dependencies." +missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? } +task 'setup' do + missing.each do |dep| + install_gem dep.name, dep.version_requirements + end +end +puts "Missing Gems #{missing.join(', ')}, please run rake setup first!" unless missing.empty?