mguymon-buildr 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data/CHANGELOG +1291 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +44 -0
  6. data/_buildr +35 -0
  7. data/_jbuildr +35 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/bnd.rb +147 -0
  10. data/addon/buildr/cobertura.rb +22 -0
  11. data/addon/buildr/drb.rb +281 -0
  12. data/addon/buildr/emma.rb +22 -0
  13. data/addon/buildr/hibernate.rb +149 -0
  14. data/addon/buildr/javacc.rb +85 -0
  15. data/addon/buildr/jaxb_xjc.rb +72 -0
  16. data/addon/buildr/jdepend.rb +60 -0
  17. data/addon/buildr/jetty.rb +248 -0
  18. data/addon/buildr/jibx.rb +86 -0
  19. data/addon/buildr/nailgun.rb +221 -0
  20. data/addon/buildr/openjpa.rb +88 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  23. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  27. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  28. data/addon/buildr/protobuf.rb +88 -0
  29. data/addon/buildr/xmlbeans.rb +93 -0
  30. data/bin/buildr +19 -0
  31. data/buildr.buildfile +58 -0
  32. data/buildr.gemspec +78 -0
  33. data/doc/_config.yml +1 -0
  34. data/doc/_layouts/default.html +90 -0
  35. data/doc/_layouts/preface.html +22 -0
  36. data/doc/artifacts.textile +217 -0
  37. data/doc/building.textile +276 -0
  38. data/doc/contributing.textile +268 -0
  39. data/doc/css/default.css +236 -0
  40. data/doc/css/print.css +101 -0
  41. data/doc/css/syntax.css +23 -0
  42. data/doc/download.textile +151 -0
  43. data/doc/extending.textile +212 -0
  44. data/doc/images/1442160941-frontcover.jpg +0 -0
  45. data/doc/images/asf-logo.gif +0 -0
  46. data/doc/images/asf-logo.png +0 -0
  47. data/doc/images/buildr-hires.png +0 -0
  48. data/doc/images/buildr.png +0 -0
  49. data/doc/images/favicon.png +0 -0
  50. data/doc/images/growl-icon.tiff +0 -0
  51. data/doc/images/note.png +0 -0
  52. data/doc/images/project-structure.png +0 -0
  53. data/doc/images/tip.png +0 -0
  54. data/doc/images/zbuildr.png +0 -0
  55. data/doc/images/zbuildr.tif +0 -0
  56. data/doc/index.textile +109 -0
  57. data/doc/installing.textile +284 -0
  58. data/doc/languages.textile +599 -0
  59. data/doc/mailing_lists.textile +29 -0
  60. data/doc/more_stuff.textile +845 -0
  61. data/doc/packaging.textile +618 -0
  62. data/doc/preface.textile +54 -0
  63. data/doc/projects.textile +276 -0
  64. data/doc/quick_start.textile +210 -0
  65. data/doc/releasing.textile +117 -0
  66. data/doc/scripts/buildr-git.rb +512 -0
  67. data/doc/scripts/gitflow.rb +296 -0
  68. data/doc/scripts/install-jruby.sh +44 -0
  69. data/doc/scripts/install-linux.sh +73 -0
  70. data/doc/scripts/install-osx.sh +52 -0
  71. data/doc/settings_profiles.textile +287 -0
  72. data/doc/testing.textile +247 -0
  73. data/etc/KEYS +189 -0
  74. data/lib/buildr.rb +44 -0
  75. data/lib/buildr/clojure.rb +34 -0
  76. data/lib/buildr/clojure/shell.rb +52 -0
  77. data/lib/buildr/core.rb +34 -0
  78. data/lib/buildr/core/application.rb +700 -0
  79. data/lib/buildr/core/build.rb +516 -0
  80. data/lib/buildr/core/cc.rb +166 -0
  81. data/lib/buildr/core/checks.rb +253 -0
  82. data/lib/buildr/core/common.rb +151 -0
  83. data/lib/buildr/core/compile.rb +622 -0
  84. data/lib/buildr/core/doc.rb +276 -0
  85. data/lib/buildr/core/environment.rb +129 -0
  86. data/lib/buildr/core/filter.rb +404 -0
  87. data/lib/buildr/core/generate.rb +197 -0
  88. data/lib/buildr/core/help.rb +119 -0
  89. data/lib/buildr/core/jrebel.rb +42 -0
  90. data/lib/buildr/core/linux.rb +30 -0
  91. data/lib/buildr/core/osx.rb +46 -0
  92. data/lib/buildr/core/progressbar.rb +161 -0
  93. data/lib/buildr/core/project.rb +975 -0
  94. data/lib/buildr/core/run.rb +43 -0
  95. data/lib/buildr/core/shell.rb +137 -0
  96. data/lib/buildr/core/test.rb +843 -0
  97. data/lib/buildr/core/transports.rb +575 -0
  98. data/lib/buildr/core/util.rb +537 -0
  99. data/lib/buildr/groovy.rb +20 -0
  100. data/lib/buildr/groovy/bdd.rb +106 -0
  101. data/lib/buildr/groovy/compiler.rb +153 -0
  102. data/lib/buildr/groovy/doc.rb +76 -0
  103. data/lib/buildr/groovy/shell.rb +57 -0
  104. data/lib/buildr/ide.rb +19 -0
  105. data/lib/buildr/ide/eclipse.rb +427 -0
  106. data/lib/buildr/ide/eclipse/java.rb +53 -0
  107. data/lib/buildr/ide/eclipse/plugin.rb +71 -0
  108. data/lib/buildr/ide/eclipse/scala.rb +68 -0
  109. data/lib/buildr/ide/idea.rb +576 -0
  110. data/lib/buildr/java.rb +25 -0
  111. data/lib/buildr/java/ant.rb +94 -0
  112. data/lib/buildr/java/bdd.rb +460 -0
  113. data/lib/buildr/java/cobertura.rb +297 -0
  114. data/lib/buildr/java/commands.rb +223 -0
  115. data/lib/buildr/java/compiler.rb +135 -0
  116. data/lib/buildr/java/deprecated.rb +141 -0
  117. data/lib/buildr/java/doc.rb +86 -0
  118. data/lib/buildr/java/ecj.rb +69 -0
  119. data/lib/buildr/java/emma.rb +244 -0
  120. data/lib/buildr/java/external.rb +73 -0
  121. data/lib/buildr/java/jruby.rb +122 -0
  122. data/lib/buildr/java/jtestr_result.rb +295 -0
  123. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  124. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  125. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  126. data/lib/buildr/java/packaging.rb +734 -0
  127. data/lib/buildr/java/pom.rb +178 -0
  128. data/lib/buildr/java/rjb.rb +154 -0
  129. data/lib/buildr/java/test_result.rb +101 -0
  130. data/lib/buildr/java/tests.rb +362 -0
  131. data/lib/buildr/java/version_requirement.rb +172 -0
  132. data/lib/buildr/packaging.rb +25 -0
  133. data/lib/buildr/packaging/archive.rb +535 -0
  134. data/lib/buildr/packaging/artifact.rb +904 -0
  135. data/lib/buildr/packaging/artifact_namespace.rb +984 -0
  136. data/lib/buildr/packaging/artifact_search.rb +140 -0
  137. data/lib/buildr/packaging/gems.rb +105 -0
  138. data/lib/buildr/packaging/package.rb +249 -0
  139. data/lib/buildr/packaging/repository_array.rb +108 -0
  140. data/lib/buildr/packaging/tar.rb +189 -0
  141. data/lib/buildr/packaging/version_requirement.rb +192 -0
  142. data/lib/buildr/packaging/zip.rb +178 -0
  143. data/lib/buildr/packaging/ziptask.rb +356 -0
  144. data/lib/buildr/resources/buildr.icns +0 -0
  145. data/lib/buildr/resources/completed.png +0 -0
  146. data/lib/buildr/resources/failed.png +0 -0
  147. data/lib/buildr/resources/icons-license.txt +17 -0
  148. data/lib/buildr/run.rb +195 -0
  149. data/lib/buildr/scala.rb +26 -0
  150. data/lib/buildr/scala/bdd.rb +118 -0
  151. data/lib/buildr/scala/compiler.rb +242 -0
  152. data/lib/buildr/scala/doc.rb +142 -0
  153. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  154. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  155. data/lib/buildr/scala/shell.rb +52 -0
  156. data/lib/buildr/scala/tests.rb +171 -0
  157. data/lib/buildr/shell.rb +185 -0
  158. data/lib/buildr/version.rb +18 -0
  159. data/rakelib/all-in-one.rake +113 -0
  160. data/rakelib/checks.rake +57 -0
  161. data/rakelib/doc.rake +137 -0
  162. data/rakelib/metrics.rake +39 -0
  163. data/rakelib/package.rake +73 -0
  164. data/rakelib/release.rake +160 -0
  165. data/rakelib/rspec.rake +91 -0
  166. data/rakelib/setup.rake +66 -0
  167. data/rakelib/stage.rake +220 -0
  168. data/spec/addon/bnd_spec.rb +330 -0
  169. data/spec/addon/drb_spec.rb +328 -0
  170. data/spec/addon/jaxb_xjc_spec.rb +125 -0
  171. data/spec/core/application_spec.rb +631 -0
  172. data/spec/core/build_spec.rb +837 -0
  173. data/spec/core/cc_spec.rb +224 -0
  174. data/spec/core/checks_spec.rb +519 -0
  175. data/spec/core/common_spec.rb +725 -0
  176. data/spec/core/compile_spec.rb +658 -0
  177. data/spec/core/doc_spec.rb +195 -0
  178. data/spec/core/extension_spec.rb +201 -0
  179. data/spec/core/generate_spec.rb +33 -0
  180. data/spec/core/project_spec.rb +772 -0
  181. data/spec/core/run_spec.rb +93 -0
  182. data/spec/core/shell_spec.rb +146 -0
  183. data/spec/core/test_spec.rb +1320 -0
  184. data/spec/core/transport_spec.rb +544 -0
  185. data/spec/core/util_spec.rb +141 -0
  186. data/spec/groovy/bdd_spec.rb +80 -0
  187. data/spec/groovy/compiler_spec.rb +251 -0
  188. data/spec/groovy/doc_spec.rb +65 -0
  189. data/spec/ide/eclipse_spec.rb +739 -0
  190. data/spec/ide/idea_spec.rb +1145 -0
  191. data/spec/java/ant_spec.rb +37 -0
  192. data/spec/java/bdd_spec.rb +374 -0
  193. data/spec/java/cobertura_spec.rb +112 -0
  194. data/spec/java/commands_spec.rb +93 -0
  195. data/spec/java/compiler_spec.rb +252 -0
  196. data/spec/java/doc_spec.rb +56 -0
  197. data/spec/java/ecj_spec.rb +115 -0
  198. data/spec/java/emma_spec.rb +121 -0
  199. data/spec/java/external_spec.rb +56 -0
  200. data/spec/java/java_spec.rb +132 -0
  201. data/spec/java/packaging_spec.rb +1266 -0
  202. data/spec/java/run_spec.rb +78 -0
  203. data/spec/java/test_coverage_helper.rb +257 -0
  204. data/spec/java/tests_spec.rb +497 -0
  205. data/spec/packaging/archive_spec.rb +775 -0
  206. data/spec/packaging/artifact_namespace_spec.rb +743 -0
  207. data/spec/packaging/artifact_spec.rb +1074 -0
  208. data/spec/packaging/packaging_helper.rb +63 -0
  209. data/spec/packaging/packaging_spec.rb +719 -0
  210. data/spec/packaging/repository_array_spec.rb +109 -0
  211. data/spec/sandbox.rb +165 -0
  212. data/spec/scala/bdd_spec.rb +124 -0
  213. data/spec/scala/compiler_spec.rb +289 -0
  214. data/spec/scala/doc_spec.rb +88 -0
  215. data/spec/scala/scala.rb +38 -0
  216. data/spec/scala/tests_spec.rb +283 -0
  217. data/spec/spec_helpers.rb +369 -0
  218. data/spec/version_requirement_spec.rb +143 -0
  219. data/spec/xpath_matchers.rb +121 -0
  220. metadata +649 -0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,109 @@
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.4.5 (Feb. 20th, 2011)
50
+
51
+ * Added: BUILDR-555 Add support for the jaxb binding compiler (Mark Petrovic)
52
+ * Added: BUILDR-554 Add support for OSGi bundle packages by importing the
53
+ buildr_bnd plugin
54
+ * Added: BUILDR-125 Add support for <security-role> in application.xml of
55
+ EAR packaging (Mikael Amborn)
56
+ * Added: BUILDR-550 Add support for groovydoc
57
+ * Added: BUILDR-521: System tray notifications for Linux systems
58
+ (via libnotify/notify-send)
59
+ * Added: BUILDR-537 Shell tasks should use JAVA_OPTS by default
60
+ * Added: BUILDR-538 Shell tasks should support passing :java_args
61
+ * Added: BUILDR-544 Support ${groupId} in pom files (Chris Dean)
62
+ * Added: BUILDR-552 Projects may now be defined using project(:name) and a block
63
+ * Added: BUILDR-564 Add package(:scaladoc)
64
+ * Added: Automatically add "require buildr/{groovy,scala}" when generating
65
+ project if Groovy/Scala files are detected.
66
+ * Change: BUILDR-540 Upgrade to rspec 2.1.0
67
+ * Change: BUILDR-546 Upgrade to Rubyzip 0.9.4 (Michael Guymon)
68
+ * Change: BUILDR-556 Merge buildr-iidea extension back into buildr.
69
+ * Change: Upgrade default Scala compiler version to 2.8.1-final
70
+ * Change: Upgrade to ScalaCheck 1.8
71
+ * Change: Upgrade to ScalaTest 1.3
72
+ * Change: Upgrade to Specs 1.6.6
73
+ * Change: Upgrade to JRuby 1.5.6
74
+ * Fixed: BUILDR-542 Release task: SVN tagging fails if parent tag directory
75
+ does not exist yet (Gerolf Seitz)
76
+ * Fixed: BUILDR-543 POMs are installed and uploaded twice when using artifacts
77
+ with classifier
78
+ * Fixed: BUILDR-522 Send notifications when continuous compilation
79
+ succeeds/fails.
80
+ * Fixed: BUILDR-551 Continuous compilation not working for project trees
81
+ * Fixed: BUILDR-557 MD5 + SHA1 checksums are not Maven compliant (Tammo van Lessen)
82
+ * Change: Upgrade to Groovy 1.7.5
83
+ * Change: BUILDR-545 Add the ability to specify the description element in in
84
+ application.xml contained within an ear.
85
+ * Fixed: BUILDR-547 - Ensure ECJ compiler works when there is a space in the
86
+ path of dependencies.
87
+ * Fixed: BUILDR-558 Artifact uploads should show a progress bar (Tammo van Lessen)
88
+ * Fixed: BUILDR-560 show a meaning full error message when POM cannot be parsed
89
+ (Tammo van Lessen)
90
+ * Fixed: BUILDR-562 WAR package isn't updated if files under src/main/webapp
91
+ are updated
92
+ * Fixed: BUILDR-569 Buildr fails under JRuby 1.6.0.RC1 due to read-only $? variable
93
+ * Fixed: BUILDR-570 Buildr does not work with Rubygems 1.5.x
94
+ * Fixed: Scaladoc task would cause build to exit prematurely
95
+
96
+ See the "CHANGELOG":CHANGELOG for full details.
97
+
98
+ h2(#notices). Credits & Notices
99
+
100
+ !http://www.apache.org/images/asf-logo.gif(A project of the Apache Software Foundation)!:http://www.apache.org
101
+
102
+ 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.
103
+
104
+ "ColorCons":http://www.mouserunner.com/Spheres_ColoCons1_Free_Icons.html, copyright of Ken Saunders. "DejaVu fonts":http://dejavu.sourceforge.net, copyright of Bitstream, Inc.
105
+
106
+ Community member quotes from a thread on "Stack Overflow":http://stackoverflow.com/questions/1015525/why-use-buildr-instead-of-ant-or-maven/1055864.
107
+
108
+ Developed with !http://www.jetbrains.com/ruby/features/ruby_banners/ruby1/ruby120x30_white.gif(Developed with RubyMine)!:http://www.jetbrains.com/ruby/features?utm_source=RubyMineUser&utm_medium=Banner&utm_campaign=RubyMine
109
+
@@ -0,0 +1,284 @@
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
+ <br>
26
+
27
+ *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).
28
+
29
+ On *RedHat/Fedora* you can use yum to install Ruby and RubyGems, and then upgrade to the most recent version of RubyGems:
30
+
31
+ {% highlight sh %}
32
+ $ sudo yum install ruby rubygems ruby-devel gcc
33
+ $ sudo gem update --system
34
+ {% endhighlight %}
35
+
36
+ On *Ubuntu* you have to install several packages:
37
+
38
+ {% highlight sh %}
39
+ $ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
40
+ {% endhighlight %}
41
+
42
+ If using Ubuntu 9.10 or earlier, the Debian package for @rubygems@ will not allow you to install Buildr, so you need to install RubyGems from source:
43
+
44
+ {% highlight sh %}
45
+ $ wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
46
+ $ tar xzf rubygems-1.3.1.tgz
47
+ $ cd rubygems-1.3.1
48
+ $ sudo ruby setup.rb
49
+ $ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
50
+ {% endhighlight %}
51
+
52
+ Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution. Next, use Ruby Gem to install Buildr:
53
+
54
+ {% highlight sh %}
55
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
56
+ {% endhighlight %}
57
+
58
+ To upgrade to a new version or install a specific version:
59
+
60
+ {% highlight sh %}
61
+ $ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
62
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.4.3
63
+ {% endhighlight %}
64
+
65
+
66
+ h2(#osx). Installing on OS X
67
+
68
+ *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.
69
+
70
+ You need to have the Apple Development Tools installed. They are available on the Mac OSX installation CD.
71
+
72
+ p(note). Java Update 3 for Snow Leopard removes header files necessary to compile the native Ruby-Java Bridge (RJB) gem, so installing rjb gem may fail on OS X. The solution is to install Java for Mac OS X 10.6 Update 3 Developer Package from http://connect.apple.com before @gem install@.
73
+
74
+ *Using RVM?* If you're not using the built-in ruby on OS X (e.g., if you're using RVM), you'll need to force-install the platform-independent RJB:
75
+
76
+ {% highlight sh %}
77
+ $ gem install rjb -v 1.3.3 --platform ruby
78
+ {% endhighlight %}
79
+
80
+ The darwin pre-built binary seems to only work with the built-in ruby.
81
+
82
+ <br>
83
+
84
+ *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.
85
+
86
+ 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/.
87
+
88
+ We recommend you first upgrade to the latest version of Ruby gems:
89
+
90
+ {% highlight sh %}
91
+ $ sudo gem update --system
92
+ {% endhighlight %}
93
+
94
+ Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution:
95
+
96
+ {% highlight sh %}
97
+ $ export JAVA_HOME=/Library/Java/Home
98
+ {% endhighlight %}
99
+
100
+ To install Buildr:
101
+
102
+ {% highlight sh %}
103
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
104
+ {% endhighlight %}
105
+
106
+ To upgrade to a new version or install a specific version:
107
+
108
+ {% highlight sh %}
109
+ $ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
110
+ $ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
111
+ {% endhighlight %}
112
+
113
+ h2(#windows). Installing on Windows
114
+
115
+ *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@.
116
+
117
+ <br>
118
+
119
+ *In details:* We recommend you first upgrade to the latest version of Ruby gems:
120
+
121
+ {% highlight sh %}
122
+ > gem update --system
123
+ {% endhighlight %}
124
+
125
+ Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution. Next, use Ruby Gem to install Buildr:
126
+
127
+ {% highlight sh %}
128
+ > gem install buildr --platform mswin32
129
+ {% endhighlight %}
130
+
131
+ To upgrade to a new version or install a specific version:
132
+
133
+ {% highlight sh %}
134
+ > gem update buildr
135
+ > gem install buildr -v 1.3.4 --platform mswin32
136
+ {% endhighlight %}
137
+
138
+ h2(#jruby). Installing for JRuby
139
+
140
+ *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@.
141
+
142
+ <br>
143
+
144
+ *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/.
145
+
146
+ After uncompressing JRuby, update your @PATH@ to include both @java@ and @jruby@ executables.
147
+
148
+ For Linux and OS X:
149
+
150
+ {% highlight sh %}
151
+ $ export PATH=$PATH:[path to JRuby]/bin:$JAVA_HOME/bin
152
+ $ jruby -S gem install buildr
153
+ {% endhighlight %}
154
+
155
+ For Windows:
156
+
157
+ {% highlight sh %}
158
+ > set PATH=%PATH%;[path to JRuby]/bin;%JAVA_HOME%/bin
159
+ > jruby -S gem install buildr
160
+ {% endhighlight %}
161
+
162
+ To upgrade to a new version or install a specific version:
163
+
164
+ {% highlight sh %}
165
+ $ jruby -S gem update buildr
166
+ $ jruby -S gem install buildr -v 1.3.4
167
+ {% endhighlight %}
168
+
169
+
170
+ *Important: Running JRuby and Ruby side by side*
171
+
172
+ 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.
173
+
174
+ 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.
175
+
176
+ To work exclusively with JRuby, make sure it shows first on the path, for example, by setting @PATH=/opt/jruby/bin:$PATH@.
177
+
178
+ You can use JRuby and Ruby side by side, by running scripts with the @-S@ command line argument. For example:
179
+
180
+ {% highlight sh %}
181
+ $ # with Ruby
182
+ $ ruby -S gem install buildr
183
+ $ ruby -S buildr
184
+ $ # with JRuby
185
+ $ jruby -S gem install buildr
186
+ $ jruby -S buildr
187
+ {% endhighlight %}
188
+
189
+ 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.
190
+
191
+ h2. Using multiple versions of Buildr
192
+
193
+ Rubygems makes it possible to install several versions of Buildr side-by-side on the same system. If you want to run a specific version, you can do so by adding the version number between underscores ('_') as the first command-line parameter. For example,
194
+
195
+ {% highlight sh %}
196
+ $ buildr _1.3.4_ clean # runs Buildr v1.3.4
197
+
198
+ $ buildr _1.4.4_ clean # runs Buildr v1.4.4
199
+ {% endhighlight %}
200
+
201
+ p(note). There are two `buildr` executables installed by Rubygems. One script serves to select the specified (or default) version of Buildr and is typically found under `/usr/bin/buildr` or `/var/lib/gems/1.8/bin/buildr`. The exact location will vary depending on your system. The other script is the Buildr bootstrap per se and can be found under the specific version of Buildr, e.g, `/var/lib/gems/1.8/gems/buildr-1.4.0/bin/buildr`. The first script should be on your `PATH`. The second script should not be called directly and should not be on your `PATH`.
202
+
203
+ h2(#running). Running Buildr
204
+
205
+ 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@.
206
+
207
+ 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@.
208
+
209
+ You use Buildr by running the @buildr@ command:
210
+
211
+ {% highlight sh %}
212
+ $ buildr [options] [tasks] [name=value]
213
+ {% endhighlight %}
214
+
215
+ There are several options you can use, for a full list of options type @buildr --help@:
216
+
217
+ |_. Option |_. Usage |
218
+ | @-f/--buildfile [file]@ | Specify the buildfile. |
219
+ | @-e/--environment [name]@ | Environment name (e.g. development, test, production). |
220
+ | @-h/--help@ | Display this help message. |
221
+ | @-n/--nosearch@ | Do not search parent directories for the buildfile. |
222
+ | @-q/--quiet@ | Do not log messages to standard output. |
223
+ | @-r/--require [file]@ | Require MODULE before executing buildfile. |
224
+ | @-t/--trace@ | Turn on invoke/execute tracing, enable full backtrace. |
225
+ | @-v/--version@ | Display the program version. |
226
+ | @-P/--prereqs@ | Display tasks and dependencies, then exit. |
227
+
228
+ You can tell Buildr to run specific tasks and the order to run them. For example:
229
+
230
+ {% highlight sh %}
231
+ # Clean and rebuild
232
+ buildr clean build
233
+ # Package and install
234
+ buildr install
235
+ {% endhighlight %}
236
+
237
+ 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@.
238
+
239
+ 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.
240
+
241
+ For example:
242
+
243
+ {% highlight sh %}
244
+ $ export JAVA_OPTS='-Xms1g -Xmx1g'
245
+ $ buildr TEST=no
246
+ {% endhighlight %}
247
+
248
+
249
+ h2(#help). Help Tasks
250
+
251
+ 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@.
252
+
253
+ To start with, type:
254
+
255
+ {% highlight sh %}
256
+ $ buildr help
257
+ {% endhighlight %}
258
+
259
+ You can list the name and description of all your projects using the @help:projects@ task. For example:
260
+
261
+ {% highlight sh %}
262
+ $ buildr help:projects
263
+ killer-app # Code. Build. ??? Profit!
264
+ killer-app:teh-api # Abstract classes and interfaces
265
+ killer-app:teh-impl # All those implementation details
266
+ killer-app:la-web # What our users see
267
+ {% endhighlight %}
268
+
269
+ 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.
270
+
271
+ So next let's talk about "projects":projects.html.
272
+
273
+
274
+ h2(#more). Learning More
275
+
276
+ *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_.
277
+
278
+ 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/.
279
+
280
+ *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.
281
+
282
+ *AntWrap* Buildr uses AntWrap, for configuring and running Ant tasks. You can learn more from the "Antwrap documentation":http://antwrap.rubyforge.org/.
283
+
284
+ *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.
@@ -0,0 +1,599 @@
1
+ ---
2
+ layout: default
3
+ title: Languages
4
+ ---
5
+
6
+
7
+ h2(#java). Java
8
+
9
+
10
+ h3. Compiling Java
11
+
12
+ The Java compiler looks for source files in the project's @src/main/java@ directory, and defaults to compiling them into the @target/classes@ directory. It looks for test cases in the project's @src/test/java@ and defaults to compile them into the @target/test/classes@ directory.
13
+
14
+ If you point the @compile@ task at any other source directory, it will use the Java compiler if any of these directories contains files with the extension @.java@.
15
+
16
+ When using the Java compiler, if you don't specify the packaging type, it defaults to JAR. If you don't specify the test framework, it defaults to JUnit.
17
+
18
+ The Java compiler supports the following options:
19
+
20
+ |_. Option |_. Usage |
21
+ | @:debug@ | Generates bytecode with debugging information. You can also override this by setting the environment variable @debug@ to @off@. |
22
+ | @:deprecation@ | If true, shows deprecation messages. False by default. |
23
+ | @:lint@ | Defaults to false. Set this option to true to use all lint options, or specify a specific lint option (e.g. @:lint=>'cast'@). |
24
+ | @:other@ | Array of options passed to the compiler (e.g. @:other=>'-implicit:none'@). |
25
+ | @:source@ | Source code compatibility (e.g. '1.5'). |
26
+ | @:target@ | Bytecode compatibility (e.g. '1.4'). |
27
+ | @:warnings@ | Issue warnings when compiling. True when running in verbose mode. |
28
+
29
+
30
+ h3. Testing with Java
31
+
32
+ h4. JUnit
33
+
34
+ The default test framework for Java projects is "JUnit 4":http://www.junit.org.
35
+
36
+ When you use JUnit, the dependencies includes JUnit and "JMock":http://www.jmock.org, and Buildr picks up all test classes from the project by looking for classes that either subclass @junit.framework.TestCase@, include methods annotated with @org.junit.Test@, or test suites annotated with @org.org.junit.runner.RunWith@.
37
+
38
+ The JUnit test framework supports the following options:
39
+
40
+ |_. Option |_. Value |
41
+ | @:fork@ | VM forking, defaults to true. |
42
+ | @:clonevm@ | If true clone the VM each time it is forked. |
43
+ | @:properties@ | Hash of system properties available to the test case. |
44
+ | @:environment@ | Hash of environment variables available to the test case. |
45
+ | @:java_args@ | Arguments passed as is to the JVM. |
46
+
47
+ For example, to pass properties to the test case:
48
+
49
+ {% highlight ruby %}
50
+ test.using :properties=>{ :currency=>'USD' }
51
+ {% endhighlight %}
52
+
53
+ There are benefits to running test cases in separate VMs. The default forking mode is @:once@, and you can change it by setting the @:fork@ option.
54
+
55
+ |_. :fork=> |_. Behavior |
56
+ | @:once@ | Create one VM to run all test classes in the project, separate VMs for each project. |
57
+ | @:each@ | Create one VM for each test case class. Slow but provides the best isolation between test classes. |
58
+ | @false@ | Without forking, Buildr runs all test cases in a single VM. This option runs fastest, but at the risk of running out of memory and causing test cases to interfere with each other. |
59
+
60
+ You can see your tests running in the console, and if any tests fail, Buildr will show a list of the failed test classes. In addition, JUnit produces text and XML report files in the project's @reports/junit@ directory. You can use that to get around too-much-stuff-in-my-console, or when using an automated test system.
61
+
62
+ In addition, you can get a consolidated XML or HTML report by running the @junit:report@ task. For example:
63
+
64
+ {% highlight sh %}
65
+ $ buildr test junit:report test=all
66
+ $ firefox report/junit/html/index.html
67
+ {% endhighlight %}
68
+
69
+ The @junit:report@ task generates a report from all tests run so far. If you run tests in a couple of projects, it will generate a report only for these two projects. The example above runs tests in all the projects before generating the reports.
70
+
71
+ You can use the @build.yaml@ settings file to specify a particular version of JUnit or JMock. For example, to force your build to use JUnit version 4.4 and JMock 2.0:
72
+
73
+ {% highlight yaml %}
74
+ junit: 4.4
75
+ jmock: 2.0
76
+ {% endhighlight %}
77
+
78
+
79
+ h4. TestNG
80
+
81
+ You can use "TestNG":http://testng.org instead of JUnit. To select TestNG as the test framework, add this to your project:
82
+
83
+ {% highlight ruby %}
84
+ test.using :testng
85
+ {% endhighlight %}
86
+
87
+ Like all other options you can set with @test.using@, it affects the projects and all its sub-projects, so you only need to do this once at the top-most project to use TestNG throughout. You can also mix TestNG and JUnit by setting different projects to use different frameworks, but you can't mix both frameworks in the same project. (And yes, @test.using :junit@ will switch a project back to using JUnit)
88
+
89
+ TestNG works much like JUnit, it gets included in the dependency list along with JMock, Buildr picks test classes that contain methods annotated with @org.testng.annotations.Test@, and generates test reports in the @reports/testng@ directory. At the moment we don't have consolidated HTML reports for TestNG.
90
+
91
+ The TestNG test framework supports the following options:
92
+
93
+ |_. Option |_. Value |
94
+ | @:properties@ | Hash of system properties available to the test case. |
95
+ | @:java_args@ | Arguments passed as is to the JVM. |
96
+
97
+ You can use the @build.yaml@ settings file to specify a particular version of TestNG, for example, to force your build to use TestNG 5.7:
98
+
99
+ {% highlight yaml %}
100
+ testng: 5.7
101
+ {% endhighlight %}
102
+
103
+
104
+ h4. JBehave
105
+
106
+ "JBehave":http://jbehave.org/ is a pure Java BDD framework, stories and behaviour specifications are written in the Java language.
107
+
108
+ To use JBehave in your project you can select it with @test.using :jbehave@.
109
+
110
+ This framework will search for the following patterns under your project:
111
+
112
+ {% highlight text %}
113
+ src/spec/java/**/*Behaviour.java
114
+ {% endhighlight %}
115
+
116
+ Supports the following options:
117
+
118
+ |_. Option |_. Value |
119
+ | @:properties@ | Hash of system properties available to the test case. |
120
+ | @:java_args@ | Arguments passed as is to the JVM. |
121
+
122
+ You can use the @build.yaml@ settings file to specify a particular version of JBehave, for example, to force your build to use JBehave 1.0.1:
123
+
124
+ {% highlight yaml %}
125
+ jbehave: 1.0.1
126
+ {% endhighlight %}
127
+
128
+
129
+ h3. Documentation
130
+
131
+ Buildr offers support for using JavaDoc to generate documentation from any Java sources in a project. This is done using the @doc@ task:
132
+
133
+ {% highlight sh %}
134
+ $ buildr doc
135
+ {% endhighlight %}
136
+
137
+ This will use the same @.java@ sources used by the @compile@ task to produce JavaDoc results in the @target/doc/@ directory. By default, these sources are chosen only from the current project. However, it is possible to override this and generate documentation from the sources in a sub-project (potentially more than one):
138
+
139
+ {% highlight ruby %}
140
+ define 'foo' do
141
+ # ...
142
+
143
+ doc.from projects('foo:bar', 'foo')
144
+
145
+ define 'bar' do
146
+ # ...
147
+ end
148
+ end
149
+ {% endhighlight %}
150
+
151
+ With this configuration, the @doc@ task will use sources from both @foo:bar@ and
152
+ @foo@.
153
+
154
+ The @doc@ task supports any option that the @javadoc@ command does (e.g. @-windowtitle@). To pass an option to the JavaDoc generator, simply specify it using the @doc@ method:
155
+
156
+ {% highlight ruby %}
157
+ define 'foo' do
158
+ # ...
159
+
160
+ doc :windowtitle => 'Abandon All Hope, Ye Who Enter Here', :private => true
161
+ end
162
+ {% endhighlight %}
163
+
164
+
165
+ h2(#scala). Scala
166
+
167
+ Before using Scala, you must first @require@ the Scala compiler:
168
+
169
+ {% highlight ruby %}
170
+ require 'buildr/scala'
171
+ {% endhighlight %}
172
+
173
+ By default, Buildr will attempt to use the latest stable release of Scala, which is currently Scala 2.8.0 as of July 2010. Of course you can configure a specific version of Scala for your project by adding the following entry in @build.yaml@:
174
+
175
+ {% highlight yaml %}
176
+ scala.version: 2.8.0.Beta1 # Pick your version
177
+ {% endhighlight %}
178
+
179
+ Or, you can do the same programmatically:
180
+
181
+ {% highlight yaml %}
182
+ # Must be placed before require 'buildr/scala'
183
+ Buildr.settings.build['scala.version'] = "2.8.0.Beta1"
184
+ {% endhighlight %}
185
+
186
+ You may also determine the version in use by querying the @Scala.version@ attribute:
187
+
188
+ {% highlight ruby %}
189
+ Scala.version # => '2.8.0'
190
+ {% endhighlight %}
191
+
192
+ Regardless of how the Scala version is determined, if you have the same Scala version installed on your system and the SCALA_HOME environment variable points to it, then your local installation will be used. Otherwise, Buildr will download it from the "Scala Tools repository":http://scala-tools.org/ which is automatically enlisted when you @require@ Scala. The only drawback if you don't have a local installation is the FSC compiler won't be available.
193
+
194
+ p(tip). For Mac users, if you have installed Scala via "MacPorts":http://www.macports.org/ Buildr will look in the
195
+ @/opt/local/share/scala/@ directory if you have not set @SCALA_HOME@.
196
+
197
+
198
+ h3. Compiling Scala
199
+
200
+ The Scala compiler looks for source files in the project's @src/main/scala@ directory, and defaults to compiling them into the @target/classes@ directory. It looks for test cases in the project's @src/test/scala@ and defaults to compile them into the @target/test/classes@ directory.
201
+
202
+ Any Java source files found in the @src/main/java@ directory will be compiled using the Scala/Java joint compiler into the @target/classes@ directory. Both the Java and the Scala sources are compiled with an inclusive classpath, meaning that you may have a Java class which depends upon a Scala class which depends upon a Java class, all within the same project. The Java sources will be compiled with the same dependencies as the Scala sources with the addition of the @scala-library.jar@ file as required for Scala interop.
203
+
204
+ Note that you cannot use the Groovy *and* the Scala joint compilers in the same project. If both are required, the Groovy joint compiler will take precedence.
205
+ +
206
+ If you point the @compile@ task at any other source directory, it will use the Scala compiler if any of these directories contains files with the extension @.scala@. The joint compilation of Java sources may only be pointed at an alternative directory using the feature to redefine the @_(:src, :main, :java)@ path.
207
+
208
+ When using the Scala compiler, if you don't specify the packaging type, it defaults to JAR.
209
+
210
+ The Scala compiler supports the following options:
211
+
212
+ |_. Option |_. Usage |
213
+ | @:debug@ | Generates bytecode with debugging information. You can also override this by setting the environment variable @debug@ to @off@. |
214
+ | @:deprecation@ | If true, shows deprecation messages. False by default. |
215
+ | @:optimise@ | Generates faster bytecode by applying optimisations to the program. |
216
+ | @:other@ | Array of options passed to the compiler (e.g. @:other=>'-Xprint-types'@). |
217
+ | @:make@ | Make strategy to be used by the compiler (e.g. @:make=>'transitive'@). *Scala 2.8 only* |
218
+ | @:target@ | Bytecode compatibility (e.g. '1.4'). |
219
+ | @:warnings@ | Issue warnings when compiling. True when running in verbose mode. |
220
+ | @:javac@ | A hash of options passed to the @javac@ compiler verbatim. |
221
+
222
+ h4. Fast Scala Compiler
223
+
224
+ You may use @fsc@, the Fast Scala Compiler, which submits compilation jobs to a compilation daemon, by setting the environment variable @USE_FSC@ to @yes@. Note that @fsc@ _may_ cache class libraries -- don't forget to run @fsc -reset@ if you upgrade a library.
225
+
226
+ h4. Rebuild detection
227
+
228
+ The Scala 2.7 compiler task assumes that each @.scala@ source file generates a corresponding @.class@ file under @target/classes@ (or @target/test/classses@ for tests). The source may generate more @.class@ files if it contains more than one class, object, trait or for anonymous functions and closures.
229
+
230
+ For example, @src/main/scala/com/example/MyClass.scala@ should generate at least @target/classes/com/example/MyClass.class@. If that it not the case, Buildr will always recompile your sources because it will assume this is a new source file that has never been compiled before.
231
+
232
+ Fortunately, Scala 2.8 provides a substantially better interface for implementing change detection. Whenever you use Scala 2.8 (see below), Buildr will auto-detect the version and enable this feature dynamically. After the @compile@ task runs, the relevant target directory will contain a @.scala-deps@ file, generated by the Scala compiler. The manner in which this file is used can be configured using the @:make@ compiler option. The following values are available:
233
+
234
+ * @:all@ - Disables compiler-level change detection
235
+ * @:changed@ - Only build changed files without considering file dependencies
236
+ * @:immediate@ - *unknown*
237
+ * @:transitive@ - Build changed files as well as their transitive file dependencies
238
+ * @:transitivenocp@ - Build changed files as well as their transitive file dependencies (*default*)
239
+
240
+ Please note that there are limits to compiler-level change detection. Most notably, dependencies cannot be tracked across separate compilation targets. This would cause problems in the case where an API has been changed in a main source file. The test suite for the project will *not* be detected as requiring recompilation, potentially resulting in unexpected runtime exceptions. When in doubt, run @clean@ to remove all dependency information. In extreme cases, it is possible to completely disable compiler-level change detection by adding the following statement to your project definition:
241
+
242
+ {% highlight ruby %}
243
+ compile.using :make => :all
244
+ {% endhighlight %}
245
+
246
+ Effectively, this is telling the Scala compiler to ignore the information it has built up regarding source file dependencies. When in this mode, only Buildr's change detection semantics remain in play (as described above).
247
+
248
+ To avoid unusual behavior, compiler-level change detection is disabled whenever the joint Scala-Java compiler is used. Thus, any @.java@ files in a project handled by the Scala compiler will cause the @:make@ option to be ignored and revert to the exclusive use of Buildr's change detection mechanism (as described above).
249
+
250
+ h4. Scala 2.8
251
+
252
+ As of version 1.4, Buildr has *non-default* support for Scala 2.8. If your @SCALA_HOME@ environment variable is pointing to an installation of Scala 2.8, then Buildr will use that compiler and enable 2.8-specific features.
253
+
254
+ As Scala 2.8 is currently pre-release, it is often desirable to maintain an installation of Scala 2.7 concurrently with Scala 2.8, defaulting to the former with the option to select the latter on a project-by-project basis. This is most easily accomplished by setting @SCALA_HOME@ to point to the Scala 2.7 installation and @SCALA28_HOME@ to point to the Scala 2.8 installation. With this configuration in place, Scala 2.8 can be selected for a specific project by dynamically reassigning @SCALA_HOME@ at the top of the buildfile (*before* @require 'buildr/scala'@):
255
+
256
+ {% highlight ruby %}
257
+ ENV['SCALA_HOME'] = ENV['SCALA28_HOME']
258
+
259
+ require 'buildr/scala'
260
+ ...
261
+ {% endhighlight %}
262
+
263
+ h3. Testing with Scala
264
+
265
+ Buildr supports two main Scala testing frameworks: "ScalaTest":http://www.artima.com/scalatest and "Specs":http://code.google.com/p/specs/. "ScalaCheck":http://code.google.com/p/scalacheck/ is also supported within the confines of either of these two frameworks. Thus, your Specs may use ScalaCheck properties, as may your ScalaTest suites.
266
+
267
+ {% highlight ruby %}
268
+ test.using(:scalatest)
269
+ {% endhighlight %}
270
+
271
+ h4. ScalaTest
272
+
273
+ ScalaTest support is activated automatically when there are any @.scala@ source files contained in the @src/test/scala@ directory. If you are not using this directory convention, you may force the test framework by using the @test.using :scalatest@ directive.
274
+
275
+ Buildr automatically detects and runs tests that extend the @org.scalatest.Suite@ interface.
276
+
277
+ A very simplistic test class might look like,
278
+
279
+ {% highlight scala %}
280
+ class MySuite extends org.scalatest.FunSuite {
281
+ test("addition") {
282
+ val sum = 1 + 1
283
+ assert(sum === 2)
284
+ }
285
+ }
286
+ {% endhighlight %}
287
+
288
+ You can also pass properties to your tests by doing @test.using :properties => { 'name'=>'value' }@, and by overriding the @Suite.runTests@ method in a manner similar to:
289
+
290
+ {% highlight scala %}
291
+ import org.scalatest._
292
+
293
+ class PropertyTestSuite extends FunSuite {
294
+ var properties = Map[String, Any]()
295
+
296
+ test("testProperty") {
297
+ assert(properties("name") === "value")
298
+ }
299
+
300
+ protected override def runTests(testName: Option[String],
301
+ reporter: Reporter, stopper: Stopper, includes: Set[String],
302
+ excludes: Set[String], properties: Map[String, Any])
303
+ {
304
+ this.properties = properties;
305
+ super.runTests(testName, reporter, stopper,
306
+ includes, excludes, properties)
307
+ }
308
+ }
309
+ {% endhighlight %}
310
+
311
+ h4. Specs
312
+
313
+ Specs is automatically selected whenever there are @.scala@ source files under the @src/spec/scala@ directory. It is also possible to force selection of the test framework by using the @test.using :specs@ directive. This can sometimes be useful when Scala sources may be found in *both* @src/test/scala@ and @src/spec/scala@. Normally in such cases, ScalaTest will have selection precedence, meaning that in case of a conflict between it and Specs, ScalaTest will be chosen.
314
+
315
+ Any objects which extend the @org.specs.Specification@ superclass will be automatically detected and run. Note that any *classes* which extend @Specification@ will also be invoked. As such classes will not have a @main@ method, such an invocation will raise an error.
316
+
317
+ A simple specification might look like this:
318
+
319
+ {% highlight scala %}
320
+ import org.specs._
321
+ import org.specs.runner._
322
+
323
+ object StringSpecs extends Specification {
324
+ "empty string" should {
325
+ "have a zero length" in {
326
+ "".length mustBe 0
327
+ }
328
+ }
329
+ }
330
+ {% endhighlight %}
331
+
332
+ ScalaCheck is automatically added to the classpath when Specs is used. However, JMock, Mockito, CGlib and similar are _not_. This is to avoid downloading extraneous artifacts which are only used by a small percentage of specifications. To use Specs with Mockito (or any other library) in a Buildr project, simply add the appropriate dependencies to @test.with@:
333
+
334
+ {% highlight ruby %}
335
+ MOCKITO = 'org.mockito:mockito-all:jar:1.7'
336
+ CGLIB = 'cglib:cglib:jar:2.1_3'
337
+ ASM = 'asm:asm:jar:1.5.3'
338
+ OBJENESIS = 'org.objenesis:objenesis:jar:1.1'
339
+
340
+ define 'killer-app' do
341
+ ...
342
+
343
+ test.with MOCKITO, CGLIB, ASM, OBJENESIS
344
+ end
345
+ {% endhighlight %}
346
+
347
+ The dependencies for Specs's optional features are defined "here":http://code.google.com/p/specs/wiki/RunningSpecs#Dependencies.
348
+
349
+ h4. ScalaCheck
350
+
351
+ You may use ScalaCheck inside ScalaTest- and Specs-inherited classes. Here is an example illustrating checks inside a ScalaTest suite,
352
+
353
+ {% highlight scala %}
354
+ import org.scalatest.prop.PropSuite
355
+ import org.scalacheck.Arbitrary._
356
+ import org.scalacheck.Prop._
357
+
358
+ class MySuite extends PropSuite {
359
+
360
+ test("list concatenation") {
361
+ val x = List(1, 2, 3)
362
+ val y = List(4, 5, 6)
363
+ assert(x ::: y === List(1, 2, 3, 4, 5, 6))
364
+ check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size)
365
+ }
366
+
367
+ test(
368
+ "list concatenation using a test method",
369
+ (a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size
370
+ )
371
+ }
372
+ {% endhighlight %}
373
+
374
+
375
+ h3. Documentation
376
+
377
+ Buildr offers support for using ScalaDoc or VScalaDoc to generate documentation from any Scala sources in a project. This is done using the @doc@ task:
378
+
379
+ {% highlight sh %}
380
+ $ buildr doc
381
+ {% endhighlight %}
382
+
383
+ This will use the same @.scala@ sources used by the @compile@ task to produce ScalaDoc results in the @target/doc/@ directory. By default, these sources are chosen only from the current project. However, it is possible to override this and generate documentation from the sources in a sub-project (potentially more than one):
384
+
385
+ {% highlight ruby %}
386
+ define 'foo' do
387
+ # ...
388
+
389
+ doc.from projects('foo:bar', 'foo')
390
+
391
+ define 'bar' do
392
+ # ...
393
+ end
394
+ end
395
+ {% endhighlight %}
396
+
397
+ With this configuration, the @doc@ task will use sources from both @foo:bar@ and
398
+ @foo@.
399
+
400
+ The @doc@ task supports any option that the @scaladoc@ command does (e.g. @-windowtitle@). To pass an option to the ScalaDoc (or VScalaDoc) generator, simply specify it using the @doc@ method:
401
+
402
+ {% highlight ruby %}
403
+ define 'foo' do
404
+ # ...
405
+
406
+ doc :windowtitle => 'Abandon All Hope, Ye Who Enter Here', :private => true
407
+ end
408
+ {% endhighlight %}
409
+
410
+ By default, the @doc@ task will use the ScalaDoc generator on Scala projects. To select the VScalaDoc generator, you must use the @doc.using@ invocation:
411
+
412
+ {% highlight ruby %}
413
+ define 'foo' do
414
+ doc.using :vscaladoc
415
+ end
416
+ {% endhighlight %}
417
+
418
+ The @doc@ task is *not* joint-compilation aware. Thus, it will only generate ScalaDoc for mixed-source projects, it will not attempt to generate both JavaDoc and ScalaDoc.
419
+
420
+
421
+ h2(#groovy). Groovy
422
+
423
+ h3. Compiling Groovy
424
+
425
+ Before using the Groovy compiler, you must first require it on your buildfile:
426
+
427
+ {% highlight ruby %}
428
+ require 'buildr/java/groovyc'
429
+ {% endhighlight %}
430
+
431
+ Once loaded, the groovyc compiler will be automatically selected if any .groovy source files are found under @src/main/groovy@ directory, compiling them by default into the @target/classes@ directory.
432
+
433
+ If the project has java sources in @src/main/java@ they will get compiled using the groovyc joint compiler.
434
+
435
+ Sources found in @src/test/groovy@ are compiled into the @target/test/classes@.
436
+
437
+ If you don't specify the packaging type, it defaults to JAR.
438
+
439
+ The Groovy compiler supports the following options:
440
+
441
+ |_. Option |_. Usage |
442
+ | @encoding@ | Encoding of source files. |
443
+ | @verbose@ | Asks the compiler for verbose output, true when running in verbose mode. |
444
+ | @fork@ | Whether to execute groovyc using a spawned instance of the JVM. Defaults to no. |
445
+ | @memoryInitialSize@ | The initial size of the memory for the underlying VM, if using fork mode, ignored otherwise. Defaults to the standard VM memory setting. (Examples: @83886080@, @81920k@, or @80m@) |
446
+ | @memoryMaximumSize@ | The maximum size of the memory for the underlying VM, if using fork mode, ignored otherwise. Defaults to the standard VM memory setting. (Examples: @83886080@, @81920k@, or @80m@) |
447
+ | @listfiles@ | Indicates whether the source files to be compiled will be listed. Defaults to no. |
448
+ | @stacktrace@ | If true each compile error message will contain a stacktrace. |
449
+ | @warnings@ | Issue warnings when compiling. True when running in verbose mode. |
450
+ | @debug@ | Generates bytecode with debugging information. Set from the debug environment variable/global option. |
451
+ | @deprecation@ | If true, shows deprecation messages. False by default. |
452
+ | @optimise@ | Generates faster bytecode by applying optimisations to the program. |
453
+ | @source@ | Source code compatibility. |
454
+ | @target@ | Bytecode compatibility. |
455
+ | @javac@ | Hash of options passed to the ant javac task. |
456
+
457
+
458
+ h3. Testing with Groovy
459
+
460
+ h4. EasyB
461
+
462
+ "EasyB":http://www.easyb.org/ is a BDD framework using "Groovy":http://groovy.codehaus.org/.
463
+
464
+ Specifications are written in the Groovy language, of course you get seamless Java integration as with all things groovy.
465
+
466
+ To use this framework in your project you can select it with @test.using :easyb@.
467
+
468
+ This framework will search for the following patterns under your project:
469
+
470
+ {% highlight text %}
471
+ src/spec/groovy/**/*Behavior.groovy
472
+ src/spec/groovy/**/*Story.groovy
473
+ {% endhighlight %}
474
+
475
+ Supports the following options:
476
+
477
+ |_. Option |_. Value |
478
+ | @:properties@ | Hash of system properties available to the test case. |
479
+ | @:java_args@ | Arguments passed as is to the JVM. |
480
+ | @:format@ | Report format, either @:txt@ or @:xml@ |
481
+
482
+
483
+ h3. Documentation
484
+
485
+ Buildr offers support for using GroovyDoc to generate documentation from any Groovy sources in a project. This is done using the @doc@ task:
486
+
487
+ {% highlight sh %}
488
+ $ buildr doc
489
+ {% endhighlight %}
490
+
491
+ This will use the same @.groovy@ sources used by the @compile@ task to produce GroovyDoc results in the @target/doc/@ directory. By default, these sources are chosen only from the current project. However, it is possible to override this and generate documentation from the sources in a sub-project (potentially more than one):
492
+
493
+ {% highlight ruby %}
494
+ define 'foo' do
495
+ # ...
496
+
497
+ doc.from projects('foo:bar', 'foo')
498
+
499
+ define 'bar' do
500
+ # ...
501
+ end
502
+ end
503
+ {% endhighlight %}
504
+
505
+ With this configuration, the @doc@ task will use sources from both @foo:bar@ and
506
+ @foo@.
507
+
508
+ The @doc@ task supports any option that the @groovydoc@ command does (e.g. @-windowtitle@). To pass an option to the GroovyDoc generator, simply specify it using the @doc@ method:
509
+
510
+ {% highlight ruby %}
511
+ define 'foo' do
512
+ # ...
513
+
514
+ doc :windowtitle => 'Abandon All Hope, Ye Who Enter Here', :private => true
515
+ end
516
+ {% endhighlight %}
517
+
518
+ The @doc@ task is *not* joint-compilation aware. Thus, it will only generate GroovyDoc for mixed-source projects, it will not attempt to generate both JavaDoc and GroovyDoc.
519
+
520
+
521
+ h2(#ruby). Ruby
522
+
523
+ h3. Testing with Ruby
524
+
525
+ Buildr provides integration with some ruby testing frameworks, allowing you to test your Java code with state of the art tools.
526
+
527
+ Testing code is written in "Ruby":http://www.ruby-lang.org/en/ language, and is run by using "JRuby":http://jruby.codehaus.org/. That means you have access to all your Java classes and any Java or Ruby tool out there.
528
+
529
+ Because of the use of JRuby, you will notice that running ruby tests is faster when running Buildr on JRuby, as in this case there's no need to run another JVM.
530
+
531
+ p(tip). When not running on JRuby, Buildr will use the @JRUBY_HOME@ environment variable to find the JRuby installation directory. If no @JRUBY_HOME@ is set or it points to an empty directory, Buildr will prompt you to either install JRuby manually or let it extract it for you.
532
+
533
+ You can use the @build.yaml@ settings file to specify a particular version of JRuby (defaults to @1.4.0@ as of Buildr 1.3.5). For example:
534
+
535
+ {% highlight yaml %}
536
+ jruby: 1.3.1
537
+ {% endhighlight %}
538
+
539
+ h4. RSpec
540
+
541
+ "RSpec":http://rspec.info/ is the de-facto BDD framework for ruby. It's the framework used to test Buildr itself.
542
+
543
+ To use this framework in your project you can select it with @test.using :rspec@.
544
+
545
+ This framework will search for the following patterns under your project:
546
+
547
+ {% highlight text %}
548
+ src/spec/ruby/**/*_spec.rb
549
+ {% endhighlight %}
550
+
551
+ Supports the following options:
552
+
553
+ |_. Option |_. Value |
554
+ | @:gems@ | Hash of gems needed before running the tests. Keys are gem names, values are the required gem version. An example use of this option would be to require the ci_reporter gem to generate xml reports |
555
+ | @:requires@ | Array of ruby files to require before running the specs |
556
+ | @:format@ | Array of valid RSpec @--format@ option values. Defaults to html report on the @reports@ directory and text progress |
557
+ | @:output@ | File path to output dump. @false@ to supress output |
558
+ | @:fork@ | Run the tests on a new java vm. (enabled unless running on JRuby) |
559
+ | @:properties@ | Hash of system properties available to the test case. |
560
+ | @:java_args@ | Arguments passed as is to the JVM. (only when fork is enabled) |
561
+
562
+ h4. JtestR
563
+
564
+ "JtestR":http://jtestr.codehaus.org is a tool that makes it easier to test Java code with state of the art Ruby tools. Using JtestR you can describe your application behaviour using many testing frameworks at the same time.
565
+
566
+ To use this framework in your project you can select it with @test.using :jtestr@.
567
+
568
+ You can use the @build.yaml@ settings file to specify a particular version of JtestR (defaults to @0.3.1@). For example:
569
+
570
+ {% highlight yaml %}
571
+ jtestr: 0.3.1
572
+ {% endhighlight %}
573
+
574
+ To customize TestNG/JUnit versions refer to their respective section.
575
+
576
+ When selected, Buildr will configure JtestR to use your project/testing classpath and will search for the following test patterns for each framework supported by JtestR:
577
+
578
+ |_. Framework |_. Patterns |
579
+ | "RSpec":http://rspec.info | Files in @src/spec/ruby@ ending with @*_spec.rb@ or @*_story.rb@ |
580
+ | "TestUnit":http://ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html | Files in @src/spec/ruby@ ending with @*_test.rb@, @*Test.rb@ |
581
+ | "Expectations":http://expectations.rubyforge.org/ | Files in @src/spec/ruby@ ending with @*_expect.rb@ |
582
+ | "JUnit":http://www.junit.org | Classes from @src/test/java@ that either subclass @junit.framework.TestCase@, include methods annotated with @org.junit.Test@, or test suites annotated with @org.org.junit.runner.RunWith@. |
583
+ | "TestNG":http://testng.org | Classes from @src/test/java@ annotated with @org.testng.annotations.Test@ |
584
+
585
+ If you create a @src/spec/ruby/jtestr_config.rb@ file, it will be loaded by JtestR, just after being configured by Buildr, this way you can configure as described on "JtestR guide":http://jtestr.codehaus.org/Configuration.
586
+
587
+ p(tip). If you have a @jtestr_config.rb@ file, don't set @JtestR::result_handler@. Buildr uses its (@RSpecResultHandler@) so that it can know which tests succeeded/failed, this handler is capable of using RSpec formatter classes, so that you can obtain an html report or use a custom rspec formatter with @JtestR@. See the @format@ option.
588
+
589
+ Supports the following options:
590
+
591
+ |_. Option |_. Value |
592
+ | @:config@ | The JtestR config file to be loaded after being configured by Buildr. Defaults to @src/spec/ruby/jtestr_config.rb@. |
593
+ | @:gems@ | Hash of gems needed before running the tests. Keys are gem names, values are the required gem version. An example use of this option would be to require the ci_reporter gem to generate xml reports |
594
+ | @:requires@ | Array of ruby files to require before running the specs |
595
+ | @:format@ | Array of valid RSpec @--format@ option values. Defaults to html report on the @reports@ directory and text progress |
596
+ | @:output@ | File path to output dump. @false@ to supress output |
597
+ | @:fork@ | Run the tests on a new java vm. (enabled unless running on JRuby) |
598
+ | @:properties@ | Hash of system properties available to the test case. (only when fork is enabled) |
599
+ | @:java_args@ | Arguments passed as is to the JVM. (only when fork is enabled) |