buildr 1.2.10 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/CHANGELOG +566 -268
  2. data/DISCLAIMER +7 -1
  3. data/KEYS +151 -0
  4. data/NOTICE +23 -8
  5. data/README +122 -22
  6. data/Rakefile +49 -229
  7. data/{lib → addon}/buildr/antlr.rb +23 -10
  8. data/addon/buildr/cobertura.rb +232 -0
  9. data/{lib → addon}/buildr/hibernate.rb +20 -4
  10. data/{lib → addon}/buildr/javacc.rb +27 -12
  11. data/addon/buildr/jdepend.rb +60 -0
  12. data/{lib → addon}/buildr/jetty.rb +34 -18
  13. data/addon/buildr/nailgun.rb +892 -0
  14. data/{lib → addon}/buildr/openjpa.rb +23 -6
  15. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  18. data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
  19. data/{lib → addon}/buildr/xmlbeans.rb +39 -14
  20. data/bin/buildr +21 -7
  21. data/buildr.gemspec +50 -0
  22. data/doc/css/default.css +225 -0
  23. data/doc/css/print.css +95 -0
  24. data/doc/css/syntax.css +43 -0
  25. data/doc/images/apache-incubator-logo.png +0 -0
  26. data/doc/images/buildr-hires.png +0 -0
  27. data/doc/images/buildr.png +0 -0
  28. data/doc/images/note.png +0 -0
  29. data/doc/images/tip.png +0 -0
  30. data/doc/images/zbuildr.tif +0 -0
  31. data/doc/pages/artifacts.textile +317 -0
  32. data/doc/pages/building.textile +501 -0
  33. data/doc/pages/contributing.textile +178 -0
  34. data/doc/pages/download.textile +25 -0
  35. data/doc/pages/extending.textile +229 -0
  36. data/doc/pages/getting_started.textile +337 -0
  37. data/doc/pages/index.textile +63 -0
  38. data/doc/pages/mailing_lists.textile +17 -0
  39. data/doc/pages/more_stuff.textile +367 -0
  40. data/doc/pages/packaging.textile +592 -0
  41. data/doc/pages/projects.textile +449 -0
  42. data/doc/pages/recipes.textile +127 -0
  43. data/doc/pages/settings_profiles.textile +339 -0
  44. data/doc/pages/testing.textile +475 -0
  45. data/doc/pages/troubleshooting.textile +121 -0
  46. data/doc/pages/whats_new.textile +389 -0
  47. data/doc/print.haml +52 -0
  48. data/doc/print.toc.yaml +28 -0
  49. data/doc/scripts/buildr-git.rb +411 -0
  50. data/doc/scripts/install-jruby.sh +44 -0
  51. data/doc/scripts/install-linux.sh +64 -0
  52. data/doc/scripts/install-osx.sh +52 -0
  53. data/doc/site.haml +55 -0
  54. data/doc/site.toc.yaml +44 -0
  55. data/lib/buildr.rb +28 -45
  56. data/lib/buildr/core.rb +27 -0
  57. data/lib/buildr/core/application.rb +373 -0
  58. data/lib/buildr/core/application_cli.rb +134 -0
  59. data/lib/{core → buildr/core}/build.rb +91 -77
  60. data/lib/{core → buildr/core}/checks.rb +116 -95
  61. data/lib/buildr/core/common.rb +155 -0
  62. data/lib/buildr/core/compile.rb +594 -0
  63. data/lib/buildr/core/environment.rb +120 -0
  64. data/lib/buildr/core/filter.rb +258 -0
  65. data/lib/{core → buildr/core}/generate.rb +22 -5
  66. data/lib/buildr/core/help.rb +118 -0
  67. data/lib/buildr/core/progressbar.rb +156 -0
  68. data/lib/{core → buildr/core}/project.rb +468 -213
  69. data/lib/buildr/core/test.rb +690 -0
  70. data/lib/{core → buildr/core}/transports.rb +107 -127
  71. data/lib/buildr/core/util.rb +235 -0
  72. data/lib/buildr/ide.rb +19 -0
  73. data/lib/{java → buildr/ide}/eclipse.rb +86 -60
  74. data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
  75. data/lib/buildr/ide/idea.rb +194 -0
  76. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  77. data/lib/buildr/ide/idea7x.rb +210 -0
  78. data/lib/buildr/java.rb +26 -0
  79. data/lib/buildr/java/ant.rb +71 -0
  80. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  81. data/lib/buildr/java/commands.rb +210 -0
  82. data/lib/buildr/java/compilers.rb +432 -0
  83. data/lib/buildr/java/deprecated.rb +141 -0
  84. data/lib/buildr/java/groovyc.rb +137 -0
  85. data/lib/buildr/java/jruby.rb +99 -0
  86. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  89. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  91. data/lib/buildr/java/packaging.rb +706 -0
  92. data/lib/{java → buildr/java}/pom.rb +20 -4
  93. data/lib/buildr/java/rjb.rb +142 -0
  94. data/lib/buildr/java/test_frameworks.rb +290 -0
  95. data/lib/buildr/java/version_requirement.rb +172 -0
  96. data/lib/buildr/packaging.rb +21 -0
  97. data/lib/{java → buildr/packaging}/artifact.rb +170 -179
  98. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  99. data/lib/buildr/packaging/artifact_search.rb +140 -0
  100. data/lib/buildr/packaging/gems.rb +102 -0
  101. data/lib/buildr/packaging/package.rb +233 -0
  102. data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
  103. data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
  104. data/rakelib/apache.rake +126 -0
  105. data/rakelib/changelog.rake +56 -0
  106. data/rakelib/doc.rake +103 -0
  107. data/rakelib/package.rake +44 -0
  108. data/rakelib/release.rake +53 -0
  109. data/rakelib/rspec.rake +81 -0
  110. data/rakelib/rubyforge.rake +45 -0
  111. data/rakelib/scm.rake +49 -0
  112. data/rakelib/setup.rake +59 -0
  113. data/rakelib/stage.rake +45 -0
  114. data/spec/application_spec.rb +316 -0
  115. data/spec/archive_spec.rb +494 -0
  116. data/spec/artifact_namespace_spec.rb +635 -0
  117. data/spec/artifact_spec.rb +738 -0
  118. data/spec/build_spec.rb +193 -0
  119. data/spec/checks_spec.rb +537 -0
  120. data/spec/common_spec.rb +579 -0
  121. data/spec/compile_spec.rb +561 -0
  122. data/spec/groovy_compilers_spec.rb +239 -0
  123. data/spec/java_bdd_frameworks_spec.rb +238 -0
  124. data/spec/java_compilers_spec.rb +446 -0
  125. data/spec/java_packaging_spec.rb +1042 -0
  126. data/spec/java_test_frameworks_spec.rb +414 -0
  127. data/spec/packaging_helper.rb +63 -0
  128. data/spec/packaging_spec.rb +589 -0
  129. data/spec/project_spec.rb +739 -0
  130. data/spec/sandbox.rb +116 -0
  131. data/spec/scala_compilers_spec.rb +239 -0
  132. data/spec/spec.opts +6 -0
  133. data/spec/spec_helpers.rb +283 -0
  134. data/spec/test_spec.rb +871 -0
  135. data/spec/transport_spec.rb +300 -0
  136. data/spec/version_requirement_spec.rb +115 -0
  137. metadata +188 -77
  138. data/lib/buildr/cobertura.rb +0 -89
  139. data/lib/buildr/jdepend.rb +0 -40
  140. data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
  141. data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
  142. data/lib/buildr/jetty/JettyWrapper.class +0 -0
  143. data/lib/buildr/scala.rb +0 -368
  144. data/lib/core/application.rb +0 -188
  145. data/lib/core/common.rb +0 -562
  146. data/lib/core/help.rb +0 -72
  147. data/lib/core/rake_ext.rb +0 -81
  148. data/lib/java/ant.rb +0 -71
  149. data/lib/java/compile.rb +0 -589
  150. data/lib/java/idea.rb +0 -159
  151. data/lib/java/java.rb +0 -432
  152. data/lib/java/packaging.rb +0 -581
  153. data/lib/java/test.rb +0 -795
  154. data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,134 @@
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
+ # Portion of this file derived from Rake.
17
+ # Copyright (c) 2003, 2004 Jim Weirich
18
+ #
19
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ # of this software and associated documentation files (the "Software"), to deal
21
+ # in the Software without restriction, including without limitation the rights
22
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ # copies of the Software, and to permit persons to whom the Software is
24
+ # furnished to do so, subject to the following conditions:
25
+ #
26
+ # The above copyright notice and this permission notice shall be included in
27
+ # all copies or substantial portions of the Software.
28
+ #
29
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ # SOFTWARE.
36
+
37
+
38
+ require 'getoptlong'
39
+
40
+
41
+ module Buildr
42
+ module CommandLineInterface
43
+
44
+ OPTIONS = [ # :nodoc:
45
+ ['--help', '-h', GetoptLong::NO_ARGUMENT,
46
+ 'Display this help message.'],
47
+ ['--nosearch', '-n', GetoptLong::NO_ARGUMENT,
48
+ 'Do not search parent directories for the buildfile.'],
49
+ ['--quiet', '-q', GetoptLong::NO_ARGUMENT,
50
+ 'Do not log messages to standard output.'],
51
+ ['--buildfile', '-f', GetoptLong::REQUIRED_ARGUMENT,
52
+ 'Use FILE as the buildfile.'],
53
+ ['--require', '-r', GetoptLong::REQUIRED_ARGUMENT,
54
+ 'Require MODULE before executing buildfile.'],
55
+ ['--trace', '-t', GetoptLong::NO_ARGUMENT,
56
+ 'Turn on invoke/execute tracing, enable full backtrace.'],
57
+ ['--version', '-v', GetoptLong::NO_ARGUMENT,
58
+ 'Display the program version.'],
59
+ ['--environment', '-e', GetoptLong::REQUIRED_ARGUMENT,
60
+ 'Environment name (e.g. development, test, production).']
61
+ ]
62
+
63
+ def collect_tasks
64
+ top_level_tasks.clear
65
+ ARGV.each do |arg|
66
+ if arg =~ /^(\w+)=(.*)$/
67
+ ENV[$1.upcase] = $2
68
+ else
69
+ top_level_tasks << arg
70
+ end
71
+ end
72
+ top_level_tasks.push("default") if top_level_tasks.size == 0
73
+ end
74
+
75
+ def parse_options
76
+ opts = GetoptLong.new(*command_line_options)
77
+ opts.each { |opt, value| do_option(opt, value) }
78
+ end
79
+
80
+ def do_option(opt, value)
81
+ case opt
82
+ when '--help'
83
+ help
84
+ exit
85
+ when '--buildfile'
86
+ rakefiles.clear
87
+ rakefiles << value
88
+ when '--version'
89
+ puts version
90
+ exit
91
+ when '--environment'
92
+ ENV['BUILDR_ENV'] = value
93
+ when '--require'
94
+ requires << value
95
+ when '--nosearch', '--quiet', '--trace'
96
+ super
97
+ end
98
+ end
99
+
100
+ def command_line_options
101
+ OPTIONS.collect { |lst| lst[0..-2] }
102
+ end
103
+
104
+ def version
105
+ "Buildr #{Buildr::VERSION} #{RUBY_PLATFORM[/java/] && '(JRuby '+JRUBY_VERSION+')'}"
106
+ end
107
+
108
+ def usage
109
+ puts version
110
+ puts
111
+ puts 'Usage:'
112
+ puts ' buildr [options] [tasks] [name=value]'
113
+ end
114
+
115
+ def help
116
+ usage
117
+ puts
118
+ puts 'Options:'
119
+ OPTIONS.sort.each do |long, short, mode, desc|
120
+ if mode == GetoptLong::REQUIRED_ARGUMENT
121
+ if desc =~ /\b([A-Z]{2,})\b/
122
+ long = long + "=#{$1}"
123
+ end
124
+ end
125
+ printf " %-20s (%s)\n", long, short
126
+ printf " %s\n", desc
127
+ end
128
+ puts
129
+ puts 'For help with your buildfile:'
130
+ puts ' buildr help'
131
+ end
132
+
133
+ end
134
+ end
@@ -1,30 +1,26 @@
1
- require "core/project"
2
- require "core/common"
3
- require "core/checks"
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/project'
18
+ require 'buildr/core/common'
19
+ require 'buildr/core/checks'
20
+ require 'buildr/core/environment'
4
21
 
