public
Rubygem
Description: Apache Buildr
Homepage: http://incubator.apache.org/buildr
Clone URL: git://github.com/vic/buildr.git
Search Repo:
Separating release process into staging and releasing


git-svn-id: https://svn.apache.org/repos/asf/incubator/buildr/trunk@651522 
13f79535-47bb-0310-9956-ffa450edef68
Assaf (author)
Fri Apr 25 00:59:03 -0700 2008
commit  eff9411d40eec4e7f9dd8e2f1eb6f1b349dfafb6
tree    5297196b3cae9fbc78eade3fe6848ffd40baed0c
parent  514c2976277902fa8d34a038635ccbe0338c4eaf
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-1.3.0 (Pending)
0
+1.3.0 (2008-04-25)
0
 * Added: Testing with EasyB (Nicolas Modrzyk).
0
 * Added: Testing with JBehave (John Layton).
0
 * Added: Testing with RSpec (Nick Sieger).
...
64
65
66
67
68
69
70
71
72
73
74
75
 
 
76
77
78
79
80
 
 
 
81
82
83
84
85
86
87
88
89
90
91
 
92
 
 
 
 
 
 
 
 
 
 
93
...
64
65
66
 
 
 
67
68
69
70
71
72
73
74
75
 
 
 
 
76
77
78
79
 
 
 
80
 
81
 
 
 
 
82
83
84
85
86
87
88
89
90
91
92
93
94
0
@@ -64,31 +64,32 @@
0
 end
0
 
0
 
0
-$license_excluded = ['spec/spec.opts', '.textile', '.haml']
0
-
0
-
0
 desc 'Compile Java libraries used by Buildr'
0
 task 'compile' do
0
   puts 'Compiling Java libraries ...'
0
   sh Config::CONFIG['ruby_install_name'], '-Ilib', '-Iaddon', 'bin/buildr', 'compile'
0
   puts 'OK'
0
 end
0
+file Rake::GemPackageTask.new(spec).package_dir=>'compile'
0
+file Rake::GemPackageTask.new(spec).package_dir_path=>'compile'
0
 
0
-Rake::GemPackageTask.new(spec('ruby')) do |pkg|
0
- pkg.need_tar = pkg.need_zip = true
0
- file pkg.package_dir_path=>'compile'
0
- file pkg.package_dir=>'compile'
0
+# We also need the other package (JRuby if building on Ruby, and vice versa)
0
+Rake::GemPackageTask.new spec(RUBY_PLATFORM =~ /java/ ? 'ruby' : 'java') do |task|
0
+ # Block necessary otherwise doesn't do full job.
0
 end
0
-Rake::GemPackageTask.new(spec('java')) do |pkg|
0
- file pkg.package_dir_path=>'compile'
0
-end
0
 
0
-namespace 'release' do
0
 
0
- task 'make' do
0
- task('rubyforge').invoke
0
- task('apache:upload').invoke('buildr', true)
0
- end
0
+ENV['staging'] = "people.apache.org:~/public_html/#{spec.name}-#{spec.version}"
0
 
0
+task 'apache:license'=>spec.files
0
+# TODO: Switch fully to our own coloring scheme.
0
+task('apache:license').prerequisites.exclude('doc/css/syntax.css')
0
+
0
+task 'spec:check' do
0
+ print 'Checking that we have JRuby, Scala and Groovy available ... '
0
+ fail 'Full testing requires JRuby!' unless which('jruby')
0
+ fail 'Full testing requires Scala!' unless which('scala')
0
+ fail 'Full testing requires Groovy!' unless which('groovy')
0
+ puts 'OK'
0
 end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -1,3 +1,20 @@
