mguymon-buildr 1.4.5-java

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 +600 -0
data/doc/_config.yml ADDED
@@ -0,0 +1 @@
1
+ pygments: true
@@ -0,0 +1,90 @@
1
+ <html>
2
+ <head>
3
+ <meta content='text/html;charset=UTF-8' http-equiv='Content-Type'>
4
+ <title>buildr &mdash; {{ page.title }}</title>
5
+ <style type='text/css'>
6
+ @import 'css/default.css';
7
+ @import 'css/syntax.css';
8
+ </style>
9
+ <style media='print' type='text/css'>
10
+ @import 'css/print.css';
11
+ </style>
12
+ <meta content='Official Buildr documentation from the people in the know' name='subject'>
13
+ <link href='images/favicon.png' rel='shortcut icon'>
14
+ </head>
15
+ <body>
16
+ <div id='wrap'>
17
+ <div id='header'>
18
+ <a href='http://buildr.apache.org/' title="Build like you code"><img alt='buildr' src='images/buildr.png'></a>
19
+ <div class='tagline'>Build like you code</div>
20
+ </div>
21
+ <div id='pages'>
22
+ <ol class='toc'>
23
+ <li>Start Here
24
+ <ol class="toc">
25
+ <li><a href='index.html'>Welcome</a></li>
26
+ <li><a href='quick_start.html'>Quick Start</a></li>
27
+ <li><a href='installing.html'>Installing & Running</a></li>
28
+ <li><a href='http://cwiki.apache.org/confluence/display/BUILDR/Index'>Community Wiki</a></li>
29
+ </ol>
30
+ </li>
31
+ <li>Using Buildr
32
+ <ol class="toc">
33
+ <li><a href='buildr.pdf'>This Guide (PDF)</a></li>
34
+ <li><a href='projects.html'>Projects</a></li>
35
+ <li><a href='building.html'>Building</a></li>
36
+ <li><a href='artifacts.html'>Artifacts</a></li>
37
+ <li><a href='packaging.html'>Packaging</a></li>
38
+ <li><a href='testing.html'>Testing</a></li>
39
+ <li><a href='releasing.html'>Releasing</a></li>
40
+ <li><a href='settings_profiles.html'>Settings/Profiles</a></li>
41
+ <li><a href='languages.html'>Languages</a></li>
42
+ <li><a href='more_stuff.html'>More Stuff</a></li>
43
+ <li><a href='extending.html'>Extending Buildr</a></li>
44
+ <li><a href='http://cwiki.apache.org/confluence/display/BUILDR/Buildr+HowTos'>How-Tos</a></li>
45
+ </ol>
46
+ </li>
47
+ <li>Reference
48
+ <ol class="toc">
49
+ <li><a href='rdoc'>API</a></li>
50
+ <li><a href='http://docs.rubyrake.org'>Rake</a></li>
51
+ <li><a href='http://antwrap.rubyforge.org'>Antwrap</a></li>
52
+ <li><a href='http://cwiki.apache.org/confluence/display/BUILDR/Common+Problems+and+Solutions'>Troubleshooting</a></li>
53
+ </ol>
54
+ </li>
55
+ <li>Get Involved
56
+ <ol class="toc">
57
+ <li><a href='download.html'>Download</a></li>
58
+ <li><a href='mailing_lists.html'>Mailing Lists</a></li>
59
+ <li><a href='http://www.twitter.com/buildr'>Twitter</a></li>
60
+ <li><a href='http://issues.apache.org/jira/browse/Buildr'>Issues/Bugs</a></li>
61
+ <li><a href='contributing.html'>Contributing</a></li>
62
+ <li><a href='specs.html'>Specs</a></li>
63
+ <li><a href='coverage/index.html'>Coverage</a></li>
64
+ </ol>
65
+ </li>
66
+ <li>
67
+ <form action='http://www.google.com/cse' id='searchbox_003673095760649043902:ogcgrzu0l2y'>
68
+ <input name='cx' type='hidden' value='003673095760649043902:ogcgrzu0l2y'>
69
+ <input name='cof' type='hidden' value='FORID:0'>
70
+ <input name='q' size='20' type='text'>
71
+ <input name='sa' type='submit' value='Search'>
72
+ <img alt='Google Custom Search' src='http://www.google.com/coop/images/google_custom_search_smnar.gif'>
73
+ </form>
74
+ </li>
75
+ <li>The Buildr Book
76
+ <p><a href='http://www.amazon.com/Buildr/dp/1442160942/'><img src='images/1442160941-frontcover.jpg' style='width:120px'></a></p>
77
+ <p>Based on the Buildr documentation, available from <a href='http://www.amazon.com/Buildr/dp/1442160942/'>Amazon</a> and
78
+ <a href='http://www.createspace.com/3382199'>CreateSpace</a></p>
79
+ </li>
80
+ </ol>
81
+ </div>
82
+ <div id='content'>
83
+ <h1 id='{{ page.title | downcase | replace(' ', '_') }}'>{{ page.title }}</h1>
84
+ {{ content | toc }}
85
+ {{ content }}
86
+ </div>
87
+ <div id='footer'>Copyright &copy; 2007-2010 The Apache Software Foundation</div>
88
+ </div>
89
+ </body>
90
+ </html>
@@ -0,0 +1,22 @@
1
+ <html>
2
+ <head>
3
+ <meta content='text/html;charset=UTF-8' http-equiv='Content-Type' />
4
+ <title>buildr</title>
5
+ <style type='text/css'>
6
+ @import 'css/default.css';
7
+ @import 'css/syntax.css';
8
+ </style>
9
+ <style media='print' type='text/css'>
10
+ @import 'css/print.css';
11
+ </style>
12
+ <meta content='Official Buildr documentation from the people in the know' name='subject' />
13
+ <link href='images/favicon.png' rel='shortcut icon' />
14
+ </head>
15
+ <body>
16
+ <div id='wrap'>
17
+ <div id='content'>
18
+ {{ content }}
19
+ </div>
20
+ </div>
21
+ </body>
22
+ </html>
@@ -0,0 +1,217 @@
1
+ ---
2
+ layout: default
3
+ title: Artifacts
4
+ ---
5
+
6
+
7
+ In Buildr, almost everything is a file or a file task. You compile source files that come from the file system using dependencies found on the file system, generating even more files. But how do you get these dependencies to start with, and how do you share them with others?
8
+
9
+ Artifacts. We designed Buildr to work as a drop-in replacement for Maven 2.0, and share artifacts through the same local and remote repositories. Artifact tasks know how to download a file from one of the remote repositories, and install it in the local repository, where Buildr can find it. Packages know how to create files and upload them to remote repositories.
10
+
11
+ We'll get into all of that in a second, but first, let's introduce the artifact specification. It's a simple string that takes one of two forms:
12
+
13
+ {% highlight text %}
14
+ group:id:type:version
15
+ group:id:type:classifier:version
16
+ {% endhighlight %}
17
+
18
+ For example, @'org.apache.axis2:axis2:jar:1.2'@ refers to an artifact with group identifier org.apache.axis2, artifact identifier axis2, a JAR file with version 1.2. Classifiers are typically used to distinguish between similar file types, for example, a source distribution and a binary distribution that otherwise have the same identifier and are both ZIP files.
19
+
20
+
21
+ h2(#specifying). Specifying Artifacts
22
+
23
+ If your Buildfile spells out @'org.apache.axis2:axis2:jar:1.2'@ more than once, you're doing something wrong. Repeating the same string over and over will make your code harder to maintain. You'll know that when you upgrade to a new version in one place, forget to do it in another, and end up with a mismatch.
24
+
25
+ You can use Ruby's syntax to do simple string substitution, for example:
26
+
27
+ {% highlight ruby %}
28
+ AXIS_VERSION = '1.2'
29
+
30
+ compile.with "org.apache.axis2:axis2:jar:#{AXIS_VERSION}"
31
+ {% endhighlight %}
32
+
33
+ Better yet, you can define all your artifacts at the top of the Buildfile and use constants to reference them in your project definition. For example:
34
+
35
+ {% highlight ruby %}
36
+ AXIS2 = 'org.apache.axis2:axis2:jar:1.2'
37
+
38
+ compile.with AXIS2
39
+ {% endhighlight %}
40
+
41
+ Note that we're not using a separate constant for the version number. In our experience, it's unnecessary. The version number intentionally appears at the end of the string, where it stands out easily.
42
+
43
+ If you have a set of artifacts that belong to the same group and version, and that's quite common, you can use the @group@ shortcut:
44
+
45
+ {% highlight ruby %}
46
+ AXIOM = group('axiom-api', 'axiom-impl', 'axiom-dom',
47
+ :under=>'org.apache.ws.commons.axiom', :version=>'1.2.4')
48
+ {% endhighlight %}
49
+
50
+ p(note). Buildr projects also define a @group@ attribute which can lead to some confusion. If you want to define an artifact group within a project definition, you should use the explicit qualifier @Buildr::group@.
51
+
52
+ If you have several artifacts you always use together, consider placing them in an array. Methods that accept lists of artifacts also accept arrays. For example:
53
+
54
+ {% highlight ruby %}
55
+ OPENJPA = ['org.apache.openjpa:openjpa:jar:1.2.1',
56
+ 'net.sourceforge.serp:serp:jar:1.12.0']
57
+ AXIS_OF_WS = [AXIS2, AXIOM]
58
+
59
+ compile.with OPENJPA, AXIS_OF_WS
60
+ {% endhighlight %}
61
+
62
+ Another way to group related artifacts together and access them individually is using the @struct@ shortcut. For example:
63
+
64
+ {% highlight ruby %}
65
+ JAVAX = struct(
66
+ :activation =>'javax.activation:activation:jar:1.1',
67
+ :persistence =>'javax.persistence:persistence-api:jar:1.0',
68
+ :stream =>'stax:stax-api:jar:1.0.1',
69
+ )
70
+
71
+ compile.with JAVAX.persistence, OPENJPA
72
+ {% endhighlight %}
73
+
74
+ In our experience, using constants in this manner makes your Buildfile much easier to write and maintain.
75
+
76
+ And, of course, you can always place your artifact specifications in a separate file and require it into your Buildfile. For example, if you're working on several different projects that all share the same artifacts:
77
+
78
+ {% highlight ruby %}
79
+ require '../shared/artifacts'
80
+ {% endhighlight %}
81
+
82
+ When you use @require@, Ruby always looks for a filename with the @.rb@ extension, so in this case it expects to find @artifacts.rb@ in the @shared@ directory.
83
+
84
+ One last thing. You can also treat artifact specifications as hashes. For example:
85
+
86
+ {% highlight ruby %}
87
+ AXIS = { :group=>'org.apache.axis2', :id=>'axis2', :version=>'1.2' }
88
+ compile.with AXIS
89
+ puts compile.dependencies.first.to_hash
90
+ => { :group=>'org.apache.axis2', :id=>'axis2',
91
+ :version=>'1.2', :type=>:jar }
92
+ {% endhighlight %}
93
+
94
+
95
+ h2(#repositories). Specifying Repositories
96
+
97
+ Buildr can download artifacts for you, but only if you tell it where to find them. You need to specify at least one remote repository, from which to download these artifacts.
98
+
99
+ When you call @repositories.remote@, you get an array of URLs for the various remote repositories. Initially, it's an empty array, to which you can add new repositories. For example:
100
+
101
+ {% highlight ruby %}
102
+ repositories.remote << 'http://www.ibiblio.org/maven2/'
103
+ {% endhighlight %}
104
+
105
+ If your repository requires HTTP authentication, you can write,
106
+
107
+ {% highlight ruby %}
108
+ repositories.remote << URI.parse("http://user:password@repository.example.com")
109
+ {% endhighlight %}
110
+
111
+ If you need to use a proxy server to access remote repositories, you can set the environment variable @HTTP_PROXY@ to the proxy server URL (use @HTTPS_PROXY@ for proxying HTTPS connections). You can also work without a proxy for certain hosts by specifying the @NO_PROXY@ environment variable. For example:
112
+
113
+ {% highlight sh %}
114
+ $ export HTTP_PROXY = 'http://myproxy:8080'
115
+ $ export NO_PROXY = '*.mycompany.com,localhost,special:800'
116
+ {% endhighlight %}
117
+
118
+ Alternatively you can use the Buildr options @proxy.http@ and @proxy.exclude@:
119
+
120
+ {% highlight ruby %}
121
+ options.proxy.http = 'http://myproxy:8080'
122
+ options.proxy.exclude << '*.mycompany.com'
123
+ options.proxy.exclude << 'localhost'
124
+ {% endhighlight %}
125
+
126
+ All the artifacts download into the local repository. Since all your projects share the same local repository, you only need to download each artifact once. Buildr was designed to be used alongside Maven 2.0, for example, when migrating projects from Maven 2.0 over to Buildr. By default it will share the same local repository, expecting the repository to be the @.m2/repository@ directory inside your home directory.
127
+
128
+ You can choose to relocate the local repository by giving it a different path, for example:
129
+
130
+ {% highlight ruby %}
131
+ repositories.local = '/usr/local/maven/repository'
132
+ {% endhighlight %}
133
+
134
+ That's one change you don't want to commit into the Buildfile, so the best place to do it is in the @buildr.rb@ file in the @.buildr@ directory under your home directory.
135
+
136
+ Buildr downloads artifacts when it needs to use them, for example, to compile a project. You don't need to download artifacts directly. Except when you do, for example, if you want to download all the latest artifacts and then go off-line. It's as simple as:
137
+
138
+ {% highlight sh %}
139
+ $ buildr artifacts
140
+ {% endhighlight %}
141
+
142
+
143
+ h2(#downloading). Downloading Artifacts
144
+
145
+ Within your buildfile you can download artifacts directly by invoking them, for example:
146
+
147
+ {% highlight ruby %}
148
+ artifact('org.apache.openjpa:openjpa:jar:1.2.1').invoke
149
+ artifacts(OPENJPA).each(&:invoke)
150
+ {% endhighlight %}
151
+
152
+ When you let Buildr download artifacts for you, or by invoking the artifact task yourself, it scans through the remote repositories assuming each repository follows the Maven 2 structure. Starting from the root repository URL, it will look for each artifact using the path @group/id/version/id-version.type@ (or ...@/id-version-classifier.type@). The group identifier becomes a path by turning periods (@.@) into slashes (@/@). So to find @org.apache.axis2:axis2:jar:1.2@, we're going to look for @org/apache/axis2/axis2/1.2/axis2-1.2.jar@.
153
+
154
+ You'll find a lot of open source Java libraries in public repositories that support this structure (for example, the "Ibiblio Maven":http://www.ibiblio.org/maven2/ repository). And, of course, every remote repository you setup for your projects.
155
+
156
+ But there are exceptions to the rule. Say we want to download the Dojo widget library and use it in our project. It's available from the Dojo Web site, but that site doesn't follow the Maven repository conventions, so our feeble attempt to use existing remote repositories will fail.
157
+
158
+ We can still treat Dojo as an artifact, by telling Buildr where to download it from:
159
+
160
+ {% highlight ruby %}
161
+ DOJO = '0.2.2'
162
+
163
+ url = "http://download.dojotoolkit.org/release-#{DOJO}/dojo-#{DOJO}-widget.zip"
164
+ download(artifact("dojo:dojo:zip:widget:#{DOJO}")=>url)
165
+ {% endhighlight %}
166
+
167
+ Explaining how it works is tricky, skip if you don't care for the details. On the other hand, it will give you a better understanding of Buildr/Rake, so if not now, come back and read it later.
168
+
169
+ We use the @artifact@ method to create an @Artifact@ task that references the Dojo widget in our local repository. The @Artifact@ task is a file task with some additional behavior added by Buildr. When you call @compile.with@, that's exactly what it does internally, turning each of your artifact specifications into an @Artifact@ task.
170
+
171
+ But the @Artifact@ task doesn't know how to download the Dojo widget, only how to handle conventional repositories. So we're going to create a download task as well. We use the @download@ method to create a file task that downloads the file from a remote URL. (Of course, it will only download the file if it doesn't already exist.)
172
+
173
+ But which task gets used when? We could have defined these tasks separately and used some glue code to make one use the other. Instead, we call @download@ with the results of @artifact@. Essentially, we're telling @download@ to use the same file path as @artifact@. So now we have two file tasks that point to the very same file. We wired them together.
174
+
175
+ You can't have more than one task pointing to the same file. Rake's rule of the road. What Rake does is merge the tasks together, creating a single file task for @artifact@, and then enhancing it with another action from @download@. One task, two actions. Statistically, we've doubled the odds that at least one of these actions will manage to download the Dojo widget and install it in the local repository.
176
+
177
+ Since we ordered the calls to @artifact@ first and @download@ second, we know the actions will execute in that order. But @artifact@ is slightly devilish: when its action runs, it adds another action to the end of the list. So the @artifact@ action runs first, adds an action at the end, the @download@ action runs second, and downloads the Dojo widget for us. The second @artifact@ action runs last, but checks that the file already exist and doesn't try to download it again.
178
+
179
+ Magic.
180
+
181
+
182
+ h2(#install_upload). Install and Upload
183
+
184
+ Generally you use artifacts that download from remote repositories into the local repository, or artifacts packaged by the project itself (see "Packaging":packaging.html), which are then installed into the local repository and uploaded to the release server.
185
+
186
+ Some artifacts do not fall into either category. In this example we're going to download a ZIP file, extract a JAR file from it, and use that JAR file as an artifact. We would then expect to install this JAR in the local repository and upload it to the release server, where it can be shared with other projects.
187
+
188
+ So let's start by creating a task that downloads the ZIP, and another one to extract it and create the JAR file:
189
+
190
+ {% highlight ruby %}
191
+ app_zip = download('target/app.zip'=>url)
192
+ bean_jar = file('target/app/bean.jar'=>unzip('target/app'=>app_zip))
193
+ {% endhighlight %}
194
+
195
+ When you call @artifact@, it returns an @Artifact@ task that points to the artifact file in the local repository, downloading the file if it doesn't already exist. You can override this behavior by enhancing the task and creating the file yourself (you may also want to create a POM file). Or much simpler, call the @from@ method on the artifact and tell it where to find the source file.
196
+
197
+ So the next step is to specify the artifact and tell it to use the extracted JAR file:
198
+
199
+ {% highlight ruby %}
200
+ bean = artifact('example.com:beans:jar:1.0').from(bean_jar)
201
+ {% endhighlight %}
202
+
203
+ The artifact still points to the local repository, but when we invoke the task it copies the source file over to the local repository, instead of attempting a download.
204
+
205
+ Use the @install@ method if you want the artifact and its POM installed in the local repository when you run the @install@ task. Likewise, use the @upload@ method if you want the artifact uploaded to the release server when you run the @upload@ task. You do not need to do this on artifacts downloaded from a remote server, or created with the @package@ method, the later are automatically added to the list of installed/uploaded artifacts.
206
+
207
+ Our example ends by including the artifact in the @install@ and @upload@ tasks:
208
+
209
+ {% highlight ruby %}
210
+ install bean
211
+ upload bean
212
+ {% endhighlight %}
213
+
214
+ p(tip). Calling the @install@ (and likewise @upload@) method on an artifact run @buildr install@. If you need to download and install an artifact, invoke the task directly with @install(<artifact>).invoke@.
215
+
216
+
217
+ We'll talk more about installing and uploading in the next chapter, but right now we're going to "package some artifacts":packaging.html.
@@ -0,0 +1,276 @@
1
+ ---
2
+ layout: default
3
+ title: Building
4
+ ---
5
+
6
+
7
+ To remove any confusion, Buildr's build task is actually called @build@. It's also the default task that executes when you run @buildr@ without any task name.
8
+
9
+ The @build@ task runs two other tasks: @compile@ and its associated tasks (that would be, @resources@) and @test@ and its associated tasks (@test:compile@, @test:setup@ and friends). We'll talk about @compile@ more in this section, and @test@ later on. We'll also show you how to run @build@ without testing, not something we recommend, but a necessary feature.
10
+
11
+ Why @build@ and not @compile@? Some projects do more than just compiling. Other projects don't compile at all, but perform other build tasks, for example, creating a database schema or command line scripts. So we want you to get in the practice of running the @build@ task, and help you by making it the default task.
12
+
13
+
14
+ h2(#compiling). Compiling
15
+
16
+ Each project has its own @compile@ task you can invoke directly, by running @buildr compile@ or as part of another build task. (Yes, that @build@).
17
+
18
+ The @compile@ task looks for source files in well known directories, determines which compiler to use, and sets the target directory accordingly. For example, if it finds any Java source files in the @src/main/java@ directory, it selects the Javac compiler and generates bytecode in the @target/classes@ directories. If it finds Scala source files in the @src/main/scala@ directory it selects the Scalac compiler, and so forth.
19
+
20
+ A single project cannot use multiple compilers at the same time, hence you may prefer creating subprojects by programming language. Some compilers like Groovy's are joint-compilers, this means they can handle several languages. When the Groovy compiler is selected for a project, .groovy and .java files are compiled by groovyc.
21
+
22
+ Most often, that's just good enough and the only change you need to make is adding compile dependencies. You can use @compile.dependencies@ to get the array of dependency file tasks. For Java, each of these tasks points to a JAR or a directory containing Java classes, and the entire set of dependencies is passed to Javac as the classpath.
23
+
24
+ Buildr uses file tasks to handle dependencies, but here we're talking about the Rake dependency mechanism. It's a double entendre. It invokes these tasks before running the compiler. Some of these tasks will download JARs from remote repositories, others will create them by compiling and packaging from a different project. Using file task ensures all the dependencies exist before the compiler can use them.
25
+
26
+ An easier way to specify dependencies is by calling the @compile.with@ method. It takes a list of arguments and adds them to the dependency list. The @compile.with@ method is easier to use, it accepts several type of dependencies. You can use file names, file tasks, projects, artifacts specifications and even pass arrays of dependencies.
27
+
28
+ Most dependencies fall into the last three categories. When you pass a project to @compile.with@, it picks up all the packages created by that project. In doing so, it establishes an order of dependency between the two projects (see "Defining the Project":projects.html#defining). For example, if you make a change in project _teh-api_ and build _teh-impl_, Buildr will detect that change, recompile and package _teh-api_ before compiling _teh-impl_. You can also select a specific package using the project's @package@ or @packages@ methods (see "Packaging":packaging.html).
29
+
30
+ When you pass an artifact specification to @compile.with@, it creates an @Artifact@ task that will download that artifact from one of the remote repositories, install it in the local repository, and use it in your project. Rake's dependency mechanism is used here to make sure the artifact is downloaded once, when needed. Check the "Artifacts":artifacts.html section for more information about artifact specification and repositories.
31
+
32
+ For now let's just show a simple example:
33
+
34
+ {% highlight ruby %}
35
+ compile.with 'org.apache.axis2:axis2:jar:1.2',
36
+ 'org.apache.derby:derby:jar:10.1.2.1', projects('teh-api', 'teh-impl')
37
+ {% endhighlight %}
38
+
39
+ Passing arrays to @compile.with@ is just a convenient for handling multiple dependencies, we'll show more examples of that when we talk about "Artifacts":artifacts.html.
40
+
41
+ Likewise, the @compile@ task has an array of file tasks that point at the source directories you want to compile from. You can access that array by calling @compile.sources@. You can use @compile.from@ to add new source directories by passing a file name or a file task.
42
+
43
+ For example, let's run the APT tool on our annotated source code before compiling it:
44
+
45
+ {% highlight ruby %}
46
+ compile.from apt
47
+ {% endhighlight %}
48
+
49
+ When you call @apt@ on a project, it returns a file task that points to the @target/generated/apt@ directory. This file task executes by running APT, using the same list of source directories, dependencies and compiler options. It then generates new source files in the target directory. Calling @compile.from@ with that file task includes those additional source files in the list of compiled sources.
50
+
51
+ Here's another example:
52
+
53
+ {% highlight ruby %}
54
+ jjtree = jjtree(_('src/main/jjtree'), :in_package=>'com.acme')
55
+ compile.from javacc(jjtree, :in_package=>'com.acme'), jjtree
56
+ {% endhighlight %}
57
+
58
+ This time, the variable @jjtree@ is a file task that reads a JJTree source file from the @src/main/jjtree@ directory, and generates additional source files in the @target/generated/jjtree@ directory. The second line creates another file task that takes those source files, runs JavaCC on them, and generates yet more source files in @target/generated/javacc@. Finally, we include both sets of source files in addition to those already in @src/main/java@, and compile the lot.
59
+
60
+ The interesting thing about these two examples is how you're wiring file tasks together to create more complicated tasks, piping the output of one task into the inputs of another. Wiring tasks this way is the most common way to handle complex builds, and uses Rake's dependency mechanism to only run tasks when it detects a change to one of the source files.
61
+
62
+ You can also control the target directory. Use @compile.target@ to get the target directory file task. If you need to change the target directory, call the @compile.into@ method with the new path.
63
+
64
+ We use method pairs to give you finer control over the compiler, but also a way to easily configure it. Methods like @dependencies@ and @sources@ give you a live array you can manipulate, or iterate over. On the other hand, methods like @with@ and @from@ accept a wider set of arguments and clean them up for you. They also all return the same task you're calling, so you can chain methods together.
65
+
66
+ For example:
67
+
68
+ {% highlight ruby %}
69
+ compile.from('srcs').with('org.apache.axis2:axis2:jar:1.2').
70
+ into('classes').using(:target=>'1.4')
71
+ {% endhighlight %}
72
+
73
+ Buildr uses the method pair and method chaining idiom in many places to make your life easier without sacrificing flexibility.
74
+
75
+ Occasionally, you'll need to post-process the generated bytecode. Since you only want to do that after compiling, and let the compiler decide when to do that – only when changes require re-compiling – you'll want to extend the @compile@ task. You can do that by calling @compile@ with a block.
76
+
77
+ For example, to run the OpenJPA bytecode enhancer after compiling the source files:
78
+
79
+ {% highlight ruby %}
80
+ compile { open_jpa_enhance }
81
+ {% endhighlight %}
82
+
83
+ You can change various compile options by calling, you guessed, @compile.options@. For example, to set the compiler to VM compatibility with Java 1.5 and turn on all Lint messages:
84
+
85
+ {% highlight ruby %}
86
+ compile.options.target = '1.5'
87
+ compile.options.lint = 'all'
88
+ {% endhighlight %}
89
+
90
+ Or, if you want to chain methods together:
91
+
92
+ {% highlight ruby %}
93
+ compile.using :target=>'1.5', :lint=>'all'
94
+ {% endhighlight %}
95
+
96
+
97
+ Sub-projects inherit compile options from their parent project, so you only need to change these settings once in the top project. You can do so, even if the top project itself doesn't compile anything.
98
+
99
+ The options available to you depend on which compiler you are using for this particular project, obviously the options are not the same for Java and Flash. Two options are designed to work consistently across compilers.
100
+
101
+ Buildr turns the @warning@ option on by default, but turns it off when you run @buildr --silent@. It also sets the @debug@ option on, but turns it off when making a release. You can also control the @debug@ option from the command line, for example:
102
+
103
+ {% highlight ruby %}
104
+ # When calling buildr
105
+ $ buildr compile debug=off
106
+
107
+ # Once until we change the variable
108
+ $ export DEBUG=off
109
+ $ buildr compile
110
+ {% endhighlight %}
111
+
112
+ The default source and target directories, compiler settings and other options you can use depend on the specific language. You can find more information in the "Languages":languages.html section.
113
+
114
+
115
+ h2(#resources). Resources
116
+
117
+
118
+ The @compile@ task comes bundled with a @resources@ task. It copies files from the @src/main/resources@ directory into @target/resources@. Best used for copying files that you want to include in the generated code, like configuration files, i18n messages, images, etc.
119
+
120
+ The @resources@ task uses a filter that can change files as it copies them from source to destination. The most common use is by mapping values using a hash. For example, to substitute "${version}" for the project's version number and "${copyright}" for "Acme Inc (C) 2007" :
121
+
122
+ {% highlight ruby %}
123
+ resources.filter.using 'version'=>version,
124
+ 'copyright'=>'Acme Inc (C) 2007'
125
+ {% endhighlight %}
126
+
127
+ You can also use "profiles":settings_profiles.html#profiles to supply a name/value map that all @resources@ task should default to, by adding a @filter@ element to each of the profiles. The following examples shows a @profiles.yaml@ file that applies the same filter in development and test environments:
128
+
129
+ {% highlight yaml %}
130
+ filter: &alpha1
131
+ version: experimental
132
+ copyright: Acme Inc (C) 2007
133
+
134
+ development:
135
+ filter: *alpha1
136
+ test:
137
+ filter: *alpha1
138
+ {% endhighlight %}
139
+
140
+ You can specify a different format by passing it as the first argument. Supported formats include:
141
+
142
+ |_. Format |_. Usage |
143
+ | @:ant@ | Map from <code>@key@</code> to value. |
144
+ | @:maven@ | Map from @${key}@ to value (default). |
145
+ | @:ruby@ | Map from @#{key}@ to value. |
146
+ | @:erb@ | Map from @<%=key%>@ to value. |
147
+ | @Regexp@ | Map using the matched value of the regular expression (e.g. @/=(.*?)=/@). |
148
+
149
+ For example, using the @:ruby@ format instead of the default @:maven@ format:
150
+
151
+ {% highlight ruby %}
152
+ resources.filter.using :ruby, 'version'=>version,
153
+ 'copyright'=>'Acme Inc (C) 2007'
154
+ {% endhighlight %}
155
+
156
+ For more complicated mapping you can also pass a method or a proc. The filter will call it once for each file with the file name and content.
157
+
158
+ If you need to copy resource files from other directories, add these source directories by calling the @from@ method, for example:
159
+
160
+ {% highlight ruby %}
161
+ resources.from _('src/etc')
162
+ {% endhighlight %}
163
+
164
+ You can select to copy only specific files using common file matching patterns. For example, to include only HTML files:
165
+
166
+ {% highlight ruby %}
167
+ resources.include '*.html'
168
+ {% endhighlight %}
169
+
170
+ To include all files, except for files in the @scratch@ directory:
171
+
172
+ {% highlight ruby %}
173
+ resources.exclude 'scratch/*'
174
+ {% endhighlight %}
175
+
176
+ The filter always excludes the @CVS@ and @.svn@ directories, and all files ending with @.bak@ or @~@, so no need to worry about these.
177
+
178
+ A file pattern can match any file name or part of a file name using an asterisk (@*@). Double asterisk (@**@) matches directories recursively, for example, @'src/main/java/**/*.java'@. You can match any character using a question mark (@?@), or a set of characters using square brackets (@[]@), similar to regular expressions, for example, @'[Rr]eadme'@. You can also match from a set of names using curly braces (@{}@), for example, @'*.{html,css}'@.
179
+
180
+ You can use filters elsewhere. The @filter@ method creates a filter, the @into@ method sets the target directory, and @using@ specifies the mapping. Last, you call @run@ on the filter to activate it.
181
+
182
+ For example:
183
+
184
+ {% highlight ruby %}
185
+ filter('src/specs').into('target/specs').
186
+ using('version'=>version, 'created'=>Time.now).run
187
+ {% endhighlight %}
188
+
189
+ The @resources@ task is, in fact, just a wrapper around such a filter that automatically adds the @src/main/resources@ directory as one of the source directories.
190
+
191
+
192
+ h2(#more). More On Building
193
+
194
+ The @build@ task runs the @compile@ (and @resources@) tasks as prerequisites, followed by any actions you add to it, and completes by running the @test@ task. The @build@ task itself is a prerequisite to other tasks, for example, @package@ and @upload@.
195
+
196
+ You can extend the @build@ task in two ways. You can add more prerequisites that will execute before the task itself, or you can add actions that will execute as part of the task. Which one you choose is up to you, we'll show you how they differ in a second. If you call @build@ with a list of tasks, it adds these tasks as prerequisites. Call @build@ with a block, and it adds that block as an action. Again, a common idiom you'll see elsewhere in Buildr and Rake.
197
+
198
+ Let's look at a simple example. Say we want to generate a Derby database from an SQL file and include it in the ZIP package:
199
+
200
+ {% highlight ruby %}
201
+ db = Derby.create(_('target/derby/db')=>_('src/main/sql/derby.sql'))
202
+ package(:zip).include db
203
+ {% endhighlight %}
204
+
205
+ There's nothing fundamentally wrong with this code, if that's what you intend to do. But in practice, you don't always run the @package@ task during development, so you won't notice if something is wrong with this task when you build. For example, if it fails to generate the SQL file. In addition, the @package@ task runs after @build@, so you can't use the database in your test cases.
206
+
207
+ So let's refactor it. We're going to use the variable @db@ to reference the file task that creates the database, and make it a prerequisite of the @build@ task. And use that same variable again to include the database in the ZIP package:
208
+
209
+ {% highlight ruby %}
210
+ db = Derby.create(_('target/derby/db')=>_('src/main/sql/derby.sql'))
211
+ build db
212
+ package(:zip).include db
213
+ {% endhighlight %}
214
+
215
+ Much better. We're using the same task twice, but since we're using Rake here, it will only execute once. In fact, it will only execute if we don't already have a Derby database, or if it detects a change to the SQL file and needs to recreate the database.
216
+
217
+ p(tip). @Derby.create@ is not part of Buildr, you can get "derby.rake":http://svn.apache.org/repos/asf/ode/trunk/tasks/derby.rake here.
218
+
219
+ Here's another example. We want to copy some files over as part of the build, and apply a filter to them. This time, we're going to extend the @build@ task:
220
+
221
+ {% highlight ruby %}
222
+ build do
223
+ filter('src/specs').into('target/specs').
224
+ using('version'=>version, 'created'=>Time.now).run
225
+ end
226
+ {% endhighlight %}
227
+
228
+ The @build@ task is recursive, so running @buildr build@ picks the current project and runs its @build@ task, which in turn runs the @build@ task on each of its sub-projects. One @build@ task to rule them all.
229
+
230
+
231
+ h2(#cleaning). Cleaning
232
+
233
+ The @build@ task has an evil twin, the @clean@ task. It's the task you use to remove all the files created during the build, especially when you mess things up and want to start all over.
234
+
235
+ It basically erases the target directories, the one called @target@, and if you get creative and change the target directory for tasks like @compile@, it will also erase those. If you decide to generate files outside the target directory and want to cleanup after yourself, just extend the @clean@ task.
236
+
237
+ For example:
238
+
239
+ {% highlight ruby %}
240
+ clean { rm_rf _('staged') }
241
+ {% endhighlight %}
242
+
243
+ The @rm_rf@ method deletes the directory and all files in it. It's named after UNIX's infamous @rm -rf@. Use it wisely. This is also a good time to introduce you to @FileUtils@, a standard Ruby library that contains convenient methods for creating and deleting directories, copying and moving files, even comparing two files. They're all free of charge when you use Buildr.
244
+
245
+
246
+ h2(#continuous-compilation). Continuous Compilation
247
+
248
+ And if all that weren't enough, Buildr also offers a time-saving feature called continuous compilation. This feature, implemented by the @cc@ task, instructs Buildr to loop eternally, polling your project's source directories for changes. Whenever a change is detected, Buildr immediately triggers the appropriate compilation step and goes right back to polling. This allows you to reap many of the benefits of an incrementally compiling IDE like Eclipse without sacrificing your favorite build tool.
249
+
250
+ To get started, simply invoke the @cc@ task at the command prompt:
251
+
252
+ {% highlight sh %}
253
+ $ buildr cc
254
+ {% endhighlight %}
255
+
256
+ This task will immediately invoke the @compile@ and @test:compile@ tasks on your project if necessary. This ensures that your build is completely up to the minute before polling is initiated. After this initial build (if required), Buildr will print a notification indicating which directories are being monitored. By default, these directories will include any source folders (e.g. @src/main/java/@), any test directories (e.g. @src/spec/scala/@) as well as any resources (e.g. @src/main/resources/). The Buildr process will remain running during this time, meaning that in order to test this functionality, we will need to open a new shell:
257
+
258
+ {% highlight sh %}
259
+ $ touch src/main/java/Test.java
260
+ {% endhighlight %}
261
+
262
+ The moment we run this command, Buildr will detect the change and invoke the @compile@ task. It will *not* invoke the @test:compile@ task, since none of the test files were actually changed. This ensures that potentially time-consuming tasks are avoided if possible. Note that, unlike the @build@ task, the continuous compilation also does not actually run any of your tests. Continuous compilation is designed to be a simple daemon which runs forever, quickly recompiling your project as soon as you save or delete a file. We can terminate the continuous compilation task by pressing Ctrl-C. Left to its own devices, the @cc@ task really will loop forever.
263
+
264
+ There are several advantages to continuous compilation. Number one is convenience. Once you invoke the @cc@ task, you can focus exclusively on the code, editing and saving your files in an unbroken workflow. There is no need to break your concentration to invoke Buildr manually unless you need to run the test suite, deploy the application or anything beyond compilation. The second advantage is speed. By using the continuous compilation process, you avoid repeatedly incurring Buildr's startup overhead. While this startup time is kept to a minimum, it is still perceptable, particularly when running on JRuby. Since the @cc@ task runs within a Buildr instance which has already been started, there is no need for repeated, inefficient load times. Again, this allows you to focus more completely on what's really important: the code.
265
+
266
+ By default, the @cc@ task will poll your sources once every 200 milliseconds. We have found that this frequency strikes a nice balance between CPU load (which is insignificant) and nearly-instant detection. However, you may wish to tune this value based on your own needs. To do so, simply use the @cc.frequency@ property in your project definition:
267
+
268
+ {% highlight ruby %}
269
+ project 'foo' do
270
+ cc.frequency 1.5 # poll every one-and-a-half seconds
271
+ end
272
+ {% endhighlight %}
273
+
274
+ If you find that the 200 ms default imposes too much overhead, try changing @cc.frequency@ to a higher value. On the flip side, if you find that you're waiting too long for changes to be caught by the poll, tune the frequency lower.
275
+
276
+ Now let's "talk about the artifacts":artifacts.html we mentioned before.