novoda-buildr 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/CHANGELOG +1050 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +245 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +90 -0
  40. data/doc/extending.textile +205 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +265 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +429 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +276 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +287 -0
  68. data/doc/testing.textile +233 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +662 -0
  73. data/lib/buildr/core/build.rb +463 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +363 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +971 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +774 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +424 -0
  94. data/lib/buildr/ide/eclipse.rb~ +424 -0
  95. data/lib/buildr/ide/eclipse/java.rb +53 -0
  96. data/lib/buildr/ide/eclipse/plugin.rb +71 -0
  97. data/lib/buildr/ide/eclipse/scala.rb +68 -0
  98. data/lib/buildr/ide/idea.ipr.template +300 -0
  99. data/lib/buildr/ide/idea.rb +190 -0
  100. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  101. data/lib/buildr/ide/idea7x.rb +212 -0
  102. data/lib/buildr/java.rb +23 -0
  103. data/lib/buildr/java/ant.rb +94 -0
  104. data/lib/buildr/java/bdd.rb +464 -0
  105. data/lib/buildr/java/cobertura.rb +274 -0
  106. data/lib/buildr/java/commands.rb +217 -0
  107. data/lib/buildr/java/compiler.rb +349 -0
  108. data/lib/buildr/java/deprecated.rb +141 -0
  109. data/lib/buildr/java/emma.rb +244 -0
  110. data/lib/buildr/java/jruby.rb +117 -0
  111. data/lib/buildr/java/jtestr_runner.rb.erb +118 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  113. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  114. data/lib/buildr/java/packaging.rb +717 -0
  115. data/lib/buildr/java/pom.rb +174 -0
  116. data/lib/buildr/java/rjb.rb +155 -0
  117. data/lib/buildr/java/test_result.rb +327 -0
  118. data/lib/buildr/java/tests.rb +341 -0
  119. data/lib/buildr/java/version_requirement.rb +172 -0
  120. data/lib/buildr/packaging.rb +24 -0
  121. data/lib/buildr/packaging/archive.rb +491 -0
  122. data/lib/buildr/packaging/artifact.rb +750 -0
  123. data/lib/buildr/packaging/artifact_namespace.rb +980 -0
  124. data/lib/buildr/packaging/artifact_search.rb +140 -0
  125. data/lib/buildr/packaging/gems.rb +106 -0
  126. data/lib/buildr/packaging/package.rb +241 -0
  127. data/lib/buildr/packaging/tar.rb +186 -0
  128. data/lib/buildr/packaging/version_requirement.rb +172 -0
  129. data/lib/buildr/packaging/zip.rb +73 -0
  130. data/lib/buildr/packaging/ziptask.rb +316 -0
  131. data/lib/buildr/resources/buildr.icns +0 -0
  132. data/lib/buildr/scala.rb +25 -0
  133. data/lib/buildr/scala/bdd.rb +114 -0
  134. data/lib/buildr/scala/compiler.rb +196 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  137. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  138. data/lib/buildr/scala/shell.rb +60 -0
  139. data/lib/buildr/scala/tests.rb +157 -0
  140. data/lib/buildr/shell.rb +180 -0
  141. data/rakelib/all-in-one.rake +84 -0
  142. data/rakelib/checks.rake +57 -0
  143. data/rakelib/doc.rake +92 -0
  144. data/rakelib/jekylltask.rb +120 -0
  145. data/rakelib/package.rake +73 -0
  146. data/rakelib/release.rake +152 -0
  147. data/rakelib/rspec.rake +73 -0
  148. data/rakelib/setup.rake +54 -0
  149. data/rakelib/stage.rake +214 -0
  150. data/spec/addon/drb_spec.rb +328 -0
  151. data/spec/core/application_spec.rb +509 -0
  152. data/spec/core/build_spec.rb +678 -0
  153. data/spec/core/checks_spec.rb +519 -0
  154. data/spec/core/common_spec.rb +670 -0
  155. data/spec/core/compile_spec.rb +624 -0
  156. data/spec/core/extension_spec.rb +201 -0
  157. data/spec/core/generate_spec.rb +33 -0
  158. data/spec/core/project_spec.rb +762 -0
  159. data/spec/core/test_spec.rb +1175 -0
  160. data/spec/core/transport_spec.rb +537 -0
  161. data/spec/core/util_spec.rb +67 -0
  162. data/spec/groovy/bdd_spec.rb +80 -0
  163. data/spec/groovy/compiler_spec.rb +240 -0
  164. data/spec/ide/eclipse_spec.rb +650 -0
  165. data/spec/ide/idea7x_spec.rb +84 -0
  166. data/spec/java/ant_spec.rb +33 -0
  167. data/spec/java/bdd_spec.rb +379 -0
  168. data/spec/java/cobertura_spec.rb +85 -0
  169. data/spec/java/compiler_spec.rb +446 -0
  170. data/spec/java/emma_spec.rb +119 -0
  171. data/spec/java/java_spec.rb +124 -0
  172. data/spec/java/packaging_spec.rb +1140 -0
  173. data/spec/java/test_coverage_helper.rb +257 -0
  174. data/spec/java/tests_spec.rb +493 -0
  175. data/spec/packaging/archive_spec.rb +538 -0
  176. data/spec/packaging/artifact_namespace_spec.rb +697 -0
  177. data/spec/packaging/artifact_spec.rb +802 -0
  178. data/spec/packaging/packaging_helper.rb +63 -0
  179. data/spec/packaging/packaging_spec.rb +684 -0
  180. data/spec/sandbox.rb +148 -0
  181. data/spec/scala/bdd_spec.rb +119 -0
  182. data/spec/scala/compiler_spec.rb +284 -0
  183. data/spec/scala/scala.rb +38 -0
  184. data/spec/scala/tests_spec.rb +263 -0
  185. data/spec/spec_helpers.rb +340 -0
  186. data/spec/version_requirement_spec.rb +143 -0
  187. metadata +384 -0