5
- module Buildr
6
-
7
- desc "Build the project"
8
- Project.local_task("build") { |name| "Building #{name}" }
9
- desc "Clean files generated during a build"
10
- Project.local_task("clean") { |name| "Cleaning #{name}" }
11
- desc "Create packages"
12
- Project.local_task("package"=>"build") { |name| "Packaging #{name}" }
13
- desc "Install packages created by the project"
14
- Project.local_task("install"=>"package") { |name| "Installing packages from #{name}" }
15
- desc "Remove previously installed packages"
16
- Project.local_task("uninstall") { |name| "Uninstalling packages from #{name}" }
17
- desc "Upload packages created by the project"
18
- Project.local_task("upload"=>"package") { |name| "Deploying packages from #{name}" }
19
-
20
- [ :build, :clean, :package, :install, :uninstall, :upload ].each do |name|
21
- Project.on_define { |project| project.recursive_task name }
22
- end
23
-
24
- task("deploy"=>"upload") do
25
- warn_deprecated "Please use the 'upload' task instead of 'deploy'."
26
- end
27
22
 
23
+ module Buildr
28
24
 
29
25
  class Options
30
26
 
@@ -39,31 +35,57 @@ module Buildr
39
35
 
40
36
  end
41
37
 
42
- task("parallel") { Buildr.options.parallel = true }
38
+ task('parallel') { Buildr.options.parallel = true }
39
+
40
+
41
+ module Build
42
+
43
+ include Extension
44
+
45
+ first_time do
46
+ desc 'Build the project'
47
+ Project.local_task('build') { |name| "Building #{name}" }
48
+ desc 'Clean files generated during a build'
49
+ Project.local_task('clean') { |name| "Cleaning #{name}" }
50
+
51
+ desc 'The default task it build'
52
+ task 'default'=>'build'
53
+ end
43
54
 
