buildrizpack 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,128 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ if !RUBY_PLATFORM[/java/]
17
+ gem 'rdoc'
18
+ require 'rdoc/task'
19
+ desc "Creates a symlink to rake's lib directory to support combined rdoc generation"
20
+ file "rake/lib" do
21
+ rake_path = $LOAD_PATH.find { |p| File.exist? File.join(p, "rake.rb") }
22
+ mkdir_p "rake"
23
+ File.symlink(rake_path, "rake/lib")
24
+ end
25
+
26
+ file "rdoc/installation.dtd" do
27
+ mkdir_p "rdoc"
28
+ File.symlink("installation.dtd", "rdoc/installation.dtd")
29
+ end
30
+
31
+ desc "Generate RDoc documentation in rdoc/"
32
+ RDoc::Task.new :rdoc do |rdoc|
33
+ rdoc.rdoc_dir = 'rdoc'
34
+ rdoc.title = spec.name
35
+ rdoc.options = spec.rdoc_options.clone
36
+ rdoc.rdoc_files.include('lib/**/*.rb')
37
+ rdoc.rdoc_files.include spec.extra_rdoc_files
38
+
39
+ # include rake source for better inheritance rdoc
40
+ rdoc.rdoc_files.include('rake/lib/**.rb')
41
+ end
42
+ task :rdoc => ["rake/lib", "rdoc/installation.dtd" ]
43
+
44
+ begin
45
+ require 'jekylltask'
46
+ module TocFilter
47
+ def toc(input)
48
+ output = "<ol class=\"toc\">"
49
+ input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).each do |entry|
50
+ id = (entry[1][/^id=(['"])(.*)\1$/, 2] rescue nil)
51
+ title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
52
+ if id
53
+ output << %{<li><a href="##{id}">#{title}</a></li>}
54
+ else
55
+ output << %{<li>#{title}</li>}
56
+ end
57
+ end
58
+ output << "</ol>"
59
+ output
60
+ end
61
+ end
62
+ Liquid::Template.register_filter(TocFilter)
63
+
64
+ desc "Generate Buildr documentation in _site/"
65
+ JekyllTask.new :jekyll do |task|
66
+ task.source = 'doc'
67
+ task.target = '_site'
68
+ end
69
+
70
+ rescue LoadError
71
+ puts "Buildr uses the jekyll gem to generate the Web site. You can install it by running bundler"
72
+ end
73
+
74
+ if `pygmentize -V`.empty?
75
+ puts "Buildr uses the Pygments python library. You can install it by running 'sudo easy_install Pygments'"
76
+ end
77
+
78
+ desc "Generate Buildr documentation as buildr.pdf"
79
+ file 'buildr.pdf'=>'_site' do |task|
80
+ pages = File.read('_site/preface.html').scan(/<li><a href=['"]([^'"]+)/).flatten.map { |f| "_site/#{f}" }
81
+ sh 'prince', '--input=html', '--no-network', '--log=prince_errors.log', "--output=#{task.name}", '_site/preface.html', *pages
82
+ end
83
+
84
+ desc "Build a copy of the Web site in the ./_site"
85
+ task :site=>['_site', :rdoc, '_reports/specs.html', '_reports/coverage', 'buildr.pdf'] do
86
+ cp_r 'rdoc', '_site'
87
+ fail 'No RDocs in site directory' unless File.exist?('_site/rdoc/lib/buildr_rb.html')
88
+ cp '_reports/specs.html', '_site'
89
+ cp_r '_reports/coverage', '_site'
90
+ fail 'No coverage report in site directory' unless File.exist?('_site/coverage/index.html')
91
+ cp 'CHANGELOG', '_site'
92
+ open("_site/.htaccess", "w") do |htaccess|
93
+ htaccess << %Q{
94
+ <FilesMatch "CHANGELOG">
95
+ ForceType 'text/plain; charset=UTF-8'
96
+ </FilesMatch>
97
+ }
98
+ end
99
+ cp 'buildr.pdf', '_site'
100
+ fail 'No PDF in site directory' unless File.exist?('_site/buildr.pdf')
101
+ puts 'OK'
102
+ end
103
+
104
+ # Publish prerequisites to Web site.
105
+ task 'publish'=>:site do
106
+ target = "people.apache.org:/www/#{spec.name}.apache.org/"
107
+ puts "Uploading new site to #{target} ..."
108
+ sh 'rsync', '--progress', '--recursive', '--delete', '_site/', target
109
+ sh 'ssh', 'people.apache.org', 'chmod', '-f', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
110
+ puts "Done"
111
+ end
112
+
113
+ # Update HTML + PDF documentation (but not entire site; no specs, coverage, etc.)
114
+ task 'publish-doc' => ['buildr.pdf', '_site'] do
115
+ cp 'buildr.pdf', '_site'
116
+ target = "people.apache.org:/www/#{spec.name}.apache.org/"
117
+ puts "Uploading new site to #{target} ..."
118
+ sh 'rsync', '--progress', '--recursive', '_site/', target # Note: no --delete
119
+ sh 'ssh', 'people.apache.org', 'chmod', '-f', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
120
+ puts "Done"
121
+ end
122
+
123
+ task :clobber do
124
+ rm_rf '_site'
125
+ rm_f 'buildr.pdf'
126
+ rm_f 'prince_errors.log'
127
+ end
128
+ end
@@ -0,0 +1,39 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ namespace :metrics do
17
+ desc 'run Saikuro reports'
18
+ task :saikuro do
19
+ gem 'atoulme-Saikuro'
20
+ require 'saikuro'
21
+ output_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "_reports", "saikuro"))
22
+ base_dir = Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), "..")))
23
+ rb_files = ["lib", "addon"].collect { |folder|
24
+ FileList[File.expand_path(File.join(File.dirname(__FILE__), "..", folder, "**", "*.rb"))]
25
+ }.flatten.collect {|path|
26
+ Pathname.new(path).relative_path_from(base_dir).to_s
27
+ }
28
+ SaikuroRunner.new.run(rb_files, output_dir)
29
+ end
30
+
31
+ desc 'generate ccn treemap'
32
+ task :ccn_treemap do
33
+ require 'saikuro_treemap'
34
+ SaikuroTreemap.generate_treemap :code_dirs => ['lib', 'addon'], :output_file => "_reports/saikuro_treemap.html"
35
+ end
36
+ end
37
+
38
+ desc 'Run all metrics tools'
39
+ task :metrics => ["metrics:saikuro", "metrics:ccn_treemap"]
@@ -0,0 +1,63 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'rubygems/package_task'
18
+
19
+
20
+ package = Gem::PackageTask.new(spec) do |pkg|
21
+ pkg.need_tar = true
22
+ pkg.need_zip = true
23
+ end
24
+
25
+ desc "Install Buildr from source"
26
+ task :install=>["#{package.package_dir}/#{package.gem_spec.file_name}"] do |task|
27
+ print "Installing #{spec.name} ... "
28
+ args = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', "#{package.package_dir}/#{package.gem_spec.file_name}"
29
+ args.unshift('sudo') if sudo_needed?
30
+ sh *args
31
+ puts "[x] Installed Buildr #{spec.version}"
32
+ end
33
+
34
+ desc "Uninstall previous rake install"
35
+ task :uninstall do |task|
36
+ puts "Uninstalling #{spec.name} ... "
37
+ args = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'uninstall', spec.name, '--version', spec.version.to_s
38
+ args.unshift('sudo') if sudo_needed?
39
+ sh *args
40
+ puts "[x] Uninstalled Buildr #{spec.version}"
41
+ end
42
+
43
+
44
+ # We also need the other packages (JRuby if building on Ruby, and vice versa)
45
+ # Must call new with block, even if block does nothing, otherwise bad things happen.
46
+ @specs.values.each do |s|
47
+ Gem::PackageTask.new(s) { |task| }
48
+ end
49
+
50
+
51
+ desc "Upload snapshot packages over to people.apache.org"
52
+ task :snapshot=>[:package] do
53
+ rm_rf '_snapshot' # Always start with empty directory
54
+ puts "Copying existing gems from Apache"
55
+ sh 'rsync', '--progress', '--recursive', 'people.apache.org:public_html/buildr/snapshot/', '_snapshot/'
56
+ puts "Copying new gems over"
57
+ cp FileList['pkg/{*.gem,*.tgz,*.zip}'], '_snapshot/gems'
58
+ puts "Generating gem index ..."
59
+ sh 'gem', 'generate_index', '--directory', '_snapshot'
60
+ puts "Copying gem and index back to Apache"
61
+ sh 'rsync', '--progress', '--recursive', '_snapshot/', 'people.apache.org:public_html/buildr/snapshot/'
62
+ end
63
+ task(:clobber) { rm_rf '_snapshot' }
@@ -0,0 +1,75 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'rubygems/package_task'
18
+
19
+
20
+ package = Gem::PackageTask.new(spec) do |pkg|
21
+ pkg.need_tar = true
22
+ pkg.need_zip = true
23
+ end
24
+
25
+ desc "Install Buildr from source"
26
+ task :install=>["#{package.package_dir}/#{package.gem_spec.file_name}"] do |task|
27
+ print "Installing #{spec.name} ... "
28
+ args = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', "#{package.package_dir}/#{package.gem_spec.file_name}"
29
+ args.unshift('sudo') if sudo_needed?
30
+ sh *args
31
+ puts "[x] Installed Buildr #{spec.version}"
32
+ end
33
+
34
+ desc "Uninstall previous rake install"
35
+ task :uninstall do |task|
36
+ puts "Uninstalling #{spec.name} ... "
37
+ args = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'uninstall', spec.name, '--version', spec.version.to_s
38
+ args.unshift('sudo') if sudo_needed?
39
+ sh *args
40
+ puts "[x] Uninstalled Buildr #{spec.version}"
41
+ end
42
+
43
+
44
+ if Dir.glob(File.join('lib','**', '*.java')).size > 0
45
+ desc "Compile Java libraries used by Buildr"
46
+ task :compile do
47
+ puts "Compiling Java libraries ..."
48
+ args = Config::CONFIG['ruby_install_name'], File.expand_path(RUBY_PLATFORM[/java/] ? '_jbuildr' : '_buildr'), '--buildfile', 'buildr.buildfile', 'compile'
49
+ args << '--trace' if Rake.application.options.trace
50
+ sh *args
51
+ end
52
+ file Gem::PackageTask.new(spec).package_dir => :compile
53
+ file Gem::PackageTask.new(spec).package_dir_path => :compile
54
+ end
55
+
56
+ # We also need the other packages (JRuby if building on Ruby, and vice versa)
57
+ # Must call new with block, even if block does nothing, otherwise bad things happen.
58
+ @specs.values.each do |s|
59
+ Gem::PackageTask.new(s) { |task| }
60
+ end
61
+
62
+
63
+ desc "Upload snapshot packages over to people.apache.org"
64
+ task :snapshot=>[:package] do
65
+ rm_rf '_snapshot' # Always start with empty directory
66
+ puts "Copying existing gems from Apache"
67
+ sh 'rsync', '--progress', '--recursive', 'people.apache.org:public_html/buildr/snapshot/', '_snapshot/'
68
+ puts "Copying new gems over"
69
+ cp FileList['pkg/{*.gem,*.tgz,*.zip}'], '_snapshot/gems'
70
+ puts "Generating gem index ..."
71
+ sh 'gem', 'generate_index', '--directory', '_snapshot'
72
+ puts "Copying gem and index back to Apache"
73
+ sh 'rsync', '--progress', '--recursive', '_snapshot/', 'people.apache.org:public_html/buildr/snapshot/'
74
+ end
75
+ task(:clobber) { rm_rf '_snapshot' }
@@ -0,0 +1,160 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ task :release do
18
+ # First, we need to get all the staged files from Apache to _release.
19
+ mkpath '_release'
20
+ lambda do
21
+ url = "people.apache.org:~/public_html/#{spec.name}/#{spec.version}"
22
+ puts "Populating _release directory from #{url} ..."
23
+ sh 'rsync', '--progress', '--recursive', url, '_release'
24
+ puts "[X] Staged files are now in _release"
25
+ end.call
26
+
27
+
28
+ # Upload binary and source packages and new Web site
29
+ lambda do
30
+ target = "people.apache.org:/www/www.apache.org/dist/#{spec.name}/#{spec.version}"
31
+ puts "Uploading packages to www.apache.org/dist ..."
32
+ host, remote_dir = target.split(':')
33
+ sh 'ssh', host, 'rm', '-rf', remote_dir rescue nil
34
+ sh 'ssh', host, 'mkdir', remote_dir
35
+ sh 'rsync', '--progress', '--recursive', "_release/#{spec.version}/dist/", target
36
+ puts "[X] Uploaded packages to www.apache.org/dist"
37
+
38
+ target = "people.apache.org:/www/#{spec.name}.apache.org/"
39
+ puts "Uploading new site to #{spec.name}.apache.org ..."
40
+ sh 'rsync', '--progress', '--recursive', '--delete', "_release/#{spec.version}/site/", target
41
+ sh 'ssh', 'people.apache.org', 'chmod', '-f', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
42
+ puts "[X] Uploaded new site to #{spec.name}.apache.org"
43
+ end.call
44
+
45
+
46
+ # Upload binary and source packages to RubyForge.
47
+ lambda do
48
+ # update rubyforge projects, processors, etc. in local config
49
+ sh 'rubyforge', 'config'
50
+ files = FileList["_release/#{spec.version}/dist/*.{gem,tgz,zip}"]
51
+ puts "Uploading #{spec.version} to RubyForge ... "
52
+ rubyforge = RubyForge.new.configure
53
+ rubyforge.login
54
+ rubyforge.userconfig.merge!('release_changes'=>"_release/#{spec.version}/CHANGES", 'preformatted' => true)
55
+ rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version.to_s, *files
56
+
57
+ puts "Posting news to RubyForge ... "
58
+ changes = File.read("_release/#{spec.version}/CHANGES")[/.*?\n(.*)/m, 1]
59
+ rubyforge.post_news spec.rubyforge_project.downcase, "Buildr #{spec.version} released",
60
+ "#{spec.description}\n\nNew in Buildr #{spec.version}:\n#{changes.gsub(/^/, ' ')}\n"
61
+ puts "[X] Uploaded gems and source files to #{spec.name}.rubyforge.org"
62
+ end.call
63
+
64
+ # Push gems to Rubyforge.org / Gemcutter
65
+ lambda do
66
+ files = FileList["_release/#{spec.version}/dist/*.{gem}"]
67
+ files.each do |f|
68
+ puts "Push gem #{f} to RubyForge.org / Gemcutter ... "
69
+ `gem push #{f}`
70
+ end
71
+ puts "[X] Pushed gems to Rubyforge.org / Gemcutter"
72
+ end
73
+
74
+ # Create an SVN tag for this release.
75
+ lambda do
76
+ info = `svn info` + `git svn info` # Using either svn or git-svn
77
+ if url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
78
+ new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
79
+ unless url == new_url
80
+ sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}" do |ok, res|
81
+ if ok
82
+ puts "[X] Tagged this release as tags/#{spec.version} ... "
83
+ else
84
+ puts "Could not create tag, please do it yourself!"
85
+ puts %{ svn copy #{url} #{new_url} -m "Release #{spec.version}"}
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end.call
91
+
92
+
93
+ # Update CHANGELOG to next release number.
94
+ lambda do
95
+ next_version = spec.version.to_s.split('.').map { |v| v.to_i }.
96
+ zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
97
+ modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
98
+ File.open 'CHANGELOG', 'w' do |file|
99
+ file.write modified
100
+ end
101
+ puts "[X] Updated CHANGELOG and added entry for next release"
102
+ end.call
103
+
104
+
105
+ # Update source files to next release number.
106
+ lambda do
107
+ next_version = spec.version.to_s.split('.').map { |v| v.to_i }.
108
+ zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
109
+
110
+ ver_file = "lib/#{spec.name}.rb"
111
+ if File.exist?(ver_file)
112
+ modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
113
+ File.open ver_file, 'w' do |file|
114
+ file.write modified
115
+ end
116
+ puts "[X] Updated #{ver_file} to next release"
117
+ end
118
+
119
+ spec_file = "#{spec.name}.gemspec"
120
+ if File.exist?(spec_file)
121
+ modified = File.read(spec_file).sub(/(s(?:pec)?\.version\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
122
+ File.open spec_file, 'w' do |file|
123
+ file.write modified
124
+ end
125
+ puts "[X] Updated #{spec_file} to next release"
126
+ end
127
+ end.call
128
+
129
+
130
+ # Prepare release announcement email.
131
+ lambda do
132
+ changes = File.read("_release/#{spec.version}/CHANGES")[/.*?\n(.*)/m, 1]
133
+ email = <<-EMAIL
134
+ To: users@buildr.apache.org, announce@apache.org
135
+ Subject: [ANNOUNCE] Apache Buildr #{spec.version} released
136
+
137
+ #{spec.description}
138
+
139
+ New in this release:
140
+
141
+ #{changes.gsub(/^/, ' ')}
142
+
143
+ To learn more about Buildr and get started:
144
+ http://buildr.apache.org/
145
+
146
+ Thanks!
147
+ The Apache Buildr Team
148
+
149
+ EMAIL
150
+ File.open 'announce-email.txt', 'w' do |file|
151
+ file.write email
152
+ end
153
+ puts "[X] Created release announce email template in 'announce-email.txt'"
154
+ puts email
155
+ end
156
+
157
+ end
158
+
159
+
160
+ task(:clobber) { rm_rf '_release' }