@@ -0,0 +1,205 @@
1
+ ---
2
+ layout: default
3
+ title: Extending Buildr
4
+ ---
5
+
6
+ h2(#tasks). Organizing Tasks
7
+
8
+ A couple of things we learned while working on Buildr. Being able to write your own Rake tasks is a very powerful feature. But if you find yourself doing the same thing over and over, you might also want to consider functions. They give you a lot more power and easy abstractions.
9
+
10
+ For example, we use OpenJPA in several projects. It's a very short task, but each time I have to go back to the OpenJPA documentation to figure out how to set the Ant MappingTool task, tell Ant how to define it. After the second time, you're recognizing a pattern and it's just easier to write a function that does all that for you.
11
+
12
+ Compare this:
13
+
14
+ {% highlight ruby %}
15
+ file('derby.sql') do
16
+ REQUIRES = [
17
+ 'org.apache.openjpa:openjpa-all:jar:0.9.7-incubating',
18
+ 'commons-collections:commons-collections:jar:3.1',
19
+ . . .
20
+ 'net.sourceforge.serp:serp:jar:1.11.0' ]
21
+ ant('openjpa') do |ant|
22
+ ant.taskdef :name=>'mapping',
23
+ :classname=>'org.apache.openjpa.jdbc.ant.MappingToolTask',
24
+ :classpath=>REQUIRES.join(File::PATH_SEPARATOR)
25
+ ant.mapping :schemaAction=>'build', :sqlFile=>task.name,
26
+ :ignoreErrors=>true do
27
+ ant.config :propertiesFile=>_('src/main/sql/derby.xml')
28
+ ant.classpath :path=>projects('store', 'utils' ).
29
+ flatten.map(&:to_s).join(File::PATH_SEPARATOR)
30
+ end
31
+ end
32
+ end
33
+ {% endhighlight %}
34
+
35
+ To this:
36
+
37
+ {% highlight ruby %}
38
+ file('derby.sql') do
39
+ mapping_tool :action=>'build', :sql=>task.name,
40
+ :properties=>_('src/main/sql/derby.xml'),
41
+ :classpath=>projects('store', 'utils')
42
+ end
43
+ {% endhighlight %}
44
+
45
+ I prefer the second. It's easier to look at the Buildfile and understand what it does. It's easier to maintain when you only have to look at the important information.
46
+
47
+ But just using functions is not always enough. You end up with a Buildfile containing a lot of code that clearly doesn't belong there. For starters, I recommend putting it in the @tasks@ directory. Write it into a file with a @.rake@ extension and place that in the @tasks@ directory next to the Buildfile. Buildr will automatically pick it up and load it for you.
48
+
49
+ If you want to share these pre-canned definitions between projects, you have a few more options. You can share the @tasks@ directory using SVN externals, Git modules, or whichever cross-repository feature your source control system supports. Another mechanism with better version control is to package all these tasks, functions and modules into a "Gem":http://rubygems.org/ and require it from your Buildfile. You can run your own internal Gem server for that.
50
+
51
+ To summarize, there are several common ways to distribute extensions:
52
+ * Put them in the same place (e.g. @~/.buildr@) and require them from your
53
+ @buildfile@
54
+ * Put them directly in the project, typically under the @tasks@ directory.
55
+ * Put them in a shared code repository, and link to them from your project's @tasks@ directory
56
+ * As Ruby gems and specify which gems are used in the settings file
57
+
58
+ You can also get creative and devise your own way to distribute extensions.
59
+ "Sake":http://errtheblog.com/post/6069 is a good example of such initiative that lets you deploy Rake tasks on a system-wide basis.
60
+
61
+ h2(#extensions). Creating Extensions
62
+
63
+ The basic mechanism for extending projects in Buildr are Ruby modules. In fact, base features like compiling and testing are all developed in the form of modules, and then added to the core Project class.
64
+
65
+ A module defines instance methods that are then mixed into the project and become instance methods of the project. There are two general ways for extending projects. You can extend all projects by including the module in Project:
66
+
67
+ {% highlight ruby %}
68
+ class Project
69
+ include MyExtension
70
+ end
71
+ {% endhighlight %}
72
+
73
+ You can also extend a given project instance and only that instance by extending it with the module:
74
+
75
+ {% highlight ruby %}
76
+ define 'foo' do
77
+ extend MyExtension
78
+ end
79
+ {% endhighlight %}
80
+
81
+ Some extensions require tighter integration with the project, specifically for setting up tasks and properties, or for configuring tasks based on the project definition. You can do that by adding callbacks to the process.
82
+
83
+ The easiest way to add callbacks is by incorporating the Extension module in your own extension, and using the various class methods to define callback behavior.
84
+
85
+ |_. Method |_. Usage |
86
+ | @first_time@ | This block will be called once for any particular extension. You can use this to setup top-level and local tasks. |
87
+ | @before_define@ | This block is called once for the project with the project instance, right before running the project definition. You can use this to add tasks and set properties that will be used in the project definition. |
88
+ | @after_define@ | This block is called once for the project with the project instance, right after running the project definition. You can use this to do any post-processing that depends on the project definition. |
89
+
90
+ This example illustrates how to write a simple extension:
91
+
92
+ {% highlight ruby %}
93
+ module LinesOfCode
94
+ include Extension
95
+
96
+ first_time do
97
+ # Define task not specific to any projet.
98
+ desc 'Count lines of code in current project'
99
+ Project.local_task('loc')
100
+ end
101
+
102
+ before_define do |project|
103
+ # Define the loc task for this particular project.
104
+ define_task 'loc' do |task|
105
+ lines = task.prerequisites.map { |path| Dir["#{path}/**/*"] }.flatten.uniq.
106
+ inject(0) { |total, file| total + File.readlines(file).count }
107
+ puts "Project #{project.name} has #{lines} lines of code"
108
+ end
109
+ end
110
+
111
+ after_define do |project|
112
+ # Now that we know all the source directories, add them.
113
+ task('loc'=>compile.sources + compile.test.sources)
114
+ end
115
+
116
+ # To use this method in your project:
117
+ # loc path_1, path_2
118
+ def loc(*paths)
119
+ task('loc'=>paths)
120
+ end
121
+
122
+ end
123
+
124
+ class Buildr::Project
125
+ include LinesOfCode
126
+ end
127
+ {% endhighlight %}
128
+
129
+ You may find interesting that this Extension API is used pervasively inside Buildr itself. Many of the standard tasks such as @compile@, @test@, @package@ are extensions to a very small core.
130
+
131
+ Starting with Buildr 1.4, it's possible to define ordering between @before_define@ and @after_define@ code blocks in a way similar to Rake's dependencies. For example, if you wanted to override @project.test.compile.from@ in @after_define@, you could do so by in
132
+
133
+ {% highlight ruby %}
134
+ after_define(:functional_tests) do |project|
135
+ # Change project.test.compile.from if it's not already pointing
136
+ # to a location with Java sources
137
+ if Dir["#{project.test.compile.from}/**/*.java"].size == 0 &&
138
+ Dir["#{project._(:src, 'test-functional', :java)}/**/*.java"].size > 0
139
+ project.test.compile.from project._(:src, 'test-functional', :java)
140
+ end
141
+ end
142
+
143
+ # make sure project.test.compile.from is updated before the
144
+ # compile extension picks up its value
145
+ after_define(:compile => :functional_test)
146
+ {% endhighlight %}
147
+
148
+ Core extensions provide the following named callbacks: @compile@, @test@, @build@, @package@ and @check@.
149
+
150
+ h2(#layouts). Using Alternative Layouts
151
+
152
+ Buildr follows a common convention for project layouts: Java source files appear in @src/main/java@ and compile to @target/classes@, resources are copied over from @src/main/resources@ and so forth. Not all projects follow this convention, so it's now possible to specify an alternative project layout.
153
+
154
+ The default layout is available in @Layout.default@, and all projects inherit it. You can set @Layout.default@ to your own layout, or define a project with a given layout (recommended) by setting the @:layout@ property. Projects inherit the layout from their parent projects. For example:
155
+
156
+ {% highlight ruby %}
157
+ define 'foo', :layout=>my_layout do
158
+ ...
159
+ end
160
+ {% endhighlight %}
161
+
162
+ A layout is an object that implements the @expand@ method. The easiest way to define a custom layout is to create a new @Layout@ object and specify mapping between names used by Buildr and actual paths within the project. For example:
163
+
164
+ {% highlight ruby %}
165
+ my_layout = Layout.new
166
+ my_layout[:source, :main, :java] = 'java'
167
+ my_layout[:source, :main, :resources] = 'resources'
168
+ {% endhighlight %}
169
+
170
+ Partial expansion also works, so you can specify the above layout using:
171
+
172
+ {% highlight ruby %}
173
+ my_layout = Layout.new
174
+ my_layout[:source, :main] = ''
175
+ {% endhighlight %}
176
+
177
+ If you need anything more complex, you can always subclass @Layout@ and add special handling in the @expand@ method, you'll find one such example in the API documentation.
178
+
179
+ The built-in tasks expand lists of symbols into relative paths, using the following convention:
180
+
181
+ |_. Path |_. Expands to |
182
+ | @:source, :main, <lang/usage>@ | Directory containing source files for a given language or usage, for example, @:java@, @:resources@, @:webapp@. |
183
+ | @:source, :test, <lang/usage>@ | Directory containing test files for a given language or usage, for example, @:java@, @:resources@. |
184
+ | @:target, :generated@ | Target directory for generated code (typically source code). |
185
+ | @:target, :main, <lang/usage>@ | Target directory for compiled code, for example, @:classes@, @:resources@. |
186
+ | @:target, :test, <lang/usage>@ | Target directory for compile test cases, for example, @:classes@, @:resources@. |
187
+ | @:reports, <framework/usage>@ | Target directory for generated reports, for example, @:junit@, @:coverage@. |
188
+
189
+ All tasks are encouraged to use the same convention, and whenever possible, we recommend using the project's @path_to@ method to expand a list of symbols into a path, or use the appropriate path when available. For example:
190
+
191
+ {% highlight ruby %}
192
+ define 'bad' do
193
+ # This may not be the real target.
194
+ puts 'Compiling to ' + path_to('target/classes')
195
+ # This will break with different layouts.
196
+ package(:jar).include 'src/main/etc/*'
197
+ end
198
+
199
+ define 'good' do
200
+ # This is always the compiler's target.
201
+ puts 'Compiling to ' + compile.target.to_s
202
+ # This will work with different layouts.
203
+ package(:jar).include path_to(:source, :main, :etc, '*')
204
+ end
205
+ {% endhighlight %}
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,69 @@
1
+ ---
2
+ layout: default
3
+ title: Apache Buildr
4
+ ---
5
+
6
+ Apache Buildr is a build system for Java-based applications, including support for Scala, Groovy and a growing number of JVM languages and tools. We wanted something that's simple and intuitive to use, so we only need to tell it what to do, and it takes care of the rest. But also something we can easily extend for those one-off tasks, with a language that's a joy to use. And of course, we wanted it to be fast, reliable and have outstanding dependency management.
7
+
8
+
9
+ h2(#why). Why Buildr Rocks
10
+
11
+ "Daniel Spiewak":http://www.codecommit.com/blog:
12
+
13
+ bq. If you think about it, the question isn’t “Why use Buildr?”, it’s really “Why use anything else?” The advantages afforded by Buildr are so substantial, I really can’t see myself going with any other tool, at least not when I have a choice.
14
+
15
+ "Tristan Juricek":http://tristanhunt.com/:
16
+
17
+ bq. That’s still the strongest sell: it builds everything I need, and as I’ve needed more, I just got things working without a lot of fuss.
18
+
19
+ "Matthieu Riou":http://offthelip.org/:
20
+
21
+ bq. We used to rely on Ant, with a fairly extensive set of scripts. It worked but was expensive to maintain. The biggest mistake afterward was to migrate to Maven2. I could write pages of rants explaining all the problems we ran into and we still ended up with thousands of lines of XML.
22
+
23
+ "Martin Grotzke":http://www.javakaffee.de/blog/:
24
+
25
+ bq. The positive side effect for me as a java user is that I learn a little ruby, and that’s easy but lots of fun… :-)
26
+
27
+ "Ijonas Kisselbach":http://twitter.com/ijonas/statuses/4134103928:
28
+
29
+ bq. I've cleaned up & migrated the Vamosa build process from 768 lines of Ant build.xml to 28 lines of Buildr.
30
+
31
+ h2(#what). What You Get
32
+
33
+ * A simple way to specify projects, and build large projects out of smaller sub-projects.
34
+ * Pre-canned tasks that require the least amount of configuration, keeping the build script DRY and simple.
35
+ * Compiling, copying and filtering resources, JUnit/TestNG test cases, APT source code generation, Javadoc and more.
36
+ * A dependency mechanism that only builds what has changed since the last release.
37
+ * A drop-in replacement for Maven 2.0, Buildr uses the same file layout, artifact specifications, local and remote repositories.
38
+ * All your Ant tasks are belong to us! Anything you can do with Ant, you can do with Buildr.
39
+ * No overhead for building "plugins" or configuration. Just write new tasks or functions.
40
+ * Buildr is Ruby all the way down. No one-off task is too demanding when you write code using variables, functions and objects.
41
+ * Simple way to upgrade to new versions.
42
+ * Did we mention fast?
43
+
44
+ So let's get started. You can "read the documentation online":quick_start.html, or "download the PDF":buildr.pdf.
45
+
46
+
47
+ h2(#news). What's New
48
+
49
+ New in Buildr 1.3.5:
50
+
51
+ * Interactive shell (REPL) support, including BeanShell for Java projects
52
+ * Scala libraries are automatically downloaded if not availabe locally
53
+ * New 'cobertura:check' allows you to check for code coverage levels in your projects
54
+ * Eclipse task is configurable to support various types of natures, builders, etc.
55
+ * Dependency upgrades such as Net-SSH 2.0.15, JRuby 1.3.1, Rake 0.8.7, RSpec 1.2.8, easyb 0.9, TestNG 5.10
56
+ * And 15+ bug fixes.
57
+
58
+ See the "CHANGELOG":CHANGELOG for full details.
59
+
60
+
61
+ h2(#notices). Credits & Notices
62
+
63
+ !http://www.apache.org/images/asf-logo.gif(A project of the Apache Software Foundation)!:http://www.apache.org
64
+
65
+ The Apache Software Foundation is a non-profit organization, consider "sponsoring":http://www.apache.org/foundation/sponsorship.html and check the "thanks":http://www.apache.org/foundation/thanks.html page.
66
+
67
+ "ColorCons":http://www.mouserunner.com/Spheres_ColoCons1_Free_Icons.html, copyright of Ken Saunders. "DejaVu fonts":http://dejavu.sourceforge.net, copyright of Bitstream, Inc.
68
+
69
+ Community member quotes from a thread on "Stack Overflow":http://stackoverflow.com/questions/1015525/why-use-buildr-instead-of-ant-or-maven/1055864.
@@ -0,0 +1,265 @@
1
+ ---
2
+ layout: default
3
+ title: Installing and Running
4
+ ---
5
+
6
+
7
+ *The easy way:* We recommend you pick the platform you want to run Buildr on and then follow the _easy way_ instructions for that platform. It could save you an hour or two struggling to install all the right dependencies.
8
+
9
+ "Installing Buildr for JRuby":#jruby is the same on all operating systems. Choose JRuby if you're working with Java 6 on OS X, developing with multiple JDKs, or just like JRuby better.
10
+
11
+ If you are running behind a proxy server, make sure the environment variable @HTTP_PROXY@ is set, as many of these steps require HTTP access.
12
+
13
+ <br>
14
+
15
+ *In details:* The @gem install@ and @gem update@ commands install Buildr from a binary distribution provided through "RubyForge":http://rubyforge.org/projects/buildr. This distribution is maintained by contributors to this project, but is *not* an official Apache distribution. You can obtain the official Apache distribution files from the "download page":download.html.
16
+
17
+ Older versions of RubyGems are all kind of fail. You want to avoid these unless you have the patience to install each Buildr dependency manually. Get RubyGems 1.3.1 or later, and when using Debian packages (e.g. Ubuntu), make sure to get the unmolested RubyGems straight form the source.
18
+
19
+ The Ruby interpreter and JVM must use compatible architectures. For example, OS X comes with 32-bit version of Ruby, Java 1.5 in both 32-bit and 64-bit flavors, and 64-bit Java 6. As a result you can run Ruby with Java 1.5 (32-bit), but to use Java 6 you either need to build Ruby from source for 64-bit, or use "Buildr for JRuby":#jruby.
20
+
21
+ h2(#linux). Installing on Linux
22
+
23
+ *The easy way:* Use this bash script to "install Buildr on Linux":scripts/install-linux.sh. This script will install the most recent version of Buildr, or if already installed, upgrade to the most recent version. It will also install Ruby 1.8.6 if not already installed (requires @apt-get@, @yum@ or @urpmi@) and upgrade to RubyGems 1.3.1 or later.
24
+
25
+ p(note). At this time, the native Ruby-Java Bridge (RJB) does not work very well on Linux with JDK 1.6. If you get Segmentation Fault errors with JDK 1.6, we recommend switching to JDK 1.5.
26
+
27
+ <br>
28
+
29
+ *In details:* To get started you will need a recent version of Ruby, Ruby Gems and build tools for compiling native libraries (@make@, @gcc@ and standard headers).
30
+
31
+ On *RedHat/Fedora* you can use yum to install Ruby and RubyGems, and then upgrade to the most recent version of RubyGems:
32
+
33
+ {% highlight sh %}
34
+ $ sudo yum install ruby rubygems ruby-devel gcc
35
+ $ sudo gem update --system
36
+ {% endhighlight %}
37
+
38
+ On *Ubuntu* you have to install several packages:
39
+
40
+ {% highlight sh %}
41
+ $ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
42
+ {% endhighlight %}
43
+
44
+ The Debian package for @rubygems@ will not allow you to install Buildr, so you need to install RubyGems from source:
45
+
46
+ {% highlight sh %}
47
+ $ wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
48
+ $ tar xzf rubygems-1.3.1.tgz
49
+ $ cd rubygems-1.3.1
50
+ $ sudo ruby setup.rb
51
+ $ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
52
+ {% endhighlight %}
53
+
54
+ Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution. Next, use Ruby Gem to install Buildr:
55
+
56
+ {% highlight sh %}
57
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
58
+ {% endhighlight %}
59
+
60
+ To upgrade to a new version or install a specific version:
61
+
62
+ {% highlight sh %}
63
+ $ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
64
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
65
+ {% endhighlight %}
66
+
67
+
68
+
69
+ h2(#osx). Installing on OS X
70
+
71
+ *The easy way:* Use this script to "install Buildr on OS X":scripts/install-osx.sh. This script will install the most recent version of Buildr, or if already installed, upgrade to the most recent version. It will also install Ruby 1.8.6 if not already installed (using MacPorts/Fink) and upgrage RubyGems to 1.3.1 or later.
72
+
73
+ <br>
74
+
75
+ *In details:* OS X 10.5 (Leopard) comes with a recent version of Ruby 1.8.6. You do not need to install a different version of Ruby when running OS X 10.5.
76
+
77
+ OS X 10.4 (Tiger) includes an older version of Ruby that is not compatible with Buildr. You can install Ruby 1.8.6 using MacPorts (@sudo port install ruby rb-rubygems@), Fink or the "Ruby One-Click Installer for OS X":http://rubyosx.rubyforge.org/.
78
+
79
+ We recommend you first upgrade to the latest version of Ruby gems:
80
+
81
+ {% highlight sh %}
82
+ $ sudo gem update --system
83
+ {% endhighlight %}
84
+
85
+ Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution:
86
+
87
+ {% highlight sh %}
88
+ $ export JAVA_HOME=/Library/Java/Home
89
+ {% endhighlight %}
90
+
91
+ To install Buildr:
92
+
93
+ {% highlight sh %}
94
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
95
+ {% endhighlight %}
96
+
97
+ To upgrade to a new version or install a specific version:
98
+
99
+ {% highlight sh %}
100
+ $ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
101
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
102
+ {% endhighlight %}
103
+
104
+
105
+ h2(#windows). Installing on Windows
106
+
107
+ *The easy way:* The easiest way to install Ruby is using the "one-click installer":http://rubyinstaller.rubyforge.org/. Be sure to install Ruby 1.8.6; support for Ruby 1.9.x is still a work in progress. Once installed, set the @JAVA_HOME@ environment variable and run @gem install buildr --platform mswin32@.
108
+
109
+ <br>
110
+
111
+ *In details:* We recommend you first upgrade to the latest version of Ruby gems:
112
+
113
+ {% highlight sh %}
114
+ > gem update --system
115
+ {% endhighlight %}
116
+
117
+ Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution. Next, use Ruby Gem to install Buildr:
118
+
119
+ {% highlight sh %}
120
+ > gem install buildr --platform mswin32
121
+ {% endhighlight %}
122
+
123
+ To upgrade to a new version or install a specific version:
124
+
125
+ {% highlight sh %}
126
+ > gem update buildr
127
+ > gem install buildr -v 1.3.4 --platform mswin32
128
+ {% endhighlight %}
129
+
130
+ h2(#jruby). Installing for JRuby
131
+
132
+ *The easy way:* Use this bash script to "install Buildr on JRuby":scripts/install-jruby.sh. This script will install the most recent version of Buildr, or if already installed, upgrade to the most recent version. If necessary, it will also install JRuby 1.1.6 in @/opt/jruby@ and update the @PATH@ variable in @~/.bash_profile@ or @~/.profile@.
133
+
134
+ <br>
135
+
136
+ *In details:* If you don't already have JRuby 1.1.6 or later installed, you can download it from the "JRuby site":http://dist.codehaus.org/jruby/.
137
+
138
+ After uncompressing JRuby, update your @PATH@ to include both @java@ and @jruby@ executables.
139
+
140
+ For Linux and OS X:
141
+
142
+ {% highlight sh %}
143
+ $ export PATH=$PATH:[path to JRuby]/bin:$JAVA_HOME/bin
144
+ $ jruby -S gem install buildr
145
+ {% endhighlight %}
146
+
147
+ For Windows:
148
+
149
+ {% highlight sh %}
150
+ > set PATH=%PATH%;[path to JRuby]/bin;%JAVA_HOME%/bin
151
+ > jruby -S gem install buildr
152
+ {% endhighlight %}
153
+
154
+ To upgrade to a new version or install a specific version:
155
+
156
+ {% highlight sh %}
157
+ $ jruby -S gem update buildr
158
+ $ jruby -S gem install buildr -v 1.3.4
159
+ {% endhighlight %}
160
+
161
+
162
+ *Important: Running JRuby and Ruby side by side*
163
+
164
+ Ruby and JRuby maintain separate Gem repositories, and in fact install slightly different versions of the Buildr Gem (same functionality, different dependencies). Installing Buildr for Ruby does not install it for JRuby and vice versa.
165
+
166
+ If you have JRuby installed but not Ruby, the @gem@ and @buildr@ commands will use JRuby. If you have both JRuby and Ruby installed, follow the instructions below. To find out if you have Ruby installed (some operating systems include it by default), run @ruby --version@ from the command line.
167
+
168
+ To work exclusively with JRuby, make sure it shows first on the path, for example, by setting @PATH=/opt/jruby/bin:$PATH@.
169
+
170
+ You can use JRuby and Ruby side by side, by running scripts with the @-S@ command line argument. For example:
171
+
172
+ {% highlight sh %}
173
+ $ # with Ruby
174
+ $ ruby -S gem install buildr
175
+ $ ruby -S buildr
176
+ $ # with JRuby
177
+ $ jruby -S gem install buildr
178
+ $ jruby -S buildr
179
+ {% endhighlight %}
180
+
181
+ Run @buildr --version@ from the command line to find which version of Buildr you are using by default. If you see @(JRuby ...)@, Buildr is running on that version of JRuby.
182
+
183
+
184
+ h2(#running). Running Buildr
185
+
186
+ You need a *Buildfile*, a build script that tells Buildr all about the projects it's building, what they contain, what to produce, and so on. The Buildfile resides in the root directory of your project. We'll talk more about it in "the next chapter":projects.html. If you don't already have one, ask Buildr to create it by running @buildr@.
187
+
188
+ p(tip). You'll notice that Buildr creates a file called @buildfile@. It's case sensitive, but Buildr will look for either @buildfile@ or @Buildfile@.
189
+
190
+ You use Buildr by running the @buildr@ command:
191
+
192
+ {% highlight sh %}
193
+ $ buildr [options] [tasks] [name=value]
194
+ {% endhighlight %}
195
+
196
+ There are several options you can use, for a full list of options type @buildr --help@:
197
+
198
+ |_. Option |_. Usage |
199
+ | @-f/--buildfile [file]@ | Specify the buildfile. |
200
+ | @-e/--environment [name]@ | Environment name (e.g. development, test, production). |
201
+ | @-h/--help@ | Display this help message. |
202
+ | @-n/--nosearch@ | Do not search parent directories for the buildfile. |
203
+ | @-q/--quiet@ | Do not log messages to standard output. |
204
+ | @-r/--require [file]@ | Require MODULE before executing buildfile. |
205
+ | @-t/--trace@ | Turn on invoke/execute tracing, enable full backtrace. |
206
+ | @-v/--version@ | Display the program version. |
207
+ | @-P/--prereqs@ | Display tasks and dependencies, then exit. |
208
+
209
+ You can tell Buildr to run specific tasks and the order to run them. For example:
210
+
211
+ {% highlight sh %}
212
+ # Clean and rebuild
213
+ buildr clean build
214
+ # Package and install
215
+ buildr install
216
+ {% endhighlight %}
217
+
218
+ If you don't specify a task, Buildr will run the "@build@ task":building.html, compiling source code and running test cases. Running a task may run other tasks as well, for example, running the @install@ task will also run @package@.
219
+
220
+ There are several "environment variables":settings_profiles.html#env_vars that let you control how Buildr works, for example, to skip test cases during a build, or specify options for the JVM. Depending on the variable, you may want to set it once in your environment, or set a different value each time you run Buildr.
221
+
222
+ For example:
223
+
224
+ {% highlight sh %}
225
+ $ export JAVA_OPTS='-Xms1g -Xmx1g'
226
+ $ buildr TEST=no
227
+ {% endhighlight %}
228
+
229
+
230
+ h2(#help). Help Tasks
231
+
232
+ Buildr includes a number of informative tasks. Currently that number stands at two, but we'll be adding more tasks in future releases. These tasks report information from the Buildfile, so you need one to run them. For more general help (version number, command line arguments, etc) use @buildr --help@.
233
+
234
+ To start with, type:
235
+
236
+ {% highlight sh %}
237
+ $ buildr help
238
+ {% endhighlight %}
239
+
240
+ You can list the name and description of all your projects using the @help:projects@ task. For example:
241
+
242
+ {% highlight sh %}
243
+ $ buildr help:projects
244
+ killer-app # Code. Build. ??? Profit!
245
+ killer-app:teh-api # Abstract classes and interfaces
246
+ killer-app:teh-impl # All those implementation details
247
+ killer-app:la-web # What our users see
248
+ {% endhighlight %}
249
+
250
+ You are, of course, describing your projects for the sake of those who will maintain your code, right? To describe a project, or a task, call the @desc@ method before the project or task definition.
251
+
252
+ So next let's talk about "projects":projects.html.
253
+
254
+
255
+ h2(#more). Learning More
256
+
257
+ *Ruby* It pays to pick up Ruby as a second (or first) programming language. It's fun, powerful and slightly addictive. If you're interested in learning Ruby the language, a good place to start is "Programming Ruby: The Pragmatic Programmer's Guide":http://www.pragprog.com/titles/ruby/programming-ruby, fondly known as the _Pickaxe book_.
258
+
259
+ For a quicker read (and much more humor), "Why’s (Poignant) Guide to Ruby":http://poignantguide.net/ruby/ is available online. More resources are listed on the "ruby-lang web site":http://www.ruby-lang.org/en/documentation/.
260
+
261
+ *Rake* Buildr is based on Rake, a Ruby build system that handles tasks and dependencies. Check out the "Rake documentation":http://docs.rubyrake.org/ for more information.
262
+
263
+ *AntWrap* Buildr uses AntWrap, for configuring and running Ant tasks. You can learn more from the "Antwrap documentation":http://antwrap.rubyforge.org/.
264
+
265
+ *YAML* Buildr uses YAML for its profiles. You can "learn more about YAML here":http://www.yaml.org, and use this handy "YAML quick reference":http://www.yaml.org/refcard.html.