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
@@ -0,0 +1,296 @@
1
+ #!/usr/bin/env ruby
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ require 'optparse'
18
+ require 'ostruct'
19
+ require 'fileutils'
20
+
21
+ module GitFlow
22
+ extend self
23
+
24
+ attr_accessor :should_run, :trace, :program
25
+
26
+ self.program = 'gitflow'
27
+ self.should_run = true # should we run at exit?
28
+
29
+ HELP = <<-HELP
30
+
31
+ GitFlow is a tool to create custom git commands implemented in ruby.
32
+ It is generic enougth to be used on any git based project besides Apache Buildr.
33
+
34
+ OVERVIEW:
35
+
36
+ gitflow is intended to help developers with their daily git workflow,
37
+ performing repetitive git commands for them. It is implemented in
38
+ ruby so you can do anything, from invoking rake tasks to telling
39
+ people on twitter you are having trouble with their code :P.
40
+
41
+ To get help for a specific command use:
42
+ gitflow.rb help command
43
+ gitflow.rb command --help
44
+
45
+ For convenience you can create an alias to be execute using git.
46
+ The following example registers buildr-git.rb, which provides apache
47
+ svn and git synchronization commands:
48
+
49
+ git config alias.apache '!'"ruby $PWD/doc/scripts/buildr-git.rb"
50
+
51
+ After that you can use
52
+ git apache command --help
53
+
54
+ EXTENDING YOUR WORKFLOW:
55
+
56
+ You can create your own gitflow commands, to adapt your development
57
+ workflow.
58
+
59
+ Simply create a ruby script somewhere say ~/.buildr/gitflow.rb
60
+ And alias it in your local repo:
61
+
62
+ git config alias.flow '!'"ruby ~/.buildr/gitflow.rb"
63
+ git config alias.work '!'"ruby ~/.buildr/gitflow.rb my-flow sub-work"
64
+
65
+ A sample command would look like this.. (you may want to look at buildr-git.rb)
66
+
67
+ #!/usr/bin/env ruby
68
+ require /path/to/gitflow.rb
69
+
70
+ class MyCommand < GitFlow/'my-flow'
71
+
72
+ @help = "Summary to be displayed when listing commands"
73
+ @documentation = "Very long help that will be paged if necessary. (for --help)"
74
+
75
+ # takes an openstruct to place default values and option values.
76
+ # returns an array of arguments given to optparse.on
77
+ def options(opts)
78
+ opts.something = 'default'
79
+ [
80
+ ['--name NAME', lambda { |n| opts.name = n }],
81
+ ['--yes', lambda { |n| opts.yes = true }]
82
+ ]
83
+ end
84
+
85
+ # takes the opts openstruct after options have been parsed and
86
+ # an argv array with non-option arguments.
87
+ def execute(opts, argv)
88
+ # you can run another command using
89
+ run('other-command', '--using-this', 'arg')
90
+ some = git('config', '--get', 'some.property').chomp rescue nil
91
+ page { puts "This will be paged on terminal if needed" }
92
+ end
93
+
94
+ class SubCommand < MyCommand/'sub-work'
95
+ ... # implement a subcommand
96
+ end
97
+
98
+ end
99
+
100
+ You would then get help for your command with
101
+
102
+ git flow my-flow --help
103
+ git work --help
104
+
105
+ Using gitflow you can customize per-project git interface.
106
+
107
+ HELP
108
+
109
+ # Pager from http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
110
+ def pager
111
+ return if RUBY_PLATFORM =~ /win32/
112
+ return unless STDOUT.tty?
113
+
114
+ read, write = IO.pipe
115
+
116
+ unless Kernel.fork # Child process
117
+ STDOUT.reopen(write)
118
+ STDERR.reopen(write) if STDERR.tty?
119
+ read.close
120
+ write.close
121
+ return
122
+ end
123
+
124
+ # Parent process, become pager
125
+ STDIN.reopen(read)
126
+ read.close
127
+ write.close
128
+
129
+ ENV['LESS'] = 'FSRX' # Don't page if the input is short enough
130
+
131
+ Kernel.select [STDIN] # Wait until we have input before we start the pager
132
+ pager = ENV['PAGER'] || 'less'
133
+ exec pager rescue exec '/bin/sh', '-c', pager
134
+ end
135
+
136
+ # Return a class to be extended in order to register a GitFlow command
137
+ # if command name is nil, it will be registered as the top level command.
138
+ # Classes implementing commands also provide this method, allowing for
139
+ # sub-command creation.
140
+ def /(command_name)
141
+ command_name = command_name.to_s unless command_name.nil?
142
+ cls = Class.new { include GitFlow::Mixin }
143
+ (class << cls; self; end).module_eval do
144
+ attr_accessor :help, :documentation, :command
145
+ define_method(:/) do |subcommand|
146
+ raise "Subcommand cannot be nil" unless subcommand
147
+ GitFlow/([command_name, subcommand].compact.join(' '))
148
+ end
149
+ define_method(:inherited) do |subclass|
150
+ subclass.command = command_name
151
+ GitFlow.commands[command_name] = subclass
152
+ end
153
+ end
154
+ cls
155
+ end
156
+
157
+ def commands
158
+ @commands ||= Hash.new
159
+ end
160
+
161
+ def optparse
162
+ optparse = opt = OptionParser.new
163
+ opt.separator ' '
164
+ opt.separator 'OPTIONS'
165
+ opt.separator ' '
166
+ opt.on('-h', '--help', 'Display this help') do
167
+ GitFlow.pager; puts opt; throw :exit
168
+ end
169
+ opt.on('--trace', 'Display traces') { GitFlow.trace = true }
170
+ optparse
171
+ end
172
+
173
+ def command(argv)
174
+ cmds = []
175
+ argv.each_with_index do |arg, i|
176
+ arg = argv[0..i].join(' ')
177
+ cmds << commands[arg] if commands.key?(arg)
178
+ end
179
+ cmds.last || commands[nil]
180
+ end
181
+
182
+ def run(*argv)
183
+ catch :exit do
184
+ command = self.command(argv).new
185
+ argv = argv[command.class.command.split.length..-1] if command.class.command
186
+ parser = optparse
187
+ parser.banner = "Usage: #{GitFlow.program} #{command.class.command} [options]"
188
+ options = OpenStruct.new
189
+ if command.respond_to?(:options)
190
+ command.options(options).each { |args| parser.on(*args) }
191
+ end
192
+ if command.class.documentation && command.class.documentation != ''
193
+ parser.separator ' '
194
+ parser.separator command.class.documentation.split(/\n/)
195
+ end
196
+ parser.parse!(argv)
197
+ command.execute(options, argv)
198
+ end
199
+ end
200
+
201
+ module Mixin
202
+ include FileUtils
203
+
204
+ # Override this method in your command class if it
205
+ # needs to parse command line options.
206
+ #
207
+ # This method takes an openstruct object as argument
208
+ # allowing you to store default values on it, and
209
+ # set option values.
210
+ #
211
+ # The return value must be an array of arguments
212
+ # given to optparse.on
213
+ def options(opt)
214
+ []
215
+ end
216
+
217
+ # Override this method in your command class to implement
218
+ # the command.
219
+ # First argument is the openstruct object after
220
+ # it has been populated by the option parser.
221
+ # Second argument is the array of non-option arguments.
222
+ def execute(opt, argv)
223
+ fail "#{self.class.command} not implemented"
224
+ end
225
+
226
+ # Run the command line given on argv
227
+ def run(*argv, &block)
228
+ GitFlow.run(*argv, &block)
229
+ end
230
+
231
+ # Yield paging the blocks output if necessary.
232
+ def page
233
+ GitFlow.pager
234
+ yield
235
+ end
236
+
237
+ def trace(*str)
238
+ STDERR.puts(*str) if GitFlow.trace
239
+ end
240
+
241
+ def git(*args)
242
+ cmd = 'git ' + args.map { |arg| arg[' '] ? %Q{"#{arg}"} : arg }.join(' ')
243
+ trace cmd
244
+ `#{cmd}`.tap {
245
+ fail "GIT command `#{cmd}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
246
+ }
247
+ end
248
+
249
+ def sh(*args)
250
+ `#{args.join(' ')}`.tap {
251
+ fail "Shell command `#{args.join(' ')}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
252
+ }
253
+ end
254
+
255
+ def expand_path(path, dir=Dir.pwd)
256
+ File.expand_path(path, dir)
257
+ end
258
+ end
259
+
260
+ class NoSuchCommand < GitFlow/nil
261
+ @documentation = HELP
262
+
263
+ def execute(opts, argv)
264
+ page do
265
+ puts "Command not found: #{argv.join(' ').inspect}"
266
+ puts "Try `#{GitFlow.program} help` to obtain a list of commands."
267
+ end
268
+ end
269
+ end
270
+
271
+ class HelpCommand < GitFlow/:help
272
+ @help = "Display help for a command or show command list"
273
+ @documentation = "Displays help for the command given as argument"
274
+
275
+ def execute(opts, argv)
276
+ if argv.empty?
277
+ opt = GitFlow.optparse
278
+ opt.banner = "Usage: #{GitFlow.program} command [options]"
279
+ opt.separator ' '
280
+ opt.separator 'COMMANDS'
281
+ opt.separator ' '
282
+ commands = GitFlow.commands.map { |name, cls| [nil, name, cls.help] }.
283
+ sort_by { |a| a[1] || '' }
284
+ commands.each { |a| opt.separator("%-2s%-25s%s" % a) if a[1] }
285
+ opt.separator ' '
286
+ opt.separator 'You can also obtain help for any command giving it --help.'
287
+ page { puts opt }
288
+ else
289
+ run(*(argv + ['--help']))
290
+ end
291
+ end
292
+ end
293
+
294
+ end
295
+
296
+ at_exit { GitFlow.run(*ARGV) if GitFlow.should_run }
@@ -14,11 +14,11 @@
14
14
  # License for the specific language governing permissions and limitations under