0
+#!/bin/sh
0
+# Licensed to the Apache Software Foundation (ASF) under one or more
0
+# contributor license agreements. See the NOTICE file distributed with this
0
+# work for additional information regarding copyright ownership. The ASF
0
+# licenses this file to you under the Apache License, Version 2.0 (the
0
+# "License"); you may not use this file except in compliance with the License.
0
+# You may obtain a copy of the License at
0
+#
0
+# http://www.apache.org/licenses/LICENSE-2.0
0
+#
0
+# Unless required by applicable law or agreed to in writing, software
0
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
0
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
0
+# License for the specific language governing permissions and limitations under
0
+# the License.
0
+
0
+
0
 # This script helps buildr developers to obtain their own git clone from
0
 # github, having a set of pre-defined aliases to work with Apache's SVN.
0
 #
...
22
23
24
25
 
26
27
28
 
29
30
31
32
33
34
35
36
37
38
39
40
...
34
35
36
 
 
37
38
39
40
41
42
43
44
45
46
47
 
 
48
49
50
51
52
53
 
 
 
 
 
 
 
 
 
54
55
56
57
58
59
60
 
 
 
 
 
61
 
 
 
 
 
 
 
 
 
 
62
63
64
65
66
67
68
69
70
 
 
 
 
 
71
72
73
74
75
76
77
 
 
 
 
 
 
78
79
80
81
82
83
84
85
86
87
88
89
90
 
 
 
...
22
23
24
 
25
26
 
 
27
28
29
30
31
32
33
34
35
36
37
38
39
...
33
34
35
36
37
38
 
 
 
 
 
 
 
 
 
 
39
40
41
42
 
 
 
43
44
45
46
47
48
49
50
51
52
53
 
 
 
 
 
 
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
 
73
 
 
 
74
75
76
77
78
79
 
 
 
 
 
 
80
81
82
83
84
85
86
87
88
89
90
91
 
 
 
 
 
 
 
92
93
94
0
@@ -22,10 +22,9 @@
0
 namespace 'apache' do
0
 
0
   desc 'Check that source files contain the Apache license'
0
- task 'license' do
0
+ task 'license' do |task|
0
     print 'Checking that files contain the Apache license ... '