55
+ before_define do |project|
56
+ project.recursive_task 'build'
57
+ project.recursive_task 'clean'
58
+ project.clean do
59
+ verbose(true) do
60
+ rm_rf project.path_to(:target)
61
+ rm_rf project.path_to(:reports)
62
+ end
63
+ end
64
+ end
44
65
 
45
- class Project
46
66
 
47
- # The target directory. By default, it's the "target" directory inside the project. Various tasks
48
- # use it to determine where to place files, e.g. when compiling or packaging. The clean task
49
- # nukes it.
50
- def target()
51
- @target ||= _("target")
67
+ # *Deprecated:* Use +path_to(:target)+ instead.
68
+ def target
69
+ Buildr.application.deprecated 'Use path_to(:target) instead'
70
+ layout.expand(:target)
52
71
  end
53
72
 
73
+ # *Deprecated:* Use Layout instead.
54
74
  def target=(dir)
55
- @target = _(dir)
75
+ Buildr.application.deprecated 'Use Layout instead'
76
+ layout[:target] = _(dir)
56
77
  end
57
78
 
58
- # The reports directory. By default, it's the "reports" directory inside the project. Various tasks
59
- # use it to determine where to place reports, e.g. when running test cases or code analysis.
60
- # The clean task nukes it.
79
+ # *Deprecated:* Use +path_to(:reports)+ instead.
61
80
  def reports()