15
15
  # the License.
16
16
  if [ -z `which jruby` ] ; then
17
- version=1.1
17
+ version=1.1.6
18
18
  target=/opt/jruby
19
19
  echo "Installing JRuby ${version} in ${target}"
20
20
  sudo mkdir -p $(dirname ${target})
21
- wget http://dist.codehaus.org/jruby/jruby-bin-${version}.tar.gz
21
+ wget http://dist.codehaus.org/jruby/${version}/jruby-bin-${version}.tar.gz
22
22
  tar -xz < jruby-bin-${version}.tar.gz
23
23
  sudo mv jruby-${version} ${target}
24
24
  rm jruby-bin-${version}.tar.gz
@@ -26,12 +26,12 @@ if [ -z `which ruby` ] ; then
26
26
  sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
27
27
  # RubyGems broken on Ubunutu, installing directly from source.
28
28
  echo "Installing RubyGems from RubyForge"
29
- wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
30
- tar xzf rubygems-1.2.0.tgz
31
- cd rubygems-1.2.0
29
+ wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
30
+ tar xzf rubygems-1.3.1.tgz
31
+ cd rubygems-1.3.1
32
32
  sudo ruby setup.rb
33
33
  cd ..
34
- rm -rf rubygems-1.2.0
34
+ rm -rf rubygems-1.3.1
35
35
  # ruby is same as ruby1.8, we need gem that is same as gem1.8
