buildr 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/CHANGELOG +76 -0
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +20 -37
  5. data/_buildr +3 -12
  6. data/{doc/print.toc.yaml → _jbuildr} +14 -14
  7. data/addon/buildr/cobertura.rb +5 -219
  8. data/addon/buildr/drb.rb +281 -0
  9. data/addon/buildr/emma.rb +5 -221
  10. data/addon/buildr/nailgun.rb +93 -689
  11. data/bin/buildr +0 -9
  12. data/buildr.buildfile +4 -4
  13. data/buildr.gemspec +27 -21
  14. data/doc/_layouts/default.html +82 -0
  15. data/doc/_layouts/preface.html +22 -0
  16. data/doc/{pages/artifacts.textile → artifacts.textile} +82 -42
  17. data/doc/{pages/building.textile → building.textile} +89 -47
  18. data/doc/{pages/contributing.textile → contributing.textile} +53 -45
  19. data/doc/css/default.css +6 -5
  20. data/doc/css/print.css +17 -24
  21. data/doc/css/syntax.css +7 -36
  22. data/doc/download.textile +78 -0
  23. data/doc/{pages/extending.textile → extending.textile} +45 -24
  24. data/doc/{pages/getting_started.textile → getting_started.textile} +146 -88
  25. data/doc/images/asf-logo.gif +0 -0
  26. data/doc/images/note.png +0 -0
  27. data/doc/index.textile +47 -0
  28. data/doc/{pages/languages.textile → languages.textile} +108 -54
  29. data/doc/mailing_lists.textile +25 -0
  30. data/doc/{pages/more_stuff.textile → more_stuff.textile} +152 -73
  31. data/doc/{pages/packaging.textile → packaging.textile} +181 -96
  32. data/doc/preface.textile +28 -0
  33. data/doc/{pages/projects.textile → projects.textile} +55 -40
  34. data/doc/scripts/buildr-git.rb +364 -264
  35. data/doc/scripts/gitflow.rb +296 -0
  36. data/doc/scripts/install-jruby.sh +2 -2
  37. data/doc/scripts/install-linux.sh +6 -6
  38. data/doc/scripts/install-osx.sh +2 -2
  39. data/doc/{pages/settings_profiles.textile → settings_profiles.textile} +83 -45
  40. data/doc/{pages/testing.textile → testing.textile} +77 -41
  41. data/lib/buildr.rb +5 -5
  42. data/lib/buildr/core.rb +2 -0
  43. data/lib/buildr/core/application.rb +321 -151
  44. data/lib/buildr/core/build.rb +298 -167
  45. data/lib/buildr/core/checks.rb +4 -132
  46. data/lib/buildr/core/common.rb +1 -5
  47. data/lib/buildr/core/compile.rb +3 -9
  48. data/lib/buildr/core/environment.rb +12 -3
  49. data/lib/buildr/core/filter.rb +20 -18
  50. data/lib/buildr/core/generate.rb +36 -36
  51. data/lib/buildr/core/help.rb +2 -1
  52. data/lib/buildr/core/osx.rb +46 -0
  53. data/lib/buildr/core/progressbar.rb +1 -1
  54. data/lib/buildr/core/project.rb +7 -34
  55. data/lib/buildr/core/test.rb +12 -6
  56. data/lib/buildr/core/transports.rb +13 -11
  57. data/lib/buildr/core/util.rb +14 -23
  58. data/lib/buildr/groovy/bdd.rb +3 -2
  59. data/lib/buildr/groovy/compiler.rb +1 -1
  60. data/lib/buildr/ide/eclipse.rb +31 -21
  61. data/lib/buildr/ide/idea.rb +3 -2
  62. data/lib/buildr/ide/idea7x.rb +6 -4
  63. data/lib/buildr/java/ant.rb +3 -1
  64. data/lib/buildr/java/bdd.rb +9 -7
  65. data/lib/buildr/java/cobertura.rb +243 -0
  66. data/lib/buildr/java/compiler.rb +5 -4
  67. data/lib/buildr/java/emma.rb +244 -0
  68. data/lib/buildr/java/packaging.rb +11 -8
  69. data/lib/buildr/java/pom.rb +0 -4
  70. data/lib/buildr/java/rjb.rb +1 -1
  71. data/lib/buildr/java/test_result.rb +5 -7
  72. data/lib/buildr/java/tests.rb +17 -11
  73. data/lib/buildr/packaging.rb +5 -2
  74. data/lib/buildr/packaging/archive.rb +488 -0
  75. data/lib/buildr/packaging/artifact.rb +48 -29
  76. data/lib/buildr/packaging/artifact_namespace.rb +6 -6
  77. data/lib/buildr/packaging/gems.rb +4 -4
  78. data/lib/buildr/packaging/package.rb +3 -2
  79. data/lib/buildr/packaging/tar.rb +85 -3
  80. data/lib/buildr/packaging/version_requirement.rb +172 -0
  81. data/lib/buildr/packaging/zip.rb +24 -682
  82. data/lib/buildr/packaging/ziptask.rb +313 -0
  83. data/lib/buildr/scala.rb +5 -0
  84. data/lib/buildr/scala/bdd.rb +100 -0
  85. data/lib/buildr/scala/compiler.rb +45 -4
  86. data/lib/buildr/scala/tests.rb +12 -59
  87. data/rakelib/checks.rake +57 -0
  88. data/rakelib/doc.rake +58 -68
  89. data/rakelib/jekylltask.rb +110 -0
  90. data/rakelib/package.rake +35 -37
  91. data/rakelib/release.rake +119 -35
  92. data/rakelib/rspec.rake +29 -39
  93. data/rakelib/setup.rake +21 -59
  94. data/rakelib/stage.rake +184 -26
  95. data/spec/addon/drb_spec.rb +328 -0
  96. data/spec/core/application_spec.rb +32 -25
  97. data/spec/core/build_spec.rb +336 -126
  98. data/spec/core/checks_spec.rb +292 -310
  99. data/spec/core/common_spec.rb +8 -2
  100. data/spec/core/compile_spec.rb +17 -1
  101. data/spec/core/generate_spec.rb +3 -3
  102. data/spec/core/project_spec.rb +18 -10
  103. data/spec/core/test_spec.rb +8 -1
  104. data/spec/core/transport_spec.rb +40 -3
  105. data/spec/core/util_spec.rb +67 -0
  106. data/spec/ide/eclipse_spec.rb +96 -28
  107. data/spec/ide/idea7x_spec.rb +84 -0
  108. data/spec/java/ant.rb +5 -0
  109. data/spec/java/bdd_spec.rb +12 -3
  110. data/spec/{addon → java}/cobertura_spec.rb +6 -6
  111. data/spec/{addon → java}/emma_spec.rb +5 -6
  112. data/spec/java/java_spec.rb +12 -2
  113. data/spec/java/packaging_spec.rb +31 -2
  114. data/spec/{addon → java}/test_coverage_spec.rb +3 -3
  115. data/spec/java/tests_spec.rb +5 -0
  116. data/spec/packaging/archive_spec.rb +11 -1
  117. data/spec/{core → packaging}/artifact_namespace_spec.rb +10 -2
  118. data/spec/packaging/artifact_spec.rb +44 -3
  119. data/spec/packaging/packaging_spec.rb +1 -1
  120. data/spec/sandbox.rb +17 -14
  121. data/spec/scala/bdd_spec.rb +150 -0
  122. data/spec/scala/compiler_spec.rb +27 -0
  123. data/spec/scala/scala.rb +38 -0
  124. data/spec/scala/tests_spec.rb +78 -33
  125. data/spec/spec_helpers.rb +29 -5
  126. data/spec/version_requirement_spec.rb +6 -0
  127. metadata +175 -171
  128. data/DISCLAIMER +0 -7
  129. data/doc/images/apache-incubator-logo.png +0 -0
  130. data/doc/pages/download.textile +0 -51
  131. data/doc/pages/index.textile +0 -42
  132. data/doc/pages/mailing_lists.textile +0 -17
  133. data/doc/pages/recipes.textile +0 -103
  134. data/doc/pages/troubleshooting.textile +0 -103
  135. data/doc/pages/whats_new.textile +0 -323
  136. data/doc/print.haml +0 -51
  137. data/doc/site.haml +0 -56
  138. data/doc/site.toc.yaml +0 -47
  139. data/etc/git-svn-authors +0 -16
  140. data/lib/buildr/core/application_cli.rb +0 -139
  141. data/rakelib/apache.rake +0 -191
  142. data/rakelib/changelog.rake +0 -57
  143. data/rakelib/rubyforge.rake +0 -53
  144. data/rakelib/scm.rake +0 -49