62
- @reports ||= _("reports")
81
+ Buildr.application.deprecated 'Use path_to(:reports) instead'
82
+ layout.expand(:reports)
63
83
  end
64
84
 
85
+ # *Deprecated:* Use Layout instead.
65
86
  def reports=(dir)
66
- @reports = _(dir)
87
+ Buildr.application.deprecated 'Use Layout instead'
88
+ layout[:reports] = _(dir)
67
89
  end
68
90
 
69
91
  # :call-seq:
@@ -72,7 +94,7 @@ module Buildr
72
94
  #
73
95
  # Returns the project's build task. With arguments or block, also enhances that task.
74
96
  def build(*prereqs, &block)
75
- task("build").enhance prereqs, &block
97
+ task('build').enhance prereqs, &block
76
98
  end
77
99
 
78
100
  # :call-seq:
@@ -81,25 +103,12 @@ module Buildr
81
103
  #
82
104
  # Returns the project's clean task. With arguments or block, also enhances that task.
83
105
  def clean(*prereqs, &block)
84
- task("clean").enhance prereqs, &block
106
+ task('clean').enhance prereqs, &block
85
107
  end
86
108
 
87
109
  end
88
110
 
89
111
 
90
- Project.on_define do |project|
91
- project.clean do
92
- verbose(true) do
93
- rm_rf project.path_to(:target)
94
- rm_rf project.path_to(:reports)
95
- end
96
- end
97
- end
98
-
99
- desc "The default task it build"
100
- task "default"=>"build"
101
-
102
-
103
112
  class Release
