public
Rubygem
Description: Apache Buildr
Homepage: http://incubator.apache.org/buildr
Clone URL: git://github.com/vic/buildr.git
Search Repo:
Brought in changes to release task from Docter, now using the same 
rakelib/*.rake files.


git-svn-id: https://svn.apache.org/repos/asf/incubator/buildr/trunk@648472 
13f79535-47bb-0310-9956-ffa450edef68
Assaf (author)
Tue Apr 15 17:29:50 -0700 2008
commit  b6bc7662c242b191e68bb97f4698f9c17fbbfdd3
tree    ccb0314bcb6f9d669c96361ad9b95b3decbed234
parent  6bf3234dd34c7ffece7f6535c586ff15eabcc2c8
...
14
15
16
 
 
 
17
18
19
20
21
...
52
53
54
55
 
 
56
57
58
59
60
61
 
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
64
65
...
14
15
16
17
18
19
20
21
22
23
24
...
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
0
@@ -14,6 +14,9 @@
0
 # the License.
0
 
0
 
0
+require 'rake/gempackagetask'
0
+
0
+
0
 def spec(platform = nil)
0
   @specs ||= {}
0
   platform ||= RUBY_PLATFORM =~ /java/ ? 'java' : 'ruby'
0
0
0
@@ -52,14 +55,31 @@
0
     spec.add_dependency 'archive-tar-minitar', '~> 0.5'
0
     spec.add_dependency 'rubyforge', '~> 0.4'
0
     unless platform =~ /java/
0
- spec.add_dependency 'rjb', '~> 1.1', '!= 1.1.3'
0
+ #spec.add_dependency 'rjb', '~> 1.1', '!= 1.1.3'
0
+ spec.add_dependency 'rjb', '~> 1.1'
0
     end
0
   end
0
 end
0
 
0
 
0
-$license_excluded = ['lib/core/progressbar.rb', 'spec/spec.opts', 'doc/css/syntax.css', '.textile', '.haml']
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
+
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
+end
0
+Rake::GemPackageTask.new(spec('java')) do |pkg|
0
+ file pkg.package_dir_path=>'compile'
0
+end
0
 
0
 namespace 'release' do
0
 
...
84
85
86
87
 
88
89
90
...
84
85
86
 
87
88
89
90
0
@@ -84,7 +84,7 @@
0
 rescue LoadError
0
   puts 'Please run rake setup to install the Docter document generation library'
0
   task 'setup' do
0
- install_gem 'docter''
0
+ install_gem 'docter', '~>1.1.3'
0
   end
0
   task 'release:check' do
0
     fail 'Please run rake setup to install the Docter document generation library'
...
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
...
20
21
22
 
 
 
 
 
 
 
 
23
24
 
 
25
 
 
 
26
27
28
29
 
30
31
32
33
34
35
36
37
0
@@ -20,26 +20,18 @@
0
 desc 'Clean up all temporary directories used for running tests, creating documentation, packaging, etc.'
0
 task 'clobber'
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
-
0
-Rake::GemPackageTask.new(spec('ruby')) do |pkg|
0
+Rake::GemPackageTask.new(spec) do |pkg|
0
   pkg.need_tar = pkg.need_zip = true
0
- file pkg.package_dir_path=>'compile'
0
- file pkg.package_dir=>'compile'
0
 end
0
-Rake::GemPackageTask.new(spec('java')) do |pkg|
0
- file pkg.package_dir_path=>'compile'
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
- install_gem "#{current.package_dir}/#{current.gem_file}"
0
+ print "Installing #{spec.name} ... "
0
+ args = [Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', "#{current.package_dir}/#{current.gem_file}"]
0
+ args.unshift('sudo') unless windows?
0
+ sh *args
0
+ puts 'Done'
0
 end
0
 
0
 desc 'Uninstall previously installed packaged'
...
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
...
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
0
@@ -41,69 +41,91 @@
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 = "#{ruby_spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
0
- header = File.readlines('CHANGELOG').first
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
   # 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
 
0
   desc 'Make a release'
0
- task 'make'=>'prepare' do
0
- enhance do
0
+ task 'make'=>'release:prepare' do |task|
0
+ task.enhance do
0
       task('release:wrapup').invoke
0
     end
0
   end
0
 
0
- task 'rubyforge'=>'pacakge' 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
- changelog = File.read(__FILE__.pathmap('%d/CHANGELOG'))
0
- changes = 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
+ 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
- File.open('.changes', 'w'){|f| f.write(current)}
0
- rubyforge.userconfig.merge!('release_changes' => '.changes', 'preformatted' => true)
0
- rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files
0
- rm '.changes'
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
- print "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
- puts "OK"
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
- next_version = ruby_spec.version.to_ints.zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
0
- print "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
- puts "OK"
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
+ end
0
 
0
- print '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
- puts "OK"
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
   end
0
 
0
   task 'wrapup'=>['tag', 'next_version']

Comments

    No one has commented yet.