0
- excluded = ['.class', '.png', '.jar', '.tif', 'README', 'LICENSE', 'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'KEYS']
0
- required = FileList[spec.files].exclude(*excluded).exclude(*Array($license_excluded)).select { |fn| File.file?(fn) }
0
+ required = task.prerequisites.select { |fn| File.file?(fn) }
0
     missing = required.reject { |fn|
0
       comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|<!--(.*?)-->/m).
0
         map { |match| match.compact }.flatten.join("\n")
0
0
0
0
0
0
0
0
0
0
@@ -34,58 +33,63 @@
0
     fail "#{missing.join(', ')} missing Apache License, please add it before making a release!" unless missing.empty?
0
     puts 'OK'
0
   end
0
+ task('license').prerequisites.exclude('.class', '.png', '.jar', '.tif', '.textile', '.haml',
0
+ 'README', 'LICENSE', 'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'KEYS', 'spec/spec.opts')
0
 
0
- file 'incubating'=>'package' do
0
- rm_rf 'incubating'
0
- mkpath 'incubating'
0
- print '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
- end
0
- end
0
- puts 'Done'
0
+ task 'check' do
0
+ ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment variable so we know which key to use.'
0
   end
0
 
0
- task 'sign', :incubating do |task, args|
0
- file('incubating').invoke if args.incubating
0
- sources = FileList[args.incubating ? 'incubating/*' : 'pkg/*']
0
 
0
+ file 'staged/distro'=>'package' do
0
+ puts 'Copying and signing release files ...'
0
+ mkpath 'staged/distro'
0
+ FileList['pkg/*.{gem,zip,tgz}'].each do |pkg|
0
+ cp pkg, pkg.pathmap('staged/distro/%n-incubating%x')
0
+ end
0
+ end
0
+
0
+ task 'sign'=>['KEYS', 'staged/distro'] 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
- print 'Signing release files ...'
0
- sources.each do |fn|
0
- contents = File.open(fn, 'rb') { |file| file.read }
0
- File.open(fn + '.md5', 'w') { |file| file.write MD5.hexdigest(contents) << ' ' << File.basename(fn) }
0
- File.open(fn + '.sha1', 'w') { |file| file.write SHA1.hexdigest(contents) << ' ' << File.basename(fn) }
0
- sh 'gpg', '--local-user', gpg_user, '--armor', '--output', fn + '.asc', '--detach-sig', fn, :verbose=>true
0
+ FileList['staged/distro/*.{gem,zip,tgz}'].each do |pkg|
0
+ bytes = File.open(pkg, 'rb') { |file| file.read }
0
+ File.open(pkg + '.md5', 'w') { |file| file.write MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
0
+ File.open(pkg + '.sha1', 'w') { |file| file.write SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
0
+ sh 'gpg', '--local-user', gpg_user, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
0
     end
0
+ cp 'KEYS', 'staged/distro'
0
+ end
0
+
0
+ # Publish prerequisites to distro server.
0
+ task 'publish:distro' do |task, args|
0
+ target = args.incubating ? "people.apache.org:/www/www.apache.org/dist/incubator/#{spec.name}" :
0
+ "people.apache.org:/www/www.apache.org/dist/#{spec.name}"
0
+ "people.apache.org:/www/#{spec.name}.apache.org"
0
+ puts 'Uploading packages to Apache distro ...'
0
+ sh 'rsync', '--progress', 'published/distro/*', target
0
     puts 'Done'
0
   end
0
 
0
- task 'upload', :project, :incubating, :depends=>['site', 'KEYS', 'sign'] do |task, args|
0
- fail 'No project specified' unless project
0
 
0
- target = 'people.apache.org:/www.apache.org/dist/'
0
- target << 'incubator/' if args.incubating
0
- target << "#{project}/"
0
+ file 'staged/site'=>'site' do
0
+ mkpath 'staged'
0
+ rm_rf 'staged/site'
0
+ cp_r 'site', 'staged'
0
+ end
0
 
0
- dir = task('sign').prerequisite.find { |prereq| File.directory?(prereq.name) }
0
- fail 'Please enhance sign task with directory containing files to release' unless dir
0
- puts 'Uploading packages to Apache dist ...'
0
- args = FileList["#{dir}/*", 'KEYS'].flatten << target
0
-
0
- sh 'rsync', '-progress', *args
0
+ # Publish prerequisites to Web site.
0
+ task 'publish:site' do |task, args|
0
+ target = args.incubating ? "people.apache.org:/www/incubator.apache.org/#{spec.name}" :
0
+ "people.apache.org:/www/#{spec.name}.apache.org"
0
+ puts 'Uploading Apache Web site ...'
0
+ sh 'rsync', '--progress', 'published/distro/site/', target
0
     puts 'Done'
0
   end
0
 
0
 end
0
 
0
 
0
-task 'clobber' do
0
- rm_rf 'incubating'
0
-end
0
-
0
-namespace 'release' do
0
- task 'check'=>'apache:license'
0
-end
0
+task 'stage:check'=>['apache:license', 'apache:check']
0
+task 'stage:prepare'=>['staged/distro', 'apache:sign', 'staged/site']
0
+task 'release:publish'=>['apache:publish:distro', 'apache:publish:site']
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
0
@@ -1 +1,56 @@
0
+# Licensed to the Apache Software Foundation (ASF) under one or more
0
+# contributor license agreements. See the NOTICE file distributed with this
0
+# work for additional information regarding copyright ownership. The ASF
0
+# licenses this file to you under the Apache License, Version 2.0 (the
0
+# "License"); you may not use this file except in compliance with the License.
0
+# You may obtain a copy of the License at
0
+#
0
+# http://www.apache.org/licenses/LICENSE-2.0
0
+#
0
+# Unless required by applicable law or agreed to in writing, software
0
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
0
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
0
+# License for the specific language governing permissions and limitations under
0
+# the License.
0
+
0
+
0
+# Handling of CHANGELOG.
0
+namespace 'changelog' do
0
+
0
+ task 'check'=>'CHANGELOG' do
0
+ print 'Checking that CHANGELOG indicates most recent version and today\'s date ... '
0
+ expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
0
+ header = File.readlines('CHANGELOG').first.chomp
0
+ fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
0
+ puts 'OK'
0
+ end
0
+
0
+ task 'prepare'=>'CHANGELOG' do
0
+ # Read the changes for this release.
0
+ print '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
+ changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
0
+ current = changes[spec.version.to_s]
0
+ fail "No changeset found for version #{spec.version}" unless current
0
+ File.open 'stage/CHANGES', 'w' do |file|
0
+ file.write current
0
+ end
0
+ puts 'OK'
0
+ end
0
+
0
+ task 'wrapup'=>'CHANGELOG' do
0
+ next_version = spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
0
+ print 'Adding new entry to CHANGELOG ... '
0
+ modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
0
+ File.open 'CHANGELOG', 'w' do |file|
0
+ file.write modified
0
+ end
0
+ puts 'Done'
0
+ end
0
+
0
+end
0
+
0
+task 'stage:check'=>'changelog:check'
0
+task 'stage:prepare'=>'changelog:prepare'
0
+task 'release:wrapup'=>'changelog:wrapup'
...
44
45
46
47
48
49
50
51
52
53
 
54
55
 
56
57
58
59
60
...
64
65
66
67
 
68
69
70
71
72
 
 
 
73
74
75
76
 
 
77
78
79
...
81
82
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
85
86
...
92
93
94
95
96
97
98
99
100
101
102
103
 
 
...
44
45
46
 
 
47
48
49
50
51
52
53
 
54
55
56
57
58
59
...
63
64
65
 
66
67
68
69
70
71
72
73
74
75
76
 
 
77
78
79
80
81
...
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
109
110
111
 
 
 
 
 
 
 
 
 
112
113
0
@@ -44,15 +44,14 @@
0
   require 'docter'
0
   require 'docter/server'
0
 
0
- file 'reports/specs.html'=>'reports'
0
-
0
   #Docter.filter_for(:footnote) do |html|
0
   # html.gsub(/<p id="fn(\d+)">(.*?)<\/p>/, %{<p id="fn\\1" class="footnote">\\2</p>})
0
   #end
0
 
0
   collection = Docter.collection(spec.name).using('doc/site.toc.yaml').include('doc/pages', 'LICENSE', 'CHANGELOG')
0
+ # TODO: Add coverage reports when we get them to run.
0
   template = Docter.template('doc/site.haml').
0
- include('doc/css', 'doc/images', 'doc/scripts', 'reports/specs.html', 'reports/coverage', 'rdoc', 'print/buildr.pdf')
0
+ include('doc/css', 'doc/images', 'doc/scripts', 'reports/specs.html', 'r', 'rdoc', 'print/buildr.pdf')
0
 
0
   desc 'Run Docter server on port 3000'
0
   Docter::Rake.serve 'docter', collection, template, :port=>3000
0
0
0
@@ -64,16 +63,19 @@
0
     Docter.collection(spec.name).using('doc/print.toc.yaml').include('doc/pages', 'LICENSE'),
0
     Docter.template('doc/print.haml').include('doc/css', 'doc/images'), :one_page
0
 
0
- file('site/buildr.pdf'=>'print') do |task|
0
+ file('print/buildr.pdf'=>'print') do |task|
0
     mkpath 'site'
0
     sh 'prince', 'print/index.html', '-o', task.name, '--media=print' do |ok, res|
0
       fail 'Failed to create PDF, see errors above' unless ok
0
     end
0
   end
0
+ task 'site'=>'print/buildr.pdf' do
0
+ cp 'print/buildr.pdf', 'site'
0
+ end
0
 
0
   desc 'Produce PDF'
0
- task 'pdf'=>'site/buildr.pdf' do |task|
0
- sh 'open', 'site/buildr.pdf'
0
+ task 'pdf'=>'print/buildr.pdf' do |task|
0
+ sh 'open', 'print/buildr.pdf'
0
   end
0
 
0
   task 'clobber' do
0
@@ -81,6 +83,21 @@
0
     rm_rf 'site'
0
   end
0
 
0
+ task 'site:prepare'=>'site' do
0
+ print 'Checking that we have site documentation, RDoc and PDF ... '
0
+ fail 'No PDF generated, you need to install PrinceXML!' unless File.exist?('site/buildr.pdf')
0
+ fail 'No RDocs in site directory' unless File.exist?('site/rdoc/files/lib/buildr_rb.html')
0
+ fail 'No site documentation in site directory' unless File.exist?('site/index.html')
0
+ fail 'No specifications site directory' unless File.exist?('site/specs.html')
0
+ puts 'OK'
0
+ end
0
+
0
+ task 'site:stage' do
0
+ puts 'Copying site over to release directory ...'
0
+ cp_r 'site', 'release'
0
+ puts 'Done'
0
+ end
0
+
0
 rescue LoadError
0
   puts 'Please run rake setup to install the Docter document generation library'
0
   task 'setup' do
0
@@ -92,13 +109,6 @@
0
 end
0
 
0
 
0
-namespace 'release' do
0
- task 'prepare'=>'docs' do
0
- print 'Checking that we have site documentation, RDoc and PDF ... '
0
- fail 'No PDF generated, you need to install PrinceXML!' unless File.exist?('site/buildr.pdf')
0
- fail 'No RDocs in site directory' unless File.exist?('site/rdoc/files/lib/buildr_rb.html')
0
- fail 'No site documentation in site directory' unless File.exist?('site/index.html')
0
- puts 'OK'
0
- end
0
-end
0
+task 'release:prepare'=>'site:prepare'
0
+task 'release:stage'=>'site:stage'
...
20
21
22
23
24
 
 
 
25
26
27
28
29
 
30
31
 
32
33
34
...
20
21
22
 
 
23
24
25
26
27
 
28
 
29
30
 
31
32
33
34
0
@@ -20,15 +20,15 @@
0
 desc 'Clean up all temporary directories used for running tests, creating documentation, packaging, etc.'
0
 task 'clobber'
0
 
0
-Rake::GemPackageTask.new(spec) do |pkg|
0
- pkg.need_tar = pkg.need_zip = true
0
+package = Rake::GemPackageTask.new(spec) do |pkg|
0
+ pkg.need_tar = true
0
+ pkg.need_zip = true
0
 end
0
 
0
-current = Rake::GemPackageTask.new(spec)
0
 desc 'Install the package locally'
0
-task 'install'=>"#{current.package_dir}/#{current.gem_file}" do |task|
0
+task 'install'=>"#{package.package_dir}/#{package.gem_file}" do |task|
0
   print "Installing #{spec.name} ... "
0
- args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', "#{current.package_dir}/#{current.gem_file}"]
0
+ args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', "#{package.package_dir}/#{package.gem_file}"]
0
   args.unshift('sudo') unless windows?
0
   sh *args
0
   puts 'Done'
...
13
14
15
 
 
 
 
 
 
 
16
17
18
19
20
21
22
23
24
25
26
 
 
27
28
29
30
31
32
33
34
35
36
37
38
39
 
 
40
41
42
43
44
45
46
47
48
 
49
50
51
52
53
54
55
56
57
 
 
58
59
60
61
62
63
64
 
 
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 
 
 
114
115
116
117
118
119
120
 
 
 
 
121
122
123
124
125
126
127
128
 
129
130
131
132
133
 
 
...
13
14
15
16
17
18
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
24
25
26
27
 
28
 
 
 
 
 
 
 
 
 
29
30
31
 
 
 
 
 
 
 
 
32
33
 
 
 
 
 
 
 
 
34
35
36
 
 
 
 
 
 
37
38
39
 
 
 
 
 
 
 
 
 
 
 
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43
44
45
 
 
 
 
 
 
46
47
48
49
50
 
 
 
 
 
 
 
51
52
 
 
 
53
54
55
0
@@ -13,122 +13,44 @@
0
 # License for the specific language governing permissions and limitations under
0
 # the License.
0
 
0
+# Released files are placed in this directory first, and from there published to various servers.
0
+file 'published' do |task, args|
0
+ mkpath task.name
0
+ puts "Populating published directory from #{args.staging} ..."
0
+ sh 'rsync', '--progress', "#{args.staging}/", 'published'
0
+ puts 'Done'
0
+end
0
 
0
-begin
0
- require 'rubyforge'
0
-rescue LoadError
0
- puts 'Please run rake setup to install the RubyForge gem'
0
- task 'setup' do
0
- install_gem 'rubyforge'
0
- end
0
- task 'release:check' do
0
- fail 'Please run rake setup to install the RubyForge gem'
0
- end
0
+task 'clobber' do
0
+ rm_rf 'published'
0
 end
0
 
0
-
0
 namespace 'release' do
0
-
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
- task 'check'=>'setup'
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
+ #task 'prepare'=>['setup', 'clobber', 'published'] # TODO: uncomment
0
+ task 'prepare'=>'published'
0
 
0
- # Does CHANGELOG reflects current release?
0
- task 'check' do
0
- print 'Checking that CHANGELOG indicates most recent version and today\'s date ... '
0
- expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
0
- header = File.readlines('CHANGELOG').first.chomp
0
- fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
0
- puts 'OK'
0
- end
0
+ task 'publish'
0
 
0
- # No local changes.
0
- task 'check' do
0
- print 'Checking there are no local changes ... '
0
- status = `svn status`
0
- fail "Cannot release unless all local changes are in SVN:\n#{status}" unless status.empty?
0
- fail "Cannot release unless all local changes are in Git:\n" + `git status` if `git status`[/^#\t/]
0
- puts 'OK'
0
- end
0
+ task 'wrapup'
0
+end
0
 
0
- desc 'Make a release'
0
- task 'make'=>'release:prepare' do |task|
0
- task.enhance do
0
- task('release:wrapup').invoke
0
- end
0
- end
0
+desc "Make a release using previously staged files"
0
+task 'release'=>['release:prepare', 'release:publish', 'release:wrapup']
0
 
0
- task 'rubyforge'=>'package' do
0
- if File.exist?('CHANGELOG')
0
- # Read the changes for this release.
0
- print '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
- changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
0
- current = changes[spec.version.to_s]
0
- current = changes[spec.version.to_s.split('.')[0..-2].join('.')] if !current && spec.version.to_s =~ /\.0$/
0
- fail "No changeset found for version #{spec.version}" unless current
0
- puts 'OK'
0
- end
0
 
0
- print "Uploading #{spec.version} to RubyForge ... "
0
- files = Dir.glob('pkg/*.{gem,tgz,zip}')
0
- rubyforge = RubyForge.new
0
- rubyforge.login
0
- begin
0
- if changes
0
- File.open('.changes', 'w'){|f| f.write(current)}
0
- rubyforge.userconfig.merge!('release_changes' => '.changes', 'preformatted' => true)
0
- end
0
- rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files
0
- ensure
0
- rm '.changes' if changes
0
- end
0
- puts 'Done'
0
- end
0
 
0
- # Tag this release in SVN.
0
- task 'tag' do
0
- info = `svn info` + `git svn info` # Using either svn or git-svn
0
- url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
0
- break unless url
0
- new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
0
- break if url == new_url
0
- print "Tagging release as tags/#{spec.version} ... "
0
- sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}", :verbose=>false do |ok, res|
0
- if ok
0
- puts 'Done'
0
- else
0
- puts 'Could not create tag, please do it yourself!'
0
- puts %{ svn copy #{url} #{new_url} -m "#{spec.version}"}
0
- end
0
- end
0
- end
0
-
0
- # Update lib/buildr.rb to next vesion number, add new entry in CHANGELOG.
0
- task 'next_version'=>'tag' do
0
+task 'next_version' do
0
+ ver_file = "lib/#{spec.name}.rb"
0
+ if File.exist?(ver_file)
0
     next_version = spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
0
- ver_file = "lib/#{spec.name}.rb"
0
- if File.exist?(ver_file)
0
- print "Updating #{ver_file} to next version number (#{next_version}) ... "
0
- modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
0
- File.open(ver_file, 'w') { |file| file.write modified }
0
- puts 'Done'
0
+ print "Updating #{ver_file} to next version number (#{next_version}) ... "
0
+ modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
0
+ File.open ver_file, 'w' do |file|
0
+ file.write modified
0
     end
0
-
0
- if File.exist?('CHANGELOG')
0
- print 'Adding new entry to CHANGELOG ... '
0
- modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
0
- File.open('CHANGELOG', 'w') { |file| file.write modified }
0
- puts 'Done'
0
- end
0
+ puts 'Done'
0
   end
0
-
0
- task 'wrapup'=>['tag', 'next_version']
0
-
0
 end
0
+
0
+task 'release:wrapup'=>'next_version'
...
17
18
19
 
 
 
 
 
 
20
21
22
23
 
 
 
 
24
 
25
26
27
28
 
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
 
 
 
 
 
 
 
 
 
 
 
43
44
45
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
48
49
...
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
...
17
18
19
20
21
22
23
24
25
26
 
 
 
27
28
29
30
31
32
33
34
35
 
36
37
38
39
 
 
 
 
 
 
 
 
 
 
 
40
41
42
43
44
45
46
47
48
49
50
51
52
 
 
 
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
91
92
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
0
@@ -17,33 +17,66 @@
0
 begin
0
   require 'spec/rake/spectask'
0
 
0
+ directory 'reports'
0
+ task 'clobber' do
0
+ rm 'failing' rescue nil
0
+ rm_rf 'reports'
0
+ end
0
+
0
   desc 'Run all specs'
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
+ Spec::Rake::SpecTask.new('spec'=>'reports') do |task|
0
+ task.spec_files = FileList['spec/**/common_spec.rb'] # TODO: fix back to *_
0
+ task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 'failing_examples:failing' <<
0
+ '--format' << 'html:reports/specs.html' << '--backtrace'
0
   end
0
+ file 'reports/specs.html'=>'spec'
0
 
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_files = FileList['spec/**/common_spec.rb'] # TODO: fix back to *_
0
     task.spec_opts << '--options' << 'spec/spec.opts' << '--format' << 'failing_examples:failing' << '--example' << 'failing'
0
   end
0
 
0
- desc 'Run RSpec and generate Spec and coverage reports (slow)'
0
- Spec::Rake::SpecTask.new('reports') do |task|
0
- task.spec_files = FileList['spec/**/*_spec.rb']
0
- task.spec_opts << '--format' << 'html:reports/specs.html' << '--backtrace'
0
- task.rcov = true
0
- task.rcov_opts = ['--exclude', 'spec,bin']
0
- end
0
- task 'reports' do
0
- mkpath 'reports'
0
- mv 'coverage', 'reports'
0
- end
0
+ # Useful for testing with JRuby when using Ruby and vice versa.
0
+ namespace 'spec' do
0
+=begin
0
+ # TODO: Horribly broken! Fix some other time.
0
+ desc 'Run RSpec and generate Spec and coverage reports (slow)'
0
+ Spec::Rake::SpecTask.new('rcov') do |task|
0
+ task.spec_files = FileList['spec/**/*spec.rb']
0
+ task.rcov = true
0
+ task.rcov_opts = '--exclude', 'spec,bin'
0
+ task.rcov_dir = 'coverage'
0
+ end
0
+=end
0
 
0
- task 'clobber' do
0
- rm 'failing' rescue nil
0
- rm_rf 'reports'
0
+ desc 'Run all specs specifically with Ruby'
0
+ task 'ruby' do
0
+ puts 'Running test suite using Ruby ...'
0
+ sh 'ruby -S rake spec'
0
+ end
0
+
0
+ desc 'Run all specs specifically with JRuby'
0
+ task 'jruby' do
0
+ puts 'Running test suite using JRuby ...'
0
+ sh 'jruby -S rake spec'
0
+ end
0
+
0
+ task 'prepare'=>'spec' do
0
+ print 'Checking we have specs report .... '
0
+ fail 'No specifications in reports directory!' unless File.exist?('reports/specs.html')
0
+ puts 'OK'
0
+ end
0
+ task 'prepare'=>RUBY_PLATFORM =~ /java/ ? 'ruby' : 'jruby'
0
+ # TODO: Add Rcov when we get it implemented.
0
+=begin
0
+ task 'prepare'=>'rcov' do
0
+ print 'Checking we have coverage report .... '
0
+ fail 'No coverage in reports directory!' unless File.exist?('reports/coverage')
0
+ puts 'OK'
0
+ end
0
+=end
0
+
0
   end
0
 
0
   task 'setup' do
0
@@ -58,38 +91,5 @@
0
 end
0
 
0
 
0
-# Useful for testing with JRuby when using Ruby and vice versa.
0
-namespace 'spec' do
0
- desc 'Run all specs specifically with Ruby'
0
- task 'ruby' do
0
- puts 'Running test suite using Ruby ...'
0
- sh 'ruby -S rake spec'
0
- end
0
-
0
- desc 'Run all specs specifically with JRuby'
0
- task 'jruby' do
0
- puts 'Running test suite using JRuby ...'
0
- sh 'jruby -S rake spec'
0
- end
0
-end
0
-
0
-namespace 'release' do
0
- # Full test suite depends on having JRuby, Scala and Groovy installed.
0
- task 'check' do
0
- print 'Checking that we have JRuby, Scala and Groovy available ... '
0
- fail 'Full testing requires JRuby!' unless which('jruby')
0
- fail 'Full testing requires Scala!' unless which('scala')
0
- fail 'Full testing requires Groovy!' unless which('groovy')
0
- puts 'OK'
0
- end
0
-
0
- # Release requires RSpec and test coverage reports, uploaded as part of site.
0
- # Primary test environment is Ruby (RCov), also test on JRuby.
0
- task 'prepare'=>['compile', 'reports', 'spec:jruby'] do
0
- print 'Checking that we have specs and coverage report ... '
0
- fail 'No specifications in site directory!' unless File.exist?('site/specs.html')
0
- fail 'No coverage reports in site directory!' unless File.exist?('site/coverage/index.html')
0
- puts 'OK'
0
- end
0
-end
0
+task 'release:prepare'=>'spec:prepare'
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
0
@@ -1 +1,46 @@
0
+# Licensed to the Apache Software Foundation (ASF) under one or more
0
+# contributor license agreements. See the NOTICE file distributed with this
0
+# work for additional information regarding copyright ownership. The ASF
0
+# licenses this file to you under the Apache License, Version 2.0 (the
0
+# "License"); you may not use this file except in compliance with the License.
0
+# You may obtain a copy of the License at
0
+#
0
+# http://www.apache.org/licenses/LICENSE-2.0
0
+#
0
+# Unless required by applicable law or agreed to in writing, software
0
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
0
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
0
+# License for the specific language governing permissions and limitations under
0
+# the License.
0
+
0
+
0
+begin
0
+ require 'rubyforge'
0
+rescue LoadError