104
113
 
105
114
  THIS_VERSION_PATTERN = /THIS_VERSION|VERSION_NUMBER\s*=\s*(["'])(.*)\1/
@@ -119,13 +128,13 @@ module Buildr
119
128
  sh "#{command} clean upload #{options.join(' ')}"
120
129
  end
121
130
  tag version
122
- commit version + "-SNAPSHOT"
131
+ commit version + '-SNAPSHOT'
123
132
  end
124
133
 
125
134
  protected
126
135
 
127
136
  def command() #:nodoc:
128
- Config::CONFIG["arch"] =~ /dos|win32/i ? $PROGRAM_NAME.ext("cmd") : $PROGRAM_NAME
137
+ Config::CONFIG['arch'] =~ /dos|win32/i ? $PROGRAM_NAME.ext('cmd') : $PROGRAM_NAME
129
138
  end
130
139
 
131
140
  # :call-seq:
@@ -136,7 +145,7 @@ module Buildr
136
145
  def check()
137
146
  fail "SVN URL must end with 'trunk' or 'branches/...'" unless svn_url =~ /(trunk)|(branches.*)$/
138
147
  # Status check reveals modified file, but also SVN externals which we can safely ignore.
139
- status = svn("status", "--ignore-externals").reject { |line| line =~ /^X\s/ }
148
+ status = svn('status', '--ignore-externals').reject { |line| line =~ /^X\s/ }
140
149
  fail "Uncommitted SVN files violate the First Principle Of Release!\n#{status}" unless
141
150
  status.empty?
142
151
  end
@@ -161,20 +170,20 @@ module Buildr
161
170
  # NEXT_VERSION = 1.2.1
162
171
  # and the method will return 1.2.0.
163
172
  def with_next_version()
164
- new_filename = Rake.application.rakefile + ".next"
173
+ new_filename = Buildr.application.buildfile + '.next'
165
174
  modified = change_version do |this_version, next_version|
166
- one_after = next_version.split(".")
175
+ one_after = next_version.split('.')
167
176
  one_after[-1] = one_after[-1].to_i + 1
168
- [ next_version, one_after.join(".") ]
177
+ [ next_version, one_after.join('.') ]
169
178
  end
170
- File.open(new_filename, "w") { |file| file.write modified }
179
+ File.open(new_filename, 'w') { |file| file.write modified }
171
180
  begin
172
181
  yield new_filename
173
- mv new_filename, Rake.application.rakefile
182
+ mv new_filename, Buildr.application.buildfile
174
183
  ensure
175
184
  rm new_filename rescue nil
176
185
  end
177
- File.read(Rake.application.rakefile).scan(THIS_VERSION_PATTERN)[0][1]
186
+ File.read(Buildr.application.buildfile).scan(THIS_VERSION_PATTERN)[0][1]
178
187
  end
179
188
 
180
189
  # :call-seq:
@@ -186,18 +195,18 @@ module Buildr
186
195
  # This method yields to the block with the current (this) and next version numbers and expects
187
196
  # an array with the new this and next version numbers.
188
197
  def change_version()
189
- rakefile = File.read(Rake.application.rakefile)
190
- this_version = rakefile.scan(THIS_VERSION_PATTERN)[0][1] or
198
+ buildfile = File.read(Buildr.application.buildfile)
199
+ this_version = buildfile.scan(THIS_VERSION_PATTERN)[0][1] or
191
200
  fail "Looking for THIS_VERSION = \"...\" in your Buildfile, none found"
192
- next_version = rakefile.scan(NEXT_VERSION_PATTERN)[0][1] or
201
+ next_version = buildfile.scan(NEXT_VERSION_PATTERN)[0][1] or
193
202
  fail "Looking for NEXT_VERSION = \"...\" in your Buildfile, none found"
194
203
  this_version, next_version = yield(this_version, next_version)
195
204
  if verbose
196
- puts "Upgrading version numbers:"
205
+ puts 'Upgrading version numbers:'
197
206
  puts " This: #{this_version}"
198
207
  puts " Next: #{next_version}"
199
208
  end
200
- rakefile.gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{this_version}"}) }.
209
+ buildfile.gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{this_version}"}) }.
201
210
  gsub(NEXT_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_version}"}) }
202
211
  end
203
212
 
@@ -207,8 +216,8 @@ module Buildr
207
216
  # Tags the current working copy with the release version number.
208
217
  def tag(version)
209
218
  url = svn_url.sub(/(trunk$)|(branches.*)$/, "tags/#{version}")
210
- svn "remove", url, "-m", "Removing old copy" rescue nil
211
- svn "copy", Dir.pwd, url, "-m", "Release #{version}"
219
+ svn 'remove', url, '-m', 'Removing old copy' rescue nil
220
+ svn 'copy', Dir.pwd, url, '-m', "Release #{version}"
212
221
  end
213
222
 
214
223
  # :call-seq:
@@ -216,10 +225,10 @@ module Buildr
216
225
  #
217
226
  # Last, we commit what we currently have in the working copy.
218
227
  def commit(version)
219
- rakefile = File.read(Rake.application.rakefile).
228
+ buildfile = File.read(Buildr.application.buildfile).
220
229
  gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{version}"}) }
221
- File.open(Rake.application.rakefile, "w") { |file| file.write rakefile }
222
- svn "commit", "-m", "Changed version number to #{version}", Rake.application.rakefile
230
+ File.open(Buildr.application.buildfile, 'w') { |file| file.write buildfile }
231
+ svn 'commit', '-m', "Changed version number to #{version}", Buildr.application.buildfile
223
232
  end
224
233
 
225
234
  # :call-seq:
@@ -227,22 +236,27 @@ module Buildr
227
236
  #
228
237
  # Executes SVN command and returns the output.
229
238
  def svn(*args)
230
- cmd = "svn " + args.map { |arg| arg[" "] ? %Q{"#{arg}"} : arg }.join(" ")
239
+ cmd = 'svn ' + args.map { |arg| arg[' '] ? %Q{"#{arg}"} : arg }.join(' ')
231
240
  puts cmd if verbose
232
- `#{cmd}`.tap { fail "SVN command failed" unless $?.exitstatus == 0 }
241
+ `#{cmd}`.tap { fail 'SVN command failed' unless $?.exitstatus == 0 }
233
242
  end
234
243
 
235
244
  # Return the current SVN URL
236
245
  def svn_url
237
- url = svn("info").scan(/URL: (.*)/)[0][0]
246
+ url = svn('info').scan(/URL: (.*)/)[0][0]
238
247
  end
239
248
  end
240
249
 
241
250
  end
242
251
 
243
- desc "Make a release"
244
- task "release" do |task|
252
+ desc 'Make a release'
253
+ task 'release' do |task|
245
254
  Release.make
246
255
  end
247
256
 
248
257
  end
258
+
259
+
260
+ class Buildr::Project
261
+ include Buildr::Build
262
+ end
@@ -1,12 +1,31 @@
1
- require "core/project"
2
- require "tasks/zip"
3
- require "spec"
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/project'
18
+ require 'buildr/packaging/zip'
19
+ require 'test/unit'
20
+ require 'spec/matchers'
21
+ require 'spec/expectations'
4
22
 
5
- module Buildr
6
23
 
7
- module BuildChecks #:nodoc:
24
+ module Buildr
25
+ # Methods added to Project to allow checking the build.
26
+ module Checks
8
27
 
9
- module Matchers
28
+ module Matchers #:nodoc:
10
29
 
11
30
  class << self
12
31
 
@@ -111,7 +130,7 @@ module Buildr
111
130
  # Run the expectation. We only print the expectation name when tracing (to know they all ran),
112
131
  # or when we get a failure.
113
132
  begin
114
- puts description if Rake.application.options.trace
133
+ puts description if Buildr.application.options.trace
115
134
  klass.new.instance_eval &@block
116
135
  rescue Exception=>error
117
136
  raise error.exception("#{description}\n#{error}").tap { |wrapped| wrapped.set_backtrace(error.backtrace) }
@@ -120,10 +139,31 @@ module Buildr
120
139
 
121
140
  end
122
141
 
123
- end
124
142
 
143
+ include Extension
144
+
145
+ before_define do |project|
146
+ # The check task can do any sort of interesting things, but the most important is running expectations.
147
+ project.task("check") do |task|
148
+ project.expectations.inject(true) do |passed, expect|
149
+ begin
150
+ expect.run_against project
151
+ passed
152
+ rescue Exception=>error
153
+ if verbose
154
+ puts error.backtrace.detect { |line| line =~ /#{Buildr.application.buildfile}/ } || ""
155
+ puts error
156
+ end
157
+ false
158
+ end
159
+ end or fail "Checks failed for project #{project.name} (see errors above)."
160
+ end
161
+ project.task("package").enhance do |task|
162
+ # Run all actions before checks.
163
+ task.enhance { project.task("check").invoke }
164
+ end
165
+ end
125
166
 
126
- class Project
127
167
 
128
168
  # :call-seq:
129
169
  # check(description) { ... }
@@ -154,7 +194,7 @@ module Buildr
154
194
  # During development you can write placeholder expectations by omitting the block. This will simply report
155
195
  # the expectation as pending.
156
196
  def check(*args, &block)
157
- expectations << BuildChecks::Expectation.new(*args, &block)
197
+ expectations << Checks::Expectation.new(*args, &block)
158
198
  end
159
199
 
160
200
  # :call-seq:
@@ -167,28 +207,6 @@ module Buildr
167
207
 
168
208
  end
169
209
 
170
- Project.on_define do |project|
171
- # The check task can do any sort of interesting things, but the most important is running expectations.
172
- project.task("check") do |task|
173
- project.expectations.inject(true) do |passed, expect|
174
- begin
175
- expect.run_against project
176
- passed
177
- rescue Exception=>error
178
- if verbose
179
- puts error.backtrace.detect { |line| line =~ /#{Rake.application.rakefile}/ } || ""
180
- puts error
181
- end
182
- false
183
- end
184
- end or fail "Checks failed for project #{project.name} (see errors above)."
185
- end
186
- project.task("package").enhance do |task|
187
- # Run all actions before checks.
188
- task.enhance { project.task("check").invoke }
189
- end
190
- end
191
-
192
210
  end
193
211
 
194
212
 
@@ -268,94 +286,97 @@ module Zip #:nodoc:
268
286
  end
269
287
 
270
288
 
271
- module Buildr
272
- class ArchiveTask
273
-
274
- class Path
275
-
276
- # :call-seq:
277
- # exist() => boolean
278
- #
279
- # Returns true if this path exists. This only works if the path has any entries in it,
280
- # so exist on path happens to be the opposite of empty.
281
- def exist?()
282
- !entries.empty?
283
- end
284
-
285
- # :call-seq:
286
- # empty?() => boolean
287
- #
288
- # Returns true if this path is empty (has no other entries inside).
289
- def empty?()
290
- entries.all? { |entry| entry.empty? }
291
- end
292
-
293
- # :call-seq:
294
- # contain(file*) => boolean
295
- #
296
- # Returns true if this ZIP file path contains all the specified files. You can use relative
297
- # file names and glob patterns (using *, **, etc).
298
- def contain?(*files)
299
- files.all? { |file| entries.detect { |entry| File.fnmatch(file, entry.to_s) } }
300
- end
301
-
302
- # :call-seq:
303
- # entry(name) => ZipEntry
304
- #
305
- # Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
306
- # for example:
307
- # package(:jar).path("META-INF").entry("LICENSE").should contain(/Apache Software License/)
308
- def entry(name)
309
- root.entry("#{@path}#{name}")
310
- end
311
-
312
- protected
289
+ class Buildr::ArchiveTask
313
290
 
314
- def entries() #:nodoc:
315
- return root.entries unless @path
316
- @entries ||= root.entries.inject([]) { |selected, entry|
317
- selected << entry.name.sub(@path, "") if entry.name.starts_with?(@path)
318
- selected
319
- }
320
- end
291
+ class Path #:nodoc:
321
292
 
293
+ # :call-seq:
294
+ # exist() => boolean
295
+ #
296
+ # Returns true if this path exists. This only works if the path has any entries in it,
297
+ # so exist on path happens to be the opposite of empty.
298
+ def exist?()
299
+ !entries.empty?
322
300
  end
323
301
 
324
302
  # :call-seq:
325
303
  # empty?() => boolean
326
304
  #
327
- # Returns true if this ZIP file is empty (has no other entries inside).
305
+ # Returns true if this path is empty (has no other entries inside).
328
306
  def empty?()
329
- path("").empty
307
+ entries.all? { |entry| entry.empty? }
330
308
  end
331
309
 
332
310
  # :call-seq:
333
311
  # contain(file*) => boolean
334
312
  #
335
- # Returns true if this ZIP file contains all the specified files. You can use absolute
313
+ # Returns true if this ZIP file path contains all the specified files. You can use relative
336
314
  # file names and glob patterns (using *, **, etc).
337
315
  def contain?(*files)
338
- path("").contain?(*files)
316
+ files.all? { |file| entries.detect { |entry| File.fnmatch(file, entry.to_s, File::FNM_PATHNAME) } }
339
317
  end
340
318
 
341
- end
342
-
343
-
344
- class ZipTask
345
-
346
319
  # :call-seq:
347
- # entry(name) => Entry
320
+ # entry(name) => ZipEntry
348
321
  #
349
322
  # Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
350
323
  # for example:
351
- # package(:jar).entry("META-INF/LICENSE").should contain(/Apache Software License/)
352
- def entry(entry_name)
353
- ::Zip::ZipEntry.new(name, entry_name)
324
+ # package(:jar).path("META-INF").entry("LICENSE").should contain(/Apache Software License/)
325
+ def entry(name)
326
+ root.entry("#{@path}#{name}")
354
327
  end
355
328
 
329
+ protected
330
+
356
331
  def entries() #:nodoc:
357
- @entries ||= Zip::ZipFile.open(name) { |zip| zip.entries }
332
+ return root.entries unless @path
333
+ @entries ||= root.entries.inject([]) { |selected, entry|
334
+ selected << entry.name.sub(@path, "") if entry.name.index(@path) == 0
335
+ selected
336
+ }
358
337
  end
359
338
 
360
339
  end
340
+
341
+ # :call-seq:
342
+ # empty?() => boolean
343
+ #
344
+ # Returns true if this ZIP file is empty (has no other entries inside).
345
+ def empty?()
346
+ path("").empty
347
+ end
348
+
349
+ # :call-seq:
350
+ # contain(file*) => boolean
351
+ #
352
+ # Returns true if this ZIP file contains all the specified files. You can use absolute
353
+ # file names and glob patterns (using *, **, etc).
354
+ def contain?(*files)
355
+ path("").contain?(*files)
356
+ end
357
+
358
+ end
359
+
360
+
361
+ class Buildr::ZipTask #:nodoc:
362
+
363
+ # :call-seq:
364
+ # entry(name) => Entry
365
+ #
366
+ # Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
367
+ # for example:
368
+ # package(:jar).entry("META-INF/LICENSE").should contain(/Apache Software License/)
369
+ def entry(entry_name)
370
+ ::Zip::ZipEntry.new(name, entry_name)
371
+ end
372
+
373
+ def entries() #:nodoc:
374
+ @entries ||= Zip::ZipFile.open(name) { |zip| zip.entries }
375
+ end
376
+
377
+ end
378
+
379
+
380
+ class Buildr::Project
381
+ include Buildr::Checks
361
382
  end