0
# License for the specific language governing permissions and limitations under
0
-require 'rake/gempackagetask'
0
-require 'rake/rdoctask'
0
-require 'spec/rake/spectask'
0
-# Gem specification comes first, other tasks rely on it.
0
- Gem::Specification.new do |spec|
0
+# We need two specifications, for Ruby and Java, and one for the platform we run on.
0
+$specs = ['ruby', 'java'].inject({}) { |hash, platform|
0
+ spec = Gem::Specification.new do |spec|
0
spec.version = File.read(__FILE__.pathmap('%d/lib/buildr.rb')).scan(/VERSION\s*=\s*(['"])(.*)\1/)[0][1]
0
spec.author = 'Apache Buildr'
0
spec.email = 'buildr-user@incubator.apache.org'
0
spec.homepage = "http://incubator.apache.org/#{spec.name}/"
0
spec.summary = 'A build system that doesn\'t suck'
0
- spec.files = FileList['lib/**/*', 'README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER',
0
- 'Rakefile', 'spec/**/*', 'doc/**/*'].to_ary
0
+ spec.files = FileList['lib/**/*', 'README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER', 'KEYS',
0
+ 'Rakefile', 'rakelib/**/*', 'spec/**/*', 'doc/**/*'].to_ary
0
spec.require_path = 'lib'
0
- spec.extra_rdoc_files = ['README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER'
]
0
+ spec.extra_rdoc_files = ['README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER'
, 'site/buildr.pdf']
0
spec.rdoc_options << '--title' << "Buildr -- #{spec.summary}" <<
0
'--main' << 'README' << '--line-numbers' << '--inline-source' << '-p' <<
0
'--webcvs' << 'http://svn.apache.org/repos/asf/incubator/buildr/trunk/'
0
spec.rubyforge_project = 'buildr'
0
+ spec.platform = platform
0
spec.bindir = 'bin' # Use these for applications.
0
spec.executables = ['buildr']
0
@@ -52,39 +49,13 @@ def specify(platform)
0
spec.add_dependency 'xml-simple', '~> 1.0'
0
spec.add_dependency 'archive-tar-minitar', '~> 0.5'
0
spec.add_dependency 'rubyforge', '~> 0.4'
0
- spec.platform = platform
0
- spec.add_dependency 'rjb', '~> 1.1' unless platform == 'java'
0
+ spec.add_dependency 'rjb', '~> 1.1' if platform =~ /ruby/
0
+ hash.update(platform=>spec)
0
+$spec = $specs[RUBY_PLATFORM =~ /java/ ? 'java' : 'ruby']
0
-ruby_spec = specify(Gem::Platform::RUBY)
0
-ruby_package = Rake::GemPackageTask.new(ruby_spec) { |pkg| pkg.need_tar = pkg.need_zip = true }
0
-jruby_spec = specify('java')
0
-jruby_package = Rake::GemPackageTask.new(jruby_spec) { |pkg| pkg.need_tar = pkg.need_zip = false }
0
- require 'rubygems/dependency_installer'
0
- require 'rubygems/doc_manager'
0
- def install_gem(gem, options = {})
0
- say "Installing #{gem}..."
0
- installer = Gem::DependencyInstaller.new(gem, options.delete(:version), options)
0
- installer.installed_gems.each do |spec|
0
- Gem::DocManager.new(spec).generate_ri unless options[:ri] == false
0
- Gem::DocManager.new(spec).generate_rdoc unless options[:rdoc] == false
0
-rescue LoadError # < rubygems 1.0.1
0
- require 'rubygems/remote_installer'
0
- def install_gem(gem, options = {})
0
- say "Installing #{gem}..."
0
- Gem::RemoteInstaller.new.install(gem, options.delete(:version))
0
+$license_excluded = ['lib/core/progressbar.rb', 'spec/spec.opts', 'doc/css/syntax.css', '.textile', '.yaml']
0
@@ -100,345 +71,32 @@ end
0
# Setup environment for running this Rakefile (RSpec, Docter, etc).
0
desc "If you're building from sources, run this task one to setup the necessary dependencies."
0
- # Install all Buildr and documentation dependencies.
0
- gems = Gem::SourceIndex.from_installed_gems
0
- dependencies = specify(RUBY_PLATFORM).dependencies
0
- dependencies << Gem::Dependency.new('docter', '~>1.1')
0
- dependencies << Gem::Dependency.new('rcov', '~>0.8') unless RUBY_PLATFORM =~ /java/
0
- dependencies.select { |dep| gems.search(dep.name, dep.version_requirements).empty? }.
0
- ruby 'install', dep.name, '-v', dep.version_requirements.to_s, :command=>'gem', :sudo=>true
0
- #each { |dep| install_gem dep.name, :version=>dep.version_requirements }
0
+ dependencies = spec.dependencies
0
+ dependencies = dependencies.reject { |dep| dep.name == 'rjb' } if RUBY_PLATFORM =~ /java/
0
+ installed = Gem::SourceIndex.from_installed_gems
0
+ required = dependencies.select { |dep| installed.search(dep.name, dep.version_requirements).empty? }
0
+ required.each do |dep|
0
+ puts "Installing #{dep} ..."
0
+ ruby 'install', dep.name, '-v', dep.version_requirements.to_s, :command=>'gem', :sudo=>true
0
require 'highline/import'
0
puts 'HighLine required, please run rake setup first'
0
-# Packaging and local installation.
0
-desc 'Clean up all temporary directories used for running tests, creating documentation, packaging, etc.'
0
-task('clobber') { rm_rf 'pkg' }
0
-desc 'Install the package locally'
0
-task 'install'=>['clobber', 'package'] do |task|
0
- pkg = RUBY_PLATFORM =~ /java/ ? jruby_package : ruby_package
0
- ruby 'install', File.expand_path(pkg.gem_file, pkg.package_dir), :command=>'gem', :sudo=>true
0
-desc 'Uninstall previously installed packaged'
0
-task 'uninstall' do |task|
0
- spec = RUBY_PLATFORM =~ /java/ ? jruby_spec : ruby_spec
0
- say "Uninstalling #{spec.name} ... "
0
- ruby 'install', spec.name, :command=>'gem', :sudo=>true
0
-# Testing is everything.
0
-task('clobber') { rm 'failing' rescue nil }
0
-Spec::Rake::SpecTask.new('spec') do |task|
0
- task.spec_files = FileList['spec/**/*_spec.rb']
0
- task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 'failing_examples:failing'
0
-desc 'Run all failing examples from previous run'
0
-Spec::Rake::SpecTask.new('failing') do |task|
0
- task.spec_files = FileList['spec/**/*_spec.rb']
0
- task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 'failing_examples:failing' << '--example' << 'failing'
0
- Rake::Task['rake:clobber'].enhance { rm_rf 'reports' }
0
- desc 'Run all specs and generate specification and test coverage reports in html directory'
0
- Spec::Rake::SpecTask.new('full'=>'reports') do |task|
0
- task.spec_files = FileList['spec/**/*_spec.rb']
0
- task.spec_opts << '--format' << 'html:reports/specs.html' << '--backtrace'
0
- task.rcov_dir = 'reports/coverage'
0
- task.rcov_opts = ['--exclude', 'spec,bin']
0
- desc 'Run all specs specifically with Ruby'
0
- task('ruby') { system 'ruby -S rake spec' }
0
- desc 'Run all specs specifically with JRuby'
0
- task('jruby') { system 'jruby -S rake spec' }
0
-desc 'Generate RDoc documentation'
0
-rdoc = Rake::RDocTask.new(:rdoc) do |rdoc|
0
- rdoc.rdoc_dir = 'rdoc'
0
- rdoc.title = ruby_spec.name
0
- rdoc.options = ruby_spec.rdoc_options + ['--promiscuous']
0
- rdoc.rdoc_files.include('lib/**/*.rb')
0
- rdoc.rdoc_files.include ruby_spec.extra_rdoc_files
0
- rdoc.template = File.expand_path('lib/allison.rb', Gem.loaded_specs['allison'].full_gem_path)
0
-desc 'Generate all documentation merged into the html directory'
0
-task 'docs'=>[rdoc.name]
0
- require 'docter/server'
0
- :collection => Docter.collection('Buildr').using('doc/web.toc.yaml').
0
- include('doc/pages', 'LICENSE', 'CHANGELOG'),
0
- :template => Docter.template('doc/web.haml').
0
- include('doc/css', 'doc/images', 'doc/scripts', 'reports/specs.html', 'reports/coverage', 'rdoc')
0
- :collection => Docter.collection('Buildr').using('doc/print.toc.yaml').
0
- include('doc/pages', 'LICENSE'),
0
- :template => Docter.template('doc/print.haml').include('doc/css', 'doc/images')
0
- #Docter.filter_for(:footnote) do |html|
0
- # html.gsub(/<p id="fn(\d+)">(.*?)<\/p>/, %{<p id="fn\\1" class="footnote">\\2</p>})
0
- desc 'Generate HTML documentation'
0
- html = Docter::Rake.generate('html', web_docs[:collection], web_docs[:template])
0
- html.enhance ['spec:full']
0
- desc 'Run Docter server'
0
- Docter::Rake.serve 'docter', web_docs[:collection], web_docs[:template], :port=>3000
0
- task('docs').enhance [html]
0
- task('clobber') { rm_rf html.to_s }
0
- if `which prince` =~ /prince/
0
- print = Docter::Rake.generate('print', print_docs[:collection], print_docs[:template], :one_page)
0
- pdf = file('html/buildr.pdf'=>print) do |task|
0
- sh *%W{prince #{print}/index.html -o #{task.name} --media=print} do |ok, res|
0
- fail 'Failed to create PDF, see errors above' unless ok
0
- task('pdf'=>pdf) { |task| `open #{File.expand_path(pdf.to_s)}` }
0
- task('docs').enhance [pdf]
0
- task('clobber') { rm_rf print.to_s }
0
- puts "To generate site documentation, run rake setup first"
0
+desc 'Clean up all temporary directories used for running tests, creating documentation, packaging, etc.'
0
- # This task does all prerequisites checks before starting the release, for example,
0
- # that we have Groovy and Scala to run all the test cases, or that we have Allison
0
- # and PrinceXML to generate the full documentation.
0
- # This task does all the preparation work before making a release and also checks
0
- # that we generate all the right material, for example, that we compiled Java sources,
0
- # created the PDF, have coverage report.
0
- task 'prepare'=>['clobber', 'check']
0
- # Does CHANGELOG reflects current release?
0
- say 'Checking that CHANGELOG indicates most recent version and today\'s date ... '
0
- expecting = "#{ruby_spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
0
- header = File.readlines('CHANGELOG').first
0
- fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
0
- # License requirement.
0
- say 'Checking that files contain the Apache license ... '
0
- directories = 'lib', 'spec', 'docs', 'bin'
0
- ignore = 'class', 'opts'
0
- FileList['lib/**/*', 'spec/**/*', 'bin/**', 'doc/css/*', 'doc/scripts/*'].
0
- exclude('doc/css/syntax.css').reject { |file| File.directory?(file) || ignore.include?(file[/[^.]*$/]) }.each do |file|
0
- comments = File.read(file).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|<!--(.*?)-->/m).
0
- map { |match| match.reject(&:nil?) }.flatten.join("\n")
0
- fail "File #{file} missing Apache License, please add it before making a release!" unless
0
- comments =~ /Licensed to the Apache Software Foundation/ && comments =~ /http:\/\/www.apache.org\/licenses\/LICENSE-2.0/
0
- fail "Cannot release unless all local changes are in SVN:\n#{status}" unless status.empty?
0
- # Re-generate Java extensions and to this before running test cases.
0
- say 'Compiling Java libraries ... '
0
- cmd = [ RUBY_PLATFORM =~ /java/ ? 'jruby' : 'ruby' ] <<
0
- '-I' << File.join(File.dirname(__FILE__), 'lib') <<
0
- File.join(File.dirname(__FILE__), 'bin', 'buildr') <<
0
- # Tests, specs and coverage reports.
0
- say 'Checking that we have JRuby, Scala and Groovy available ... '
0
- fail 'Full testing requires JRuby!' if `which jruby`.empty?
0
- fail 'Full testing requires Scala!' if `which scalac`.empty? || ENV['SCALA_HOME'].to_s.empty?
0
- fail 'Full testing requires Groovy!' if `which groovyc`.empty?
0
- task 'prepare'=>'compile' do
0
- say 'Running test suite using JRuby ...'
0
- task('spec:jruby').invoke
0
- say 'Running test suite using Ruby ...'
0
- task('spec:ruby').invoke
0
- # Documentation (derived from above).
0
- say 'Checking that we can use Allison and PrinceXML ... '
0
- fail 'Release requires the Allison RDoc template, please gem install allison!' unless rdoc.template =~ /allison.rb/
0
- fail 'Release requires PrinceXML to generate PDF documentation!' if `which prince`.empty?
0
- task 'prepare'=>'spec:full' do
0
- say 'Generating RDocs and PDF ...'
0
- say 'Checking that we have PDF, RDoc, specs and coverage report ... '
0
- fail 'No RDocs if html/rdoc!' unless File.exist?('html/rdoc/files/lib/buildr_rb.html')
0
- fail 'No PDF generated, you need to install PrinceXML!' unless File.exist?('html/buildr.pdf')
0
- fail 'No specifications in html directory!' unless File.exist?('html/specs.html')
0
- fail 'No coverage reports in html/coverage directory!' unless File.exist?('html/coverage/index.html')
0
+ task('rubyforge').invoke
0
+ task('apache:upload').invoke('buildr', true)
0
- require 'rubyforge' rescue fail 'RubyForge required, please gem install rubyforge!'
0
- fail 'GnuPG required to create signatures!' if `which gpg`.empty?
0
- gpg_user = ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment variable so we know which key to use.'
0
- sh('gpg', '--list-key', gpg_user) { |ok, res| ok or fail "No key matches for GPG_USER=#{gpg_user}" }
0
- # Cut the release: upload Gem to RubyForge before updating site (fail safe).
0
- task 'cut'=>['upload:rubyforge', 'upload:site']
0
- # Upload site (html directory) to Apache.
0
- task 'site'=>'rake:docs' do
0
- say 'Uploading Web site to people.apache.org ... '
0
- args = Dir.glob('html/*') + ['people.apache.org:/www/incubator.apache.org/' + ruby_spec.rubyforge_project.downcase]
0
- verbose(false) { sh 'rsync ', '-r', '--del', '--progress', *files }
0
- # Upload Gems to RubyForge.
0
- task 'rubyforge'=>['rake:docs', 'rake:package'] do
0
- # Read the changes for this release.
0
- say 'Looking for changes between this release and previous one ... '
0
- pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
0
- changelog = File.read(__FILE__.pathmap('%d/CHANGELOG'))
0
- changes = changelog.scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
0
- current = changes[ruby_spec.version.to_s]
0
- current = changes[ruby_spec.version.to_s.split('.')[0..-2].join('.')] if !current && ruby_spec.version.to_s =~ /\.0$/
0
- fail "No changeset found for version #{ruby_spec.version}" unless current
0
- say "Uploading #{ruby_spec.version} to RubyForge ... "
0
- files = Dir.glob('pkg/*.{gem,tgz,zip}')
0
- rubyforge = RubyForge.new
0
- File.open('.changes', 'w'){|f| f.write(current)}
0
- rubyforge.userconfig.merge!('release_changes' => '.changes', 'preformatted' => true)
0
- rubyforge.add_release ruby_spec.rubyforge_project.downcase, ruby_spec.name.downcase, ruby_spec.version, *files
0
- task 'apache'=>['rake:package'] do
0
- gpg_user = ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment variable so we know which key to use.'
0
- say 'Creating -incubating packages ... '
0
- packages = FileList['pkg/*.{gem,zip,tgz}'].map do |package|
0
- package.pathmap('incubating/%n-incubating%x').tap do |incubating|
0
- cp package, incubating
0
- say 'Signing -incubating packages ... '
0
- files = packages.each do |package|
0
- binary = File.read(package)
0
- File.open(package + '.md5', 'w') { |file| file.write MD5.hexdigest(binary) << ' ' << package }
0
- File.open(package + '.sha1', 'w') { |file| file.write SHA1.hexdigest(binary) << ' ' << package }
0
- sh 'gpg', '--local-user', gpg_user, '--armor', '--output', package + '.asc', '--detach-sig', package, :verbose=>true
0
- [package, package + '.md5', package + '.sha1', package + '.asc']
0
- say 'Uploading packages to Apache dist ... '
0
- args = files.flatten << 'KEYS' << 'people.apache.org:/www.apache.org/dist/incubator/buildr/'
0
- verbose(false) { sh 'rsync', '-progress', *args }
0
- Rake::Task['rake:clobber'].enhance { rm_rf 'incubating' }
0
- # Tag this release in SVN.
0
- say "Tagging release as tags/#{ruby_spec.version} ... "
0
- cur_url = `svn info`.scan(/URL: (.*)/)[0][0]
0
- new_url = cur_url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{ruby_spec.version.to_s}")
0
- sh 'svn', 'copy', cur_url, new_url, '-m', "Release #{ruby_spec.version.to_s}", :verbose=>false
0
- # Update lib/buildr.rb to next vesion number, add new entry in CHANGELOG.
0
- task 'next_version'=>'tag' do
0
- next_version = ruby_spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
0
- say "Updating lib/buildr.rb to next version number (#{next_version}) ... "
0
- buildr_rb = File.read(__FILE__.pathmap('%d/lib/buildr.rb')).
0
- sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
0
- File.open(__FILE__.pathmap('%d/lib/buildr.rb'), 'w') { |file| file.write buildr_rb }
0
- say 'Adding new entry to CHANGELOG ... '
0
- changelog = File.read(__FILE__.pathmap('%d/CHANGELOG'))
0
- File.open(__FILE__.pathmap('%d/CHANGELOG'), 'w') { |file| file.write "#{next_version} (Pending)\n\n#{changelog}" }
0
- # Wrapup comes after cut, and does things like tagging in SVN, updating Buildr version number, etc.
0
- task 'wrapup'=>['tag', 'next_version']
0
-task 'release'=>['release:prepare', 'release:cut', 'release:wrapup']
Comments
No one has commented yet.