@@ -13,53 +13,137 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- # Released files are placed in this directory first, and from there published to various servers.
17
- file 'published' do |task, args|
18
- mkpath task.name
19
- puts "Populating published directory from #{args.staging} ..."
20
- sh 'rsync', '--progress', '--recursive', "#{args.staging}/", 'published'
21
- puts 'Done'
22
- end
23
16
 
24
- task 'clobber' do
25
- rm_rf 'published'
26
- end
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
27
26
 
28
- namespace 'release' do
29
- task 'prepare'=>['setup', 'clobber', 'published']
30
27
 
31
- task 'publish'
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"
32
37
 
33
- task 'wrapup'
34
- end
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', '-R', 'g+w', "/www/#{spec.name}.apache.org/*"
42
+ puts "[X] Uploaded new site to #{spec.name}.apache.org"
43
+ end.call
35
44
 
36
- desc "Make a release using previously staged files"
37
- task 'release'=>['release:prepare', 'release:publish', 'release:wrapup']
38
45
 
46
+ # Upload binary and source packages to RubyForge.
47
+ lambda do
48
+ files = FileList["_release/#{spec.version}/dist/*.{gem,tgz,zip}"]
49
+ puts "Uploading #{spec.version} to RubyForge ... "
50
+ rubyforge = RubyForge.new.configure
51
+ rubyforge.login
52
+ rubyforge.userconfig.merge!('release_changes'=>"_release/#{spec.version}/CHANGES", 'preformatted' => true)
53
+ rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version.to_s, *files
39
54
 