36
36
  sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
37
37
  else
@@ -46,8 +46,8 @@ if [ -z $JAVA_HOME ] ; then
46
46
  exit 1
47
47
  fi
48
48
 
49
- if [ $(gem --version) \< '1.0.1' ] ; then
50
- echo "Upgrading to RubyGems 1.0.1"
49
+ if [ $(gem --version) \< '1.3.1' ] ; then
50
+ echo "Upgrading to latest version of RubyGems"
51
51
  sudo gem update --system
52
52
  echo
53
53
  fi
@@ -34,8 +34,8 @@ if [ -z $JAVA_HOME ] ; then
34
34
  export JAVA_HOME=/Library/Java/Home
35
35
  fi
36
36
 
37
- if [ $(gem --version) \< '1.0.1' ] ; then
38
- echo "Upgrading to RubyGems 1.0.1"
37
+ if [ $(gem --version) \< '1.3.1' ] ; then
38
+ echo "Upgrading to latest version of RubyGems"
39
39
  sudo gem update --system
40
40
  echo
41
41
  fi
@@ -1,30 +1,39 @@
1
- h1. Settings/Profiles
1
+ ---
2
+ layout: default
3
+ title: Settings/Profiles
4
+ ---
2
5
 
3
6
 
4
- h2. Environment Variables
7
+ h2(#env_vars). Environment Variables
5
8
 
6
9
  Buildr uses several environment variables that help you control how it works. Some environment variables you will only set once or change infrequently. You can set these in your profile, OS settings or any tool you use to launch Buildr (e.g. continuous integration).
7
10
 
8
11
  For example:
9
12
 
10
- {{{!sh
13
+ <notextile>
14
+ {% highlight sh %}
11
15
  $ export HTTP_PROXY=http://myproxy:8080
12
- }}}
16
+ {% endhighlight %}
17
+ </notextile>
13
18
 
14
19
  There are other environment variables you will want to set when running Buildr, for example, to do a full build without running the tests:
15
20
 
16
- {{{!sh
21
+ <notextile>
22
+ {% highlight sh %}
17
23
  $ buildr test=no
18
- }}}
24
+ {% endhighlight %}
25
+ </notextile>
19
26
 
20
27
  For convenience, when you set environment variables on the command line, the variable name is case insensitive, you can use either @test=no@ or @TEST=no@. Any other way (@export@, @ENV@, etc) the variable names are case sensitive.
21
28
 
22
29
  You can also set environment variables from within your Buildfile. For example, if you discover that building your project requires gobs of JVM heap space, and you want all other team members to run with the same settings:
23
30
 
24
- {{{!ruby
31
+ <notextile>
32
+ {% highlight ruby %}
25
33
  # This project builds a lot of code.
26
34
  ENV['JAVA_OPTS'] ||= '-Xms1g -Xmx1g'
27
- }}}
35
+ {% endhighlight %}
36
+ </notextile>
28
37
 
29
38
  Make sure to set any environment variables at the very top of the Buildfile, above any Ruby statement (even @require@).
30
39
 
@@ -36,25 +45,28 @@ Buildr supports the following environment variables:
36
45
  | @BUILDR_ENV@ | Environment name (development, production, test, etc). Another way to set this is using the @-e@ command line option. |
37
46
  | @DEBUG@ | Set to @no/off@ if you want Buildr to compile without debugging information (default when running the @release@ task, see "Compiling":building.html#compiling). |
38
47
  | @HOME@ | Your home directory. |
39
- | @HTTP_PROXY@ | URL for HTTP proxy server (see "Specifying Repositories":artifacts.html#specifying_repositories). |
48
+ | @HTTP_PROXY@ | URL for HTTP proxy server (see "Specifying Repositories":artifacts.html#repositories). |
49
+ | @HTTPS_PROXY@ | URL for HTTPS proxy server (see "Specifying Repositories":artifacts.html#repositories). |
40
50
  | @JAVA_HOME@ | Points to your JDK, required when using Java and Ant. |
41
51
  | @JAVA_OPTS@ | Command line options to pass to the JDK (e.g. @'-Xms1g'@). |
42
52
  | @M2_REPO@ | Location of the Maven2 local repository. Defaults to the @.m2@ directory in your home directory (@ENV['HOME']@). |
43
- | @NO_PROXY@ | Comma separated list of hosts and domain that should not be proxied (see "Specifying Repositories":artifacts.html#specifying_repositories). |
44
- | @TEST@ | Set to @no/off@ to tell Buildr to skip tests, or @all@ to tell Buildr to run all tests and ignore failures (see "Running Tests":testing.html#running_tests). |
53
+ | @NO_PROXY@ | Comma separated list of hosts and domain that should not be proxied (see "Specifying Repositories":artifacts.html#repositories). |
54
+ | @TEST@ | Set to @no/off@ to tell Buildr to skip tests, or @all@ to tell Buildr to run all tests and ignore failures (see "Running Tests":testing.html#running). |
45
55
  | @USER@ | Tasks that need your user name, for example to log to remote servers, will use this environment variable. |
46
56
 
47
57
  p(note). Buildr does not check any of the arguments in @JAVA_OPTS@. A common mistake is to pass an option like @mx512mb@, where it should be @Xmx512mb@. Make sure to double check @JAVA_OPTS@.
48
58
 
49
59
  Some extensions may use additional environment variables, and of course, you can always add your own. This example uses two environment variables for specifying the username and password:
50
60
 
51
- {{{!ruby
61
+ <notextile>
62
+ {% highlight ruby %}
52
63
  repositories.upload_to[:username] = ENV['USERNAME']
53
64
  repositories.upload_to[:password] = ENV['PASSWORD']
54
- }}}
65
+ {% endhighlight %}
66
+ </notextile>
55
67
 
56
68
 
57
- h2. Personal Settings
69
+ h2(#personal). Personal Settings
58
70
 
59
71
  Some things clearly do not belong in the Buildfile. For example, the username and password you use to upload releases. If you're working in a team or on an open source project, you'd want to keep these in a separate place.
60
72
 
@@ -64,7 +76,8 @@ The prefered way to store personal settings is to create a @.buildr/settings.yam
64
76
 
65
77
  Here's an example @settings.yaml@:
66
78
 
67
- {{{!yaml
79
+ <notextile>
80
+ {% highlight yaml %}
68
81
  # The repositories hash is read automatically by buildr.
69
82
  repositories:
70
83
 
@@ -87,26 +100,30 @@ im:
87
100
  server: jabber.company.com
88
101
  usr: notifier@company-jabber.com
89
102
  pwd: secret
90
- }}}
103
+ {% endhighlight %}
104
+ </notextile>
91
105
 
92
106
  Later your buildfile or addons can reference user preferences using the hash returned by the @Buildr.settings.user@ accessor.
93
107
 
94
- {{{!ruby
108
+ <notextile>
109
+ {% highlight ruby %}
95
110
  task 'relase-notification' do
96
111
  usr, pwd, server = settings.user['im'].values_at('usr', 'pwd', 'server')
97
112
  jabber = JabberAPI.new(server, usr, pwd)
98
113
  jabber.msg("We are pleased to announce the last stable version #{VERSION}")
99
114
  end
100
- }}}
115
+ {% endhighlight %}
116
+ </notextile>
101
117
 
102
118
 
103
- h2. Build Settings
119
+ h2(#build). Build Settings
104
120
 
105
121
  Build settings are local to the project being built, and are placed in the @build.yaml@ file located in the same directory that the @buildfile@. Normally this file would be managed by the project revision control system, so settings here are shared between developers.
106
122
 
107
123
  They help keep the buildfile and build.yaml file simple and readable, working to the advantages of each one. Example for build settings are gems, repositories and artifacts used by that build.
108
124
 
109
- {{{!yaml
125
+ <notextile>
126
+ {% highlight yaml %}
110
127
  # This project requires the following ruby gems, buildr addons
111
128
  gems:
112
129
  # Suppose we want to notify developers when testcases fail.
@@ -133,22 +150,26 @@ twitter:
133
150
 
134
151
  jira:
135
152
  uri: https://jira.corp.org
136
- }}}
153
+ {% endhighlight %}
154
+ </notextile>
137
155
 
138
156
  When buildr is loaded, required ruby gems will be installed if needed, thus adding features like the imaginary twitter notifier addon.
139
157
 
140
158
  Artifacts defined on @build.yaml@ can be referenced on your buildfile by supplying the ruby symbol to the @Buildr.artifact@ and @Buildr.artifacts@ methods. The @compile.with@, @test.with@ methods can also be given these names.
141
159
 
142
- {{{!ruby
160
+ <notextile>
161
+ {% highlight ruby %}
143
162
  define 'my_project' do
144
163
  compile.with artifacts(:log4j, :j2ee)
145
164
  test.with :spring, :j2ee
146
165
  end
147
- }}}
166
+ {% endhighlight %}
167
+ </notextile>
148
168
 
149
169
  Build settings can be retreived using the @Buildr.settings.build@ accessor.
150
170
 
151
- {{{!ruby
171
+ <notextile>
172
+ {% highlight ruby %}
152
173
  task 'create_patch' do
153
174
  patch = Git.create_patch :interactive => true
154
175
  if patch && agree("Would you like to request inclusion of #{patch}")
@@ -156,9 +177,11 @@ Build settings can be retreived using the @Buildr.settings.build@ accessor.
156
177
  jira.create(:improvement, patch.summary, :attachment => patch.blob)
157
178
  end
158
179
  end
159
- }}}
180
+ {% endhighlight %}
181
+ </notextile>
160
182
 
161
- h2. Non constant settings
183
+
184
+ h2(#variable). Non constant settings
162
185
 
163
186
  Before loading the Buildfile, Buildr will attempt to load two other files: the @buildr.rb@ file it finds in your home directory, followed by the @buildr.rb@ file it finds in the build directory.
164
187
 
@@ -166,44 +189,52 @@ The loading order allows you to place global settings that affect all your build
166
189
 
167
190
  Here's an example @buildr.rb@:
168
191
 
169
- {{{!ruby
192
+ <notextile>
193
+ {% highlight ruby %}
170
194
  # Only I should know that
171
195
  repositories.upload_to[:username] = 'assaf'
172
196
  repositories.upload_to[:password] = 'supersecret'
173
197
  # Search here first, it's faster
174
198
  repositories.remote << 'http://inside-the-firewall'
175
- }}}
199
+ {% endhighlight %}
200
+ </notextile>
176
201
 
177
202
 
178
- h2. Environments
203
+ h2(#environments). Environments
179
204
 
180
205
  One common use case is adapting the build to different environments. For example, to compile code with debugging information during development and testing, but strip it for production. Another example is using different databases for development, testing and production, or running services at different URLs.
181
206
 
182
207
  So let's start by talking about the build environment. Buildr has a global attributes that indicates which environment it's running in, accessible from the @environment@ method. You can set the current build environment in one of two ways. Using the @-e/--environment@ command line option:
183
208
 
184
- {{{!sh
209
+ <notextile>
210
+ {% highlight sh %}
185
211
  $ buildr -e test
186
212
  (in /home/john/project, test)
187
- }}}
213
+ {% endhighlight %}
214
+ </notextile>
188
215
 
189
216
  Or by setting the environment variable @BUILDR_ENV@:
190
217
 
191
- {{{!
218
+ <notextile>
219
+ {% highlight text %}
192
220
  $ export BUILDR_ENV=production
193
221
  $ buildr
194
222
  (in /home/john/project, production)
195
- }}}
223
+ {% endhighlight %}
224
+ </notextile>
196
225
 
197
226
  Unless you tell it otherwise, Buildr assumes you're developing and sets the environment to @development@.
198
227
 
199
228
  Here's a simple example for handling different environments within the Buildfile:
200
229
 
201
- {{{!ruby
230
+ <notextile>
231
+ {% highlight ruby %}
202
232
  project 'db-module' do
203
233
  db = (environment == 'production' ? 'oracle' : 'hsql')
204
- resources.from(_(:source, :main, db))
234
+ resources.from(_("src/main/#{db}"))
205
235
  end
206
- }}}
236
+ {% endhighlight %}
237
+ </notextile>
207
238
 
208
239
  We recommend picking a convention for your different environments and following it across all your projects. For example:
209
240
 
@@ -213,7 +244,7 @@ We recommend picking a convention for your different environments and following
213
244
  | production | Building for release/production. |
214
245
 
215
246
 
216
- h2. Profiles
247
+ h2(#profiles). Profiles
217
248
 
218
249
  Different environments may require different configurations, some you will want to control with code, others you will want to specify in the profiles file.
219
250
 
@@ -221,7 +252,8 @@ The profiles file is a YAML file called @profiles.yaml@ that you place in the sa
221
252
 
222
253
  For example, to support three different database configurations, we could write:
223
254
 
224
- {{{!yaml
255
+ <notextile>
256
+ {% highlight yaml %}
225
257
  # HSQL, don't bother storing to disk.
226
258
  development:
227
259
  db: hsql
@@ -236,19 +268,22 @@ test:
236
268
  production:
237
269
  db: oracle
238
270
  jdbc: oracle:thin:@bigstrong:1521:mighty
239
- }}}
271
+ {% endhighlight %}
272
+ </notextile>
240
273
 
241
274
  Here's a simple example for a buildfile that uses the profile information:
242
275
 
243
- {{{!ruby
276
+ <notextile>
277
+ {% highlight ruby %}
244
278
  project 'db-module' do
245
279
  # Copy SQL files specific for the database we're using,
246
280
  # for example, everything under src/main/hsql.
247
- resources.from(_(:source, :main, profile['db']))
281
+ resources.from(_("src/main/#{Buildr.settings.profile['db']}"))
248
282
  # Set the JDBC URL in copied resource files (config.xml needs this).
249
- resources.filter :jdbc=>profile['jdbc']
283
+ resources.filter.using :jdbc=>Buildr.settings.profile['jdbc']
250
284
  end
251
- }}}
285
+ {% endhighlight %}
286
+ </notextile>
252
287
 
253
288
  The @profile@ method returns the current profile, selected based on the current "environment":#environments. You can get a list of all profiles by calling @profiles@.
254
289
 
@@ -258,7 +293,8 @@ We recommend following conventions and using the same environments in all your p
258
293
 
259
294
  YAML allows you to use anchors (@&@), similar to ID attributes in XML, reference the anchored element (@*@) elsewhere, and merge one element into another (@<<@). For example:
260
295
 
261
- {{{!yaml
296
+ <notextile>
297
+ {% highlight yaml %}
262
298
  # We'll reference this one as common.
263
299
  development: &common
264
300
  db: hsql
@@ -269,6 +305,8 @@ development: &common
269
305
  test:
270
306
  <<: *common
271
307
  jdbc: hsqldb:file:testdb
272
- }}}
308
+ {% endhighlight %}
309
+ </notextile>
310
+
273
311
 
274
312
  You can "learn more about YAML here":http://www.yaml.org, and use this handy "YAML quick reference":http://www.yaml.org/refcard.html.