assaf-buildr 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/CHANGELOG +887 -0
  2. data/DISCLAIMER +7 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.rdoc +146 -0
  6. data/Rakefile +62 -0
  7. data/_buildr +38 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +236 -0
  10. data/addon/buildr/emma.rb +238 -0
  11. data/addon/buildr/hibernate.rb +142 -0
  12. data/addon/buildr/javacc.rb +85 -0
  13. data/addon/buildr/jdepend.rb +60 -0
  14. data/addon/buildr/jetty.rb +248 -0
  15. data/addon/buildr/jibx.rb +86 -0
  16. data/addon/buildr/nailgun.rb +817 -0
  17. data/addon/buildr/openjpa.rb +90 -0
  18. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  21. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  25. data/addon/buildr/xmlbeans.rb +93 -0
  26. data/bin/buildr +28 -0
  27. data/buildr.buildfile +53 -0
  28. data/buildr.gemspec +58 -0
  29. data/doc/css/default.css +228 -0
  30. data/doc/css/print.css +100 -0
  31. data/doc/css/syntax.css +52 -0
  32. data/doc/images/apache-incubator-logo.png +0 -0
  33. data/doc/images/buildr-hires.png +0 -0
  34. data/doc/images/buildr.png +0 -0
  35. data/doc/images/favicon.png +0 -0
  36. data/doc/images/growl-icon.tiff +0 -0
  37. data/doc/images/note.png +0 -0
  38. data/doc/images/project-structure.png +0 -0
  39. data/doc/images/tip.png +0 -0
  40. data/doc/images/zbuildr.tif +0 -0
  41. data/doc/pages/artifacts.textile +207 -0
  42. data/doc/pages/building.textile +240 -0
  43. data/doc/pages/contributing.textile +208 -0
  44. data/doc/pages/download.textile +62 -0
  45. data/doc/pages/extending.textile +175 -0
  46. data/doc/pages/getting_started.textile +273 -0
  47. data/doc/pages/index.textile +42 -0
  48. data/doc/pages/languages.textile +407 -0
  49. data/doc/pages/mailing_lists.textile +17 -0
  50. data/doc/pages/more_stuff.textile +286 -0
  51. data/doc/pages/packaging.textile +427 -0
  52. data/doc/pages/projects.textile +274 -0
  53. data/doc/pages/recipes.textile +103 -0
  54. data/doc/pages/settings_profiles.textile +274 -0
  55. data/doc/pages/testing.textile +212 -0
  56. data/doc/pages/troubleshooting.textile +103 -0
  57. data/doc/pages/whats_new.textile +323 -0
  58. data/doc/print.haml +51 -0
  59. data/doc/print.toc.yaml +29 -0
  60. data/doc/scripts/buildr-git.rb +412 -0
  61. data/doc/scripts/install-jruby.sh +44 -0
  62. data/doc/scripts/install-linux.sh +64 -0
  63. data/doc/scripts/install-osx.sh +52 -0
  64. data/doc/site.haml +56 -0
  65. data/doc/site.toc.yaml +47 -0
  66. data/etc/KEYS +151 -0
  67. data/etc/git-svn-authors +16 -0
  68. data/lib/buildr.rb +35 -0
  69. data/lib/buildr/core.rb +27 -0
  70. data/lib/buildr/core/application.rb +489 -0
  71. data/lib/buildr/core/application_cli.rb +139 -0
  72. data/lib/buildr/core/build.rb +311 -0
  73. data/lib/buildr/core/checks.rb +382 -0
  74. data/lib/buildr/core/common.rb +154 -0
  75. data/lib/buildr/core/compile.rb +596 -0
  76. data/lib/buildr/core/environment.rb +120 -0
  77. data/lib/buildr/core/filter.rb +362 -0
  78. data/lib/buildr/core/generate.rb +195 -0
  79. data/lib/buildr/core/help.rb +118 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +892 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +558 -0
  84. data/lib/buildr/core/util.rb +289 -0
  85. data/lib/buildr/groovy.rb +18 -0
  86. data/lib/buildr/groovy/bdd.rb +105 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/ide.rb +19 -0
  89. data/lib/buildr/ide/eclipse.rb +212 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +189 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +210 -0
  94. data/lib/buildr/java.rb +23 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +449 -0
  97. data/lib/buildr/java/commands.rb +211 -0
  98. data/lib/buildr/java/compiler.rb +348 -0
  99. data/lib/buildr/java/deprecated.rb +141 -0
  100. data/lib/buildr/java/jruby.rb +117 -0
  101. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  102. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  103. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  104. data/lib/buildr/java/packaging.rb +713 -0
  105. data/lib/buildr/java/pom.rb +178 -0
  106. data/lib/buildr/java/rjb.rb +155 -0
  107. data/lib/buildr/java/test_result.rb +308 -0
  108. data/lib/buildr/java/tests.rb +324 -0
  109. data/lib/buildr/java/version_requirement.rb +172 -0
  110. data/lib/buildr/packaging.rb +21 -0
  111. data/lib/buildr/packaging/artifact.rb +730 -0
  112. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  113. data/lib/buildr/packaging/artifact_search.rb +140 -0
  114. data/lib/buildr/packaging/gems.rb +102 -0
  115. data/lib/buildr/packaging/package.rb +233 -0
  116. data/lib/buildr/packaging/tar.rb +104 -0
  117. data/lib/buildr/packaging/zip.rb +722 -0
  118. data/lib/buildr/resources/buildr.icns +0 -0
  119. data/lib/buildr/scala.rb +19 -0
  120. data/lib/buildr/scala/compiler.rb +109 -0
  121. data/lib/buildr/scala/tests.rb +203 -0
  122. data/rakelib/apache.rake +191 -0
  123. data/rakelib/changelog.rake +57 -0
  124. data/rakelib/doc.rake +103 -0
  125. data/rakelib/package.rake +73 -0
  126. data/rakelib/release.rake +65 -0
  127. data/rakelib/rspec.rake +83 -0
  128. data/rakelib/rubyforge.rake +53 -0
  129. data/rakelib/scm.rake +49 -0
  130. data/rakelib/setup.rake +86 -0
  131. data/rakelib/stage.rake +48 -0
  132. data/spec/addon/cobertura_spec.rb +77 -0
  133. data/spec/addon/emma_spec.rb +120 -0
  134. data/spec/addon/test_coverage_spec.rb +255 -0
  135. data/spec/core/application_spec.rb +412 -0
  136. data/spec/core/artifact_namespace_spec.rb +646 -0
  137. data/spec/core/build_spec.rb +415 -0
  138. data/spec/core/checks_spec.rb +537 -0
  139. data/spec/core/common_spec.rb +664 -0
  140. data/spec/core/compile_spec.rb +566 -0
  141. data/spec/core/generate_spec.rb +33 -0
  142. data/spec/core/project_spec.rb +754 -0
  143. data/spec/core/test_spec.rb +1091 -0
  144. data/spec/core/transport_spec.rb +500 -0
  145. data/spec/groovy/bdd_spec.rb +80 -0
  146. data/spec/groovy/compiler_spec.rb +239 -0
  147. data/spec/ide/eclipse_spec.rb +243 -0
  148. data/spec/java/ant.rb +28 -0
  149. data/spec/java/bdd_spec.rb +358 -0
  150. data/spec/java/compiler_spec.rb +446 -0
  151. data/spec/java/java_spec.rb +88 -0
  152. data/spec/java/packaging_spec.rb +1103 -0
  153. data/spec/java/tests_spec.rb +466 -0
  154. data/spec/packaging/archive_spec.rb +503 -0
  155. data/spec/packaging/artifact_spec.rb +754 -0
  156. data/spec/packaging/packaging_helper.rb +63 -0
  157. data/spec/packaging/packaging_spec.rb +589 -0
  158. data/spec/sandbox.rb +137 -0
  159. data/spec/scala/compiler_spec.rb +228 -0
  160. data/spec/scala/tests_spec.rb +215 -0
  161. data/spec/spec_helpers.rb +304 -0
  162. data/spec/version_requirement_spec.rb +123 -0
  163. metadata +369 -0
@@ -0,0 +1,19 @@
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 'buildr/scala/compiler'
18
+ require 'buildr/scala/tests'
19
+ Object::Scala = Buildr::Scala
@@ -0,0 +1,109 @@
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
+ require 'buildr/core/project'
17
+ require 'buildr/core/common'
18
+ require 'buildr/core/compile'
19
+ require 'buildr/packaging'
20
+
21
+
22
+ module Buildr::Scala
23
+
24
+ # Scalac compiler:
25
+ # compile.using(:scalac)
26
+ # Used by default if .scala files are found in the src/main/scala directory (or src/test/scala)
27
+ # and sets the target directory to target/classes (or target/test/classes).
28
+ #
29
+ # Accepts the following options:
30
+ # * :warnings -- Generate warnings if true (opposite of -nowarn).
31
+ # * :deprecation -- Output source locations where deprecated APIs are used.
32
+ # * :optimise -- Generates faster bytecode by applying optimisations to the program.
33
+ # * :target -- Class file compatibility with specified release.
34
+ # * :debug -- Generate debugging info.
35
+ # * :other -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
36
+ class Scalac < Buildr::Compiler::Base
37
+ class << self
38
+ def scala_home
39
+ @home ||= ENV['SCALA_HOME']
40
+ end
41
+
42
+ def dependencies
43
+ [ 'scala-library.jar', 'scala-compiler.jar'].map { |jar| File.expand_path("lib/#{jar}", scala_home) }
44
+ end
45
+
46
+ def use_fsc
47
+ ENV["USE_FSC"] =~ /^(yes|on|true)$/i
48
+ end
49
+ end
50
+
51
+ OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other]
52
+ Java.classpath << dependencies
53
+
54
+ specify :language=>:scala, :target=>'classes', :target_ext=>'class', :packaging=>:jar
55
+
56
+ def initialize(project, options) #:nodoc:
57
+ super
58
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
59
+ options[:warnings] = verbose if options[:warnings].nil?
60
+ options[:deprecation] ||= false
61
+ options[:optimise] ||= false
62
+ end
63
+
64
+ def compile(sources, target, dependencies) #:nodoc:
65
+ check_options options, OPTIONS
66
+
67
+ cmd_args = []
68
+ cmd_args << '-classpath' << (dependencies + Scalac.dependencies).join(File::PATH_SEPARATOR)
69
+ source_paths = sources.select { |source| File.directory?(source) }
70
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
71
+ cmd_args << '-d' << File.expand_path(target)
72
+ cmd_args += scalac_args
73
+ cmd_args += files_from_sources(sources)
74
+
75
+ unless Buildr.application.options.dryrun
76
+ Scalac.scala_home or fail 'Are we forgetting something? SCALA_HOME not set.'
77
+ trace((['scalac'] + cmd_args).join(' '))
78
+ if Scalac.use_fsc
79
+ system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' ')) or
80
+ fail 'Failed to compile, see errors above'
81
+ else
82
+ Java.load
83
+ Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
84
+ fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
85
+ end
86
+ end
87
+ end
88
+
89
+ private
90
+
91
+ # Returns Scalac command line arguments from the set of options.
92
+ def scalac_args #:nodoc:
93
+ args = []
94
+ args << "-nowarn" unless options[:warnings]
95
+ args << "-verbose" if Buildr.application.options.trace
96
+ args << "-g" if options[:debug]
97
+ args << "-deprecation" if options[:deprecation]
98
+ args << "-optimise" if options[:optimise]
99
+ args << "-target:jvm-" + options[:target].to_s if options[:target]
100
+ args + Array(options[:other])
101
+ end
102
+
103
+ end
104
+
105
+ end
106
+
107
+ # Scala compiler comes first, ahead of Javac, this allows it to pick
108
+ # projects that mix Scala and Java code by spotting Scala code first.
109
+ Buildr::Compiler.compilers.unshift Buildr::Scala::Scalac
@@ -0,0 +1,203 @@
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 'buildr/core/build'
18
+ require 'buildr/core/compile'
19
+ require 'buildr/java/ant'
20
+ require 'buildr/java/tests'
21
+
22
+
23
+ module Buildr::Scala
24
+
25
+ # Scala::Specs is available when using Scala::Test
26
+ module ScalaSpecs
27
+ VERSION = '1.2.9'
28
+
29
+ class << self
30
+ def version
31
+ Buildr.settings.build['scala.specs'] || VERSION
32
+ end
33
+
34
+ def dependencies
35
+ ["org.specs:specs:jar:#{version}"]
36
+ end
37
+
38
+ private
39
+ def const_missing(const)
40
+ return super unless const == :REQUIRES # TODO: remove in 1.5
41
+ Buildr.application.deprecated "Please use Scala::Specs.dependencies/.version instead of ScalaSpecs::REQUIRES/VERSION"
42
+ dependencies
43
+ end
44
+ end
45
+ end
46
+
47
+
48
+ # Scala::Check is available when using Scala::Test
49
+ module ScalaCheck
50
+ VERSION = '1.3'
51
+
52
+ class << self
53
+ def version
54
+ Buildr.settings.build['scala.check'] || VERSION
55
+ end
56
+
57
+ def dependencies
58
+ ["org.scalacheck:scalacheck:jar:#{version}"]
59
+ end
60
+
61
+ private
62
+ def const_missing(const)
63
+ return super unless const == :REQUIRES # TODO: remove in 1.5
64
+ Buildr.application.deprecated "Please use Scala::Check.dependencies/.version instead of ScalaCheck::REQUIRES/VERSION"
65
+ dependencies
66
+ end
67
+ end
68
+ end
69
+
70
+
71
+ # ScalaTest framework, the default test framework for Scala tests.
72
+ #
73
+ # Support the following options:
74
+ # * :properties -- Hash of system properties available to the test case.
75
+ # * :environment -- Hash of environment variables available to the test case.
76
+ # * :java_args -- Arguments passed as is to the JVM.
77
+ class ScalaTest < TestFramework::Java
78
+
79
+ VERSION = '0.9.3'
80
+
81
+ class << self
82
+ def version
83
+ Buildr.settings.build['scala.test'] || VERSION
84
+ end
85
+
86
+ def dependencies
87
+ ["org.scalatest:scalatest:jar:#{version}"] + ScalaSpecs.dependencies +
88
+ ScalaCheck.dependencies + JMock.dependencies
89
+ end
90
+
91
+ def applies_to?(project) #:nodoc:
92
+ project.test.compile.language == :scala
93
+ end
94
+
95
+ private
96
+ def const_missing(const)
97
+ return super unless const == :REQUIRES # TODO: remove in 1.5
98
+ Buildr.application.deprecated "Please use Scala::Test.dependencies/.version instead of ScalaTest::REQUIRES/VERSION"
99
+ dependencies
100
+ end
101
+ end
102
+
103
+ # annotation-based group inclusion
104
+ attr_accessor :group_includes
105
+
106
+ # annotation-based group exclusion
107
+ attr_accessor :group_excludes
108
+
109
+ def initialize(test_task, options)
110
+ super
111
+ @group_includes = []
112
+ @group_excludes = []
113
+ end
114
+
115
+ def tests(dependencies) #:nodoc:
116
+ suites = filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
117
+ # we should really filter using :class => %w{org.specs.Specification} instead of naming convention
118
+ specs = filter_classes(dependencies, :class_names => [/Specs?$/])
119
+ [suites, specs].flatten
120
+ end
121
+
122
+ def run(tests, dependencies) #:nodoc:
123
+ mkpath task.report_to.to_s
124
+ success = []
125
+ scalatest = tests.select { |t| t !~ /Specs?$/ }
126
+ specs = tests.select { |t| t =~ /Specs?$/ }
127
+
128
+ # Specs
129
+ nostacktrace = (options[:nostacktrace]) ? "-ns" : ""
130
+ cmd_options = { :properties => options[:properties],
131
+ :java_args => options[:java_args],
132
+ :classpath => dependencies}
133
+ specs.each do |spec|
134
+ Java.load
135
+ begin
136
+ Java::Commands.java(spec, cmd_options)
137
+ rescue => e
138
+ print e.message
139
+ else
140
+ success << spec
141
+ end
142
+ end
143
+
144
+ # ScalaTest
145
+ reporter_options = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted
146
+ scalatest.each do |suite|
147
+ info "ScalaTest #{suite.inspect}"
148
+ # Use Ant to execute the ScalaTest task, gives us performance and reporting.
149
+ reportFile = File.join(task.report_to.to_s, "TEST-#{suite}.txt")
150
+ taskdef = Buildr.artifacts(self.class.dependencies).each(&:invoke).map(&:to_s)
151
+ Buildr.ant('scalatest') do |ant|
152
+ ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask',
153
+ :classpath=>taskdef.join(File::PATH_SEPARATOR)
154
+ ant.scalatest :runpath=>dependencies.join(File::PATH_SEPARATOR) do
155
+ ant.suite :classname=>suite
156
+ ant.reporter :type=>'stdout', :config=>reporter_options
157
+ ant.reporter :type=>'file', :filename=> reportFile, :config=>reporter_options
158
+ ant.includes group_includes.join(" ") if group_includes
159
+ ant.excludes group_excludes.join(" ") if group_excludes
160
+ (options[:properties] || []).each { |name, value| ant.property :name=>name, :value=>value }
161
+ end
162
+ end
163
+
164
+ # Parse for failures, errors, etc.
165
+ # This is a bit of a pain right now because ScalaTest doesn't flush its
166
+ # output synchronously before the Ant test finishes so we have to loop
167
+ # and wait for an indication that the test run was completed.
168
+ failed = false
169
+ completed = false
170
+ wait = 0
171
+ while (!completed) do
172
+ File.open(reportFile, "r") do |input|
173
+ while (line = input.gets) do
174
+ failed = (line =~ /(TEST FAILED -)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
175
+ completed |= (line =~ /Run completed\./)
176
+ break if (failed || completed)
177
+ end
178
+ end
179
+ wait += 1
180
+ break if (failed || wait > 10)
181
+ unless completed
182
+ sleep(1)
183
+ end
184
+ end
185
+ success << suite if (completed && !failed)
186
+ end
187
+
188
+ success
189
+ end # run
190
+
191
+ end # ScalaTest
192
+
193
+ end
194
+
195
+
196
+ # Backwards compatibility stuff. Remove in 1.5.
197
+ module Buildr
198
+ ScalaSpecs = Scala::ScalaSpecs
199
+ ScalaCheck = Scala::ScalaCheck
200
+ ScalaTest = Scala::ScalaTest
201
+ end
202
+
203
+ Buildr::TestFramework << Buildr::Scala::ScalaTest
@@ -0,0 +1,191 @@
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 'digest/md5'
18
+ require 'digest/sha1'
19
+
20
+
21
+ # Tasks specific to Apache projects (license, release, etc).
22
+ namespace 'apache' do
23
+
24
+ desc 'Upload snapshot packages over to people.apache.org'
25
+ task 'snapshot'=>['spec', 'package'] do
26
+ rm_rf 'snapshot' # Always start with empty directory
27
+ puts "Copying existing gems from Apache"
28
+ sh 'rsync', '--progress', '--recursive', 'people.apache.org:public_html/buildr/snapshot', './'
29
+ puts "Copying new gems over"
30
+ cp FileList['pkg/{*.gem,*.tgz,*.zip}'], 'snapshot/gems'
31
+ puts "Generating gem index ..."
32
+ sh 'gem', 'generate_index', '--directory', 'snapshot'
33
+ puts "Copying gem and index back to Apache"
34
+ sh 'rsync', '--progress', '--recursive', 'snapshot', 'people.apache.org:public_html/buildr/'
35
+ end
36
+
37
+
38
+ desc 'Check that source files contain the Apache license'
39
+ task 'license' do |task|
40
+ print 'Checking that files contain the Apache license ... '
41
+ required = task.prerequisites.select { |fn| File.file?(fn) }
42
+ missing = required.reject { |fn|
43
+ comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|^-#\s+(.*?)$|<!--(.*?)-->/m).
44
+ map { |match| match.compact }.flatten.join("\n")
45
+ comments =~ /Licensed to the Apache Software Foundation/ && comments =~ /http:\/\/www.apache.org\/licenses\/LICENSE-2.0/
46
+ }
47
+ fail "#{missing.join(', ')} missing Apache License, please add it before making a release!" unless missing.empty?
48
+ puts 'OK'
49
+ end
50
+
51
+ # Staging checks specific for Apache.
52
+ task 'check'=>'license' do |task, args|
53
+ args.gpg_user or fail "Please run with gpg_user=<argument for gpg --local-user>"
54
+ fail "No GPG user #{args.gpg_user}" if `gpg --list-keys #{args.gpg_user}`.empty?
55
+ end
56
+
57
+
58
+ file 'staged/distro'=>'package' do
59
+ puts 'Copying and signing release files ...'
60
+ mkpath 'staged/distro'
61
+ FileList['pkg/*.{gem,zip,tgz}'].each do |pkg|
62
+ cp pkg, pkg.pathmap('staged/distro/%n-incubating%x')
63
+ end
64
+ end
65
+
66
+ task 'sign'=>['etc/KEYS', 'staged/distro'] do |task, args|
67
+ gpg_user = args.gpg_user or fail "Please run with gpg_user=<argument for gpg --local-user>"
68
+ puts "Signing packages in staged/distro as user #{gpg_user}"
69
+ FileList['staged/distro/*.{gem,zip,tgz}'].each do |pkg|
70
+ bytes = File.open(pkg, 'rb') { |file| file.read }
71
+ File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
72
+ File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
73
+ sh 'gpg', '--local-user', gpg_user, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
74
+ end
75
+ cp 'etc/KEYS', 'staged/distro'
76
+ end
77
+
78
+ # Publish prerequisites to distro server.
79
+ task 'publish:distro' do |task, args|
80
+ target = args.incubating ? "people.apache.org:/www/www.apache.org/dist/incubator/#{spec.name}/#{spec.version}-incubating" :
81
+ "people.apache.org:/www/www.apache.org/dist/#{spec.name}/#{spec.version}"
82
+ puts 'Uploading packages to Apache distro ...'
83
+ host, remote_dir = target.split(':')
84
+ sh 'ssh', host, 'rm', '-rf', remote_dir rescue nil
85
+ sh 'ssh', host, 'mkdir', remote_dir
86
+ sh 'rsync', '--progress', '--recursive', 'published/distro/', target
87
+ puts 'Done'
88
+ end
89
+
90
+ task 'distro-links'=>'staged/distro' do |task, args|
91
+ url = args.incubating ? "http://www.apache.org/dist/incubator/#{spec.name}/#{spec.version}-incubating" :
92
+ "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
93
+ rows = FileList['staged/distro/*.{gem,tgz,zip}'].map { |pkg|
94
+ name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
95
+ %{| "#{name}":#{url}/#{name} | "#{md5}":#{url}/#{name}.md5 | "Sig":#{url}/#{name}.asc |}
96
+ }
97
+ textile = <<-TEXTILE
98
+ h3. #{spec.name} #{spec.version}#{args.incubating && "-incubating"} (#{Time.now.strftime('%Y-%m-%d')})
99
+
100
+ |_. Package |_. MD5 Checksum |_. PGP |
101
+ #{rows.join("\n")}
102
+
103
+ p>. ("Release signing keys":#{url}/KEYS)
104
+ TEXTILE
105
+ file_name = 'doc/pages/download.textile'
106
+ print "Adding download links to #{file_name} ... "
107
+ modified = File.read(file_name).sub(/h2.*binaries.*source.*/i) { |header| "#{header}\n\n#{textile}" }
108
+ File.open file_name, 'w' do |file|
109
+ file.write modified
110
+ end
111
+ puts 'Done'
112
+ end
113
+
114
+ file 'staged/site'=>['distro-links', 'staged', 'site'] do
115
+ rm_rf 'staged/site'
116
+ cp_r 'site', 'staged'
117
+ end
118
+
119
+ # Publish prerequisites to Web site.
120
+ task 'publish:site' do |task, args|
121
+ target = args.incubating ? "people.apache.org:/www/incubator.apache.org/#{spec.name}" :
122
+ "people.apache.org:/www/#{spec.name}.apache.org"
123
+ puts 'Uploading Apache Web site ...'
124
+ sh 'rsync', '--progress', '--recursive', '--delete', 'published/site/', target
125
+ puts 'Done'
126
+ end
127
+
128
+
129
+ file 'release-vote-email.txt'=>'CHANGELOG' do |task|
130
+ # Need to know who you are on Apache, local user may be different (see .ssh/config).
131
+ whoami = `ssh people.apache.org whoami`.strip
132
+ base_url = "http://people.apache.org/~#{whoami}/buildr/#{spec.version}"
133
+ # Need changes for this release only.
134
+ changelog = File.read('CHANGELOG').scan(/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/)
135
+ changes = changelog[0][2]
136
+ previous_version = changelog[1][1]
137
+
138
+ email = <<-EMAIL
139
+ To: buildr-dev@incubator.apache.org
140
+ Subject: [VOTE] Buildr #{spec.version} release
141
+
142
+ We're voting on the source distributions available here:
143
+ #{base_url}/distro/
144
+
145
+ Specifically:
146
+ #{base_url}/distro/buildr-#{spec.version}-incubating.tgz
147
+ #{base_url}/distro/buildr-#{spec.version}-incubating.zip
148
+
149
+ The documentation generated for this release is available here:
150
+ #{base_url}/site/
151
+ #{base_url}/site/buildr.pdf
152
+
153
+ The official specification against which this release was tested:
154
+ #{base_url}/site/specs.html
155
+
156
+ Test coverage report:
157
+ #{base_url}/site/coverage/index.html
158
+
159
+
160
+ The following changes were made since #{previous_version}:
161
+
162
+ #{changes}
163
+ EMAIL
164
+ File.open task.name, 'w' do |file|
165
+ file.write email
166
+ end
167
+ puts "Created release vote email template in '#{task.name}':"
168
+ puts email
169
+ end
170
+
171
+ end
172
+
173
+ task 'clobber' do
174
+ rm_rf 'snapshot'
175
+ rm_f 'release-vote-email.txt'
176
+ end
177
+
178
+
179
+ task 'stage:check'=>['apache:check']
180
+ task 'stage:prepare'=>['staged/distro', 'staged/site'] do |task|
181
+ # Since this requires input (passphrase), do it at the very end.
182
+ task.enhance do
183
+ task('apache:sign').invoke
184
+ end
185
+ end
186
+ task 'stage' do
187
+ task('apache:snapshot').invoke
188
+ end
189
+ task 'stage:wrapup'=>'release-vote-email.txt'
190
+
191
+ task 'release:publish'=>['apache:publish:distro', 'apache:publish:site']