40
- task 'next_version' do
41
- next_version = spec.version.to_s.split('.').map { |v| v.to_i }.
42
- zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
55
+ puts "Posting news to RubyForge ... "
56
+ changes = File.read("_release/#{spec.version}/CHANGES")[/.*?\n(.*)/m, 1]
57
+ rubyforge.post_news spec.rubyforge_project.downcase, "Buildr #{spec.version} released",
58
+ "#{spec.description}\n\nNew in Buildr #{spec.version}:\n#{changes.gsub(/^/, ' ')}\n"
59
+ puts "[X] Uploaded gems and source files to #{spec.name}.rubyforge.org"
60
+ end.call
43
61
 
44
- ver_file = "lib/#{spec.name}.rb"
45
- if File.exist?(ver_file)
46
- print "Updating #{ver_file} to next version number (#{next_version}) ... "
47
- modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
48
- File.open ver_file, 'w' do |file|
49
- file.write modified
62
+
63
+ # Create an SVN tag for this release.
64
+ lambda do
65
+ info = `svn info` + `git svn info` # Using either svn or git-svn
66
+ if url = info[/^URL:/] && info.scan(/^URL: (.*)/)[0][0]
67
+ new_url = url.sub(/(trunk$)|(branches\/\w*)$/, "tags/#{spec.version}")
68
+ unless url == new_url
69
+ sh 'svn', 'copy', url, new_url, '-m', "Release #{spec.version}" do |ok, res|
70
+ if ok
71
+ puts "[X] Tagged this release as tags/#{spec.version} ... "
72
+ else
73
+ puts "Could not create tag, please do it yourself!"
74
+ puts %{ svn copy #{url} #{new_url} -m "Release #{spec.version}"}
75
+ end
76
+ end
77
+ end
50
78
  end
51
- puts 'Done'
52
- end
79
+ end.call
53
80
 
54
- spec_file = "#{spec.name}.gemspec"
55
- if File.exist?(spec_file)
56
- print "Updating #{spec_file} to next version number (#{next_version}) ... "
57
- modified = File.read(spec_file).sub(/(s(?:pec)?\.version\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
58
- File.open spec_file, 'w' do |file|
81
+
82
+ # Update CHANGELOG to next release number.
83
+ lambda do
84
+ next_version = spec.version.to_s.split('.').map { |v| v.to_i }.
85
+ zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
86
+ modified = "#{next_version} (Pending)\n\n" + File.read('CHANGELOG')
87
+ File.open 'CHANGELOG', 'w' do |file|
59
88
  file.write modified
60
89
  end
61
- puts 'Done'
90
+ puts "[X] Updated CHANGELOG and added entry for next release"
91
+ end.call
92
+
93
+
94
+ # Update source files to next release number.
95
+ lambda do
96
+ next_version = spec.version.to_s.split('.').map { |v| v.to_i }.
97
+ zip([0, 0, 1]).map { |a| a.inject(0) { |t,i| t + i } }.join('.')
98
+
99
+ ver_file = "lib/#{spec.name}.rb"
100
+ if File.exist?(ver_file)
101
+ modified = File.read(ver_file).sub(/(VERSION\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
102
+ File.open ver_file, 'w' do |file|
103
+ file.write modified
104
+ end
105
+ puts "[X] Updated #{ver_file} to next release"
106
+ end
107
+
108
+ spec_file = "#{spec.name}.gemspec"
109
+ if File.exist?(spec_file)
110
+ modified = File.read(spec_file).sub(/(s(?:pec)?\.version\s*=\s*)(['"])(.*)\2/) { |line| "#{$1}#{$2}#{next_version}#{$2}" }
111
+ File.open spec_file, 'w' do |file|
112
+ file.write modified
113
+ end
114
+ puts "[X] Updated #{spec_file} to next release"
115
+ end
116
+ end.call
117
+
118
+
119
+ # Prepare release announcement email.
120
+ lambda do
121
+ changes = File.read("_release/#{spec.version}/CHANGES")[/.*?\n(.*)/m, 1]
122
+ email = <<-EMAIL
123
+ To: users@buildr.apache.org, announce@apache.org
124
+ Subject: [ANNOUNCE] Apache Buildr #{spec.version} released
125
+
126
+ #{spec.description}
127
+
128
+ New in this release:
129
+
130
+ #{changes.gsub(/^/, ' ')}
131
+
132
+ To learn more about Buildr and get started:
133
+ http://buildr.apache.org/
134
+
135
+ Thanks!
136
+ The Apache Buildr Team
137
+
138
+ EMAIL
139
+ File.open 'announce-email.txt', 'w' do |file|
140
+ file.write email
141
+ end
142
+ puts "[X] Created release announce email template in 'announce-email.txt'"
143
+ puts email
62
144
  end
145
+
63
146
  end
64
147
 
65
- task 'release:wrapup'=>'next_version'
148
+
149
+ task(:clobber) { rm_rf '_release' }
@@ -16,68 +16,58 @@
16
16
 
17
17
  begin
18
18
  require 'spec/rake/spectask'
19
+ directory '_reports'
19
20
 
20
- directory 'reports'
21
- task 'clobber' do
22
- rm_f 'failed'
23
- rm_rf 'reports'
24
- end
25
-
26
- desc 'Run all specs'
27
- Spec::Rake::SpecTask.new('spec'=>'reports') do |task|
28
- task.spec_files = Dir['spec/**/*_spec.rb']
29
- task.spec_opts = %w{--format specdoc --format failing_examples:failed --format html:reports/specs.html --loadby mtime --backtrace}
21
+ desc "Run all specs"
22
+ Spec::Rake::SpecTask.new :spec=>'_reports' do |task|
23
+ task.spec_files = FileList['spec/**/*_spec.rb']
24
+ task.spec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
25
+ task.spec_opts = %w{--format specdoc --format failing_examples:failed --format html:_reports/specs.html --loadby mtime --backtrace}
30
26
  task.spec_opts << '--colour' if $stdout.isatty
31
27
  end
32
- file 'reports/specs.html'=>'spec'
28
+ file('_reports/specs.html') { task(:spec).invoke }
33
29
 
34
30
  desc 'Run all failed examples from previous run'
35
- Spec::Rake::SpecTask.new('failed') do |task|
36
- task.spec_files = Dir['spec/**/*_spec.rb']
31
+ Spec::Rake::SpecTask.new :failed do |task|
32
+ task.spec_files = FileList['spec/**/*_spec.rb']
37
33
  task.spec_opts = %w{--format specdoc --format failing_examples:failed --example failed --backtrace}
38
34
  task.spec_opts << '--colour' if $stdout.isatty
39
35
  end
40
36
 
41
- # TODO: Horribly broken! Fix some other time.
42
37
  desc 'Run RSpec and generate Spec and coverage reports (slow)'
43
- Spec::Rake::SpecTask.new('coverage'=>'reports') do |task|
44
- task.spec_files = Dir['spec/**/*_spec.rb']
45
- task.spec_opts = %W{--format progress --format failing_examples:failed --format html:reports/specs.html --backtrace}
38
+ Spec::Rake::SpecTask.new :coverage=>'_reports' do |task|
39
+ task.spec_files = FileList['spec/**/*_spec.rb']
40
+ task.spec_opts = %W{--format progress --format failing_examples:failed --format html:_reports/specs.html --backtrace}
46
41
  task.spec_opts << '--colour' if $stdout.isatty
47
42
  task.rcov = true
48
- task.rcov_dir = 'reports/coverage'
49
- task.rcov_opts << '--exclude / --include-file ^lib --include-file ^addon --text-summary'
43
+ task.rcov_dir = '_reports/coverage'
44
+ task.rcov_opts = %w{--exclude / --include-file ^lib --text-summary}
50
45
  end
51
- file 'reports/coverage'=>'coverage'
46
+ file('_reports/coverage') { task(:coverage).invoke }
52
47
 
53
- # Useful for testing with JRuby when using Ruby and vice versa.
54
- namespace 'spec' do
55
48
 
56
- desc 'Run all specs specifically with Ruby'
57
- task 'ruby' do
58
- puts 'Running test suite using Ruby ...'
49
+ # Useful for testing with JRuby when using Ruby and vice versa.
50
+ namespace :spec do
51
+ desc "Run all specs specifically with Ruby"
52
+ task :ruby do
53
+ puts "Running test suite using Ruby ..."
59
54
  sh 'ruby -S rake spec'
60
55
  end
61
56
 
62
- desc 'Run all specs specifically with JRuby'
63
- task 'jruby' do
64
- puts 'Running test suite using JRuby ...'
57
+ desc "Run all specs specifically with JRuby"
58
+ task :jruby do
59
+ puts "Running test suite using JRuby ..."
65
60
  sh 'jruby -S rake spec'
66
61
  end
67
-
68
62
  end
69
63
 
70
- task 'setup' do
71
- install_gem 'win32console' if windows? && !RUBY_PLATFORM[/java/] # Colors for RSpec, only on Windows platform.
64
+ task :clobber do
65
+ rm_f 'failed'
66
+ rm_rf '_reports'
72
67
  end
73
68
 
74
69
  rescue LoadError
75
- puts 'Please run rake setup to install RSpec'
76
- task 'stage:check' do
77
- fail 'Please run rake setup to install RSpec'
78
- end
70
+ puts "Buildr uses RSpec. You can install it by running rake setup"
71
+ task(:setup) { install_gem 'rcov', :version=>'~>0.8' }
72
+ task(:setup) { install_gem 'win32console' if RUBY_PLATFORM[/win32/] } # Colors for RSpec, only on Windows platform.
79
73
  end
80
-
81
-
82
- task 'stage:prepare'=>'spec'
83
- task 'stage:prepare'=>RUBY_PLATFORM =~ /java/ ? 'spec:ruby' : 'spec:jruby' # Test the *other* platform
@@ -14,73 +14,35 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require 'rubygems/source_info_cache'
18
- require 'stringio' # for Gem::RemoteFetcher
19
17
  require 'jruby' if RUBY_PLATFORM[/java/]
18
+ require 'rubygems/source_info_cache'
20
19
 
21
- # True if running on the Windows operating sytem. Different from Gem.win_platform?
22
- # which returns true if running on the Windows platform of MRI, false when using JRuby.
23
- def windows?
24
- Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
25
- end
26
-
27
- def set_java_home
28
- if !ENV['JAVA_HOME'] && RUBY_PLATFORM[/java/]
29
- ENV['JAVA_HOME'] = java.lang.System.getProperty('java.home')
30
- end
31
- fail "Please set JAVA_HOME first #{'(no need to run as sudo)' if ENV['USER'] == 'root'}" unless ENV['JAVA_HOME']
32
- end
33
-
34
- def set_gem_home
35
- ENV['GEM_HOME'] ||= Gem.path.find { |f| File.writable?(f) }
36
- end
37
-
38
- def sudo_needed?
39
- !( windows? || ENV['GEM_HOME'] )
40
- end
41
-
42
- # Finds and returns path to executable. Consults PATH environment variable.
43
- # Returns nil if executable not found.
44
- def which(name)
45
- if windows?
46
- path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| path.gsub('\\', '/') }.map { |path| "#{path}/#{name}.{exe,bat,com}" }
47
- else
48
- path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| "#{path}/#{name}" }
49
- end
50
- FileList[path].existing.first
51
- end
52
-
53
- # Execute a GemRunner command
54
- def gem_run(*args)
55
- rb_bin = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
56
- args.unshift rb_bin, '-S', 'gem'
57
- args.unshift 'sudo', 'env', 'JAVA_HOME=' + ENV['JAVA_HOME'] if sudo_needed?
58
- sh *args.map{ |a| a.inspect }.join(' ')
59
- end
60
20
 
61
- def install_gem(name, ver_requirement = ['> 0'])
62
- dep = Gem::Dependency.new(name, ver_requirement)
63
- @load_cache = true
21
+ # Install the specified gem. Options include:
22
+ # - :version -- Version requirement, e.g. '1.2' or '~> 1.2'
23
+ # - :source -- Gem repository, e.g. 'http://gems.github.com'
24
+ def install_gem(name, options = {})
25
+ dep = Gem::Dependency.new(name, options[:version] || '>0')
64
26
  if Gem::SourceIndex.from_installed_gems.search(dep).empty?
65
- spec = Gem::SourceInfoCache.search(dep, true, @load_cache).last
66
- fail "#{dep} not found in local or remote repository!" unless spec
67
- puts "Installing #{spec.full_name} ..."
68
- args = ['install']
69
- args.push '--install-dir', ENV['GEM_HOME'] if ENV['GEM_HOME']
70
- args.push spec.name, '-v', spec.version.to_s
71
- gem_run *args
72
- @load_cache = false # Just update the Gem cache once
27
+ puts "Installing #{name} ..."
28
+ rb_bin = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
29
+ args = []
30
+ args << 'sudo' << 'env' << "JAVA_HOME=#{ENV['JAVA_HOME']}" if sudo_needed?
31
+ args << rb_bin << '-S' << 'gem' << 'install' << name
32
+ args << '--version' << dep.version_requirements.to_s
33
+ args << '--source' << options[:source] if options[:source]
34
+ args << '--source' << 'http://gems.rubyforge.org'
35
+ args << '--install-dir' << ENV['GEM_HOME'] if ENV['GEM_HOME']
36
+ sh *args
73
37
  end
74
38
  end
75
39
 
76
- # Setup environment for running this Rakefile (RSpec, Docter, etc).
40
+
41
+ # Setup environment for running this Rakefile (RSpec, Jekyll, etc).
77
42
  desc "If you're building from sources, run this task first to setup the necessary dependencies."
78
- missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
79
- task 'setup' do
80
- set_java_home
81
- set_gem_home
43
+ task :setup do
44
+ missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
82
45
  missing.each do |dep|
83
- install_gem dep.name, dep.version_requirements
46
+ install_gem dep.name, :version=>dep.version_requirements
84
47
  end
85
48
  end
86
- puts "Missing Gems #{missing.join(', ')}, please run rake setup first!" unless missing.empty?
@@ -14,35 +14,193 @@
14
14
  # the License.
15
15
 
16
16
 
17
- # Staged files are copied to this directory first, and from there uploaded to the staging server.
18
- directory 'staged'
17
+ require 'digest/md5'
18
+ require 'digest/sha1'
19
19
 
20
- task 'clobber' do
21
- rm_rf 'staged'
20
+ begin # Releases upload Gems to RubyForge.
21
+ require 'rubyforge'
22
+ rescue LoadError
23
+ task(:setup) { install_gem 'rubyforge' }
22
24
  end
23
25
 
24
- namespace 'stage' do
25
- # stage:check verifies that we're able to stage a release: check for a changelog,
26
- # local changes, run all the test cases, etc. You can add more actions, e.g.
27
- # checking license files, spell checking documentation.
28
- task 'check'=>['setup', 'clobber']
29
-
30
- # stage:prepare prepares all the files necessary for making a successful release:
31
- # binary and source packages, documentation, Web site, change file, checksums, etc.
32
- # This task depends on stage:check, and also performs its own verification of the
33
- # produced artifacts. Staged files are placed in the staged directory.
34
- task 'prepare'=>'staged'
35
-
36
- # stage:upload moves the stage directory to the staging server.
37
- task 'upload' do |task, args|
38
- puts "Uploading staged directory to #{args.staging} ..."
39
- sh 'rsync', '--progress', '--recursive', 'staged/', args.staging
40
- puts 'Done'
41
- end
26
+
27
+ task :prepare do |task, args|
28
+ # Make sure we're doing a release from checked code.
29
+ lambda do
30
+ puts "Checking there are no local changes ... "
31
+ svn = `svn status`
32
+ fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
33
+ git = `git status`
34
+ fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^#\t/]
35
+ puts "[X] There are no local changes, everything is in source control"
36
+ end.call
37
+
38
+ # Make sure we have a valid CHANGELOG entry for this release.
39
+ lambda do
40
+ puts "Checking that CHANGELOG indicates most recent version and today's date ... "
41
+ expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
42
+ header = File.readlines('CHANGELOG').first.chomp
43
+ fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
44
+ puts "[x] CHANGELOG indicates most recent version and today's date"
45
+ end.call
46
+
47
+ # Need GPG to sign the packages.
48
+ lambda do
49
+ args.gpg or fail "Please run with gpg=<argument for gpg --local-user>"
50
+ fail "No GPG user #{args.gpg}" if `gpg2 --list-keys #{args.gpg}`.empty?
51
+ end.call
52
+
53
+ task(:license).invoke
54
+ task(:dependency).invoke
55
+
56
+ # Need JRuby, Scala and Groovy installed to run all the specs.
57
+ lambda do
58
+ puts "Checking that we have JRuby, Scala and Groovy available ... "
59
+ sh 'jruby --version'
60
+ sh 'scala -version'
61
+ sh 'groovy -version'
62
+ puts "[X] We have JRuby, Scala and Groovy"
63
+ end.call
64
+
65
+ # Need RubyForge to upload new release files.
66
+ lambda do
67
+ puts "[!] Make sure you have admin privileges to make a release on RubyForge"
68
+ rubyforge = RubyForge.new.configure
69
+ rubyforge.login
70
+ rubyforge.scrape_project(spec.name)
71
+ end.call
72
+
73
+ # We will be speccing in one platform, so also spec the other one.
74
+ task(RUBY_PLATFORM =~ /java/ ? 'spec:ruby' : 'spec:jruby').invoke # Test the *other* platform
75
+ end
76
+
77
+
78
+ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
79
+ mkpath '_staged'
80
+
81
+ # Start by figuring out what has changed.
82
+ lambda do
83
+ puts "Looking for changes between this release and previous one ..."
84
+ pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
85
+ changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
86
+ current = changes[spec.version.to_s]
87
+ fail "No changeset found for version #{spec.version}" unless current
88
+ File.open '_staged/CHANGES', 'w' do |file|
89
+ file.write "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})\n"
90
+ file.write current
91
+ end
92
+ puts "[X] Listed most recent changed in _staged/CHANGES"
93
+ end.call
94
+
95
+ # Create the packages (gem, tarball) and sign them. This requires user
96
+ # intervention so the earlier we do it the better.
97
+ lambda do
98
+ puts "Creating and signing release packages ..."
99
+ task(:package).invoke
100
+ mkpath '_staged/dist'
101
+ FileList['pkg/*.{gem,zip,tgz}'].each do |source|
102
+ pkg = source.pathmap('_staged/dist/%n%x')
103
+ cp source, pkg
104
+ bytes = File.open(pkg, 'rb') { |file| file.read }
105
+ File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
106
+ File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
107
+ sh 'gpg2', '--local-user', args.gpg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
108
+ end
109
+ cp 'etc/KEYS', '_staged'
110
+ puts "[X] Created and signed release packages in _staged/dist"
111
+ end.call
112
+
113
+ # The download page should link to the new binaries/sources, and we
114
+ # want to do that before generating the site/documentation.
115
+ lambda do
116
+ puts "Updating download page with links to release packages ... "
117
+ url = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
118
+ rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
119
+ name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
120
+ %{| "#{name}":#{url}/#{name} | "#{md5}":#{url}/#{name}.md5 | "Sig":#{url}/#{name}.asc |}
121
+ }
122
+ textile = <<-TEXTILE
123
+ h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
124
+
125
+ |_. Package |_. MD5 Checksum |_. PGP |
126
+ #{rows.join("\n")}
127
+
128
+ p>. ("Release signing keys":#{url}/KEYS)
129
+ TEXTILE
130
+ file_name = 'doc/download.textile'
131
+ print "Adding download links to #{file_name} ... "
132
+ modified = File.read(file_name).sub(/^h2\(#dist\).*$/) { |header| "#{header}\n\n#{textile}" }
133
+ File.open file_name, 'w' do |file|
134
+ file.write modified
135
+ end
136
+ puts "[X] Updated #{file_name}"
137
+ end.call
138
+
139
+
140
+ # Now we can create the Web site, this includes running specs, coverage report, etc.
141
+ # This will take a while, so we want to do it as last step before upload.
142
+ lambda do
143
+ puts "Creating new Web site"
144
+ task(:site).invoke
145
+ cp_r '_site', '_staged/site'
146
+ puts "[X] Created new Web site in _staged/site"
147
+ end.call
148
+
149
+
150
+ # Move everything over to people.apache.org so we can vote on it.
151
+ lambda do
152
+ url = "people.apache.org:~/public_html/#{spec.name}/#{spec.version}"
153
+ puts "Uploading _staged directory to #{url} ..."
154
+ sh 'rsync', '--progress', '--recursive', '_staged/', url
155
+ puts "[X] Uploaded _staged directory to #{url}"
156
+ end.call
42
157
 
43
- # Put anything that happens post staging here, e.g. release vote email template.
44
- task 'wrapup'
158
+
159
+ # Prepare a release vote email. In the distant future this will also send the
160
+ # email for you and vote on it.
161
+ lambda do
162
+ # Need to know who you are on Apache, local user may be different (see .ssh/config).
163
+ whoami = `ssh people.apache.org whoami`.strip
164
+ base_url = "http://people.apache.org/~#{whoami}/buildr/#{spec.version}"
165
+ # Need changes for this release only.
166
+ changelog = File.read('CHANGELOG').scan(/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/)
167
+ changes = changelog[0][2]
168
+ previous_version = changelog[1][1]
169
+
170
+ email = <<-EMAIL
171
+ To: dev@buildr.apache.org
172
+ Subject: [VOTE] Buildr #{spec.version} release
173
+
174
+ We're voting on the source distributions available here:
175
+ #{base_url}/dist/
176
+
177
+ Specifically:
178
+ #{base_url}/dist/buildr-#{spec.version}.tgz
179
+ #{base_url}/dist/buildr-#{spec.version}.zip
180
+
181
+ The documentation generated for this release is available here:
182
+ #{base_url}/site/
183
+ #{base_url}/site/buildr.pdf
184
+
185
+ The official specification against which this release was tested:
186
+ #{base_url}/site/specs.html
187
+
188
+ Test coverage report:
189
+ #{base_url}/site/coverage/index.html
190
+
191
+
192
+ The following changes were made since #{previous_version}:
193
+
194
+ #{changes.gsub(/^/, ' ')}
195
+ EMAIL
196
+ File.open 'vote-email.txt', 'w' do |file|
197
+ file.write email
198
+ end
199
+ puts "[X] Created release vote email template in 'vote-email.txt'"
200
+ puts email
201
+ end.call
202
+
45
203
  end
46
204
 
47
- desc 'Stage files for the release, upload them to staging server'
48
- task 'stage'=>['stage:check', 'stage:prepare', 'stage:upload', 'stage:wrapup']
205
+
206
+ task(:clobber) { rm_rf '_staged' }