buildr 1.3.2-java → 1.3.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/CHANGELOG +66 -4
  2. data/{README → README.rdoc} +29 -16
  3. data/Rakefile +16 -20
  4. data/_buildr +38 -0
  5. data/addon/buildr/cobertura.rb +49 -45
  6. data/addon/buildr/emma.rb +238 -0
  7. data/addon/buildr/jetty.rb +1 -1
  8. data/addon/buildr/nailgun.rb +585 -661
  9. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
  10. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
  11. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
  12. data/bin/buildr +9 -2
  13. data/buildr.buildfile +53 -0
  14. data/buildr.gemspec +21 -14
  15. data/doc/css/default.css +51 -48
  16. data/doc/css/print.css +60 -55
  17. data/doc/images/favicon.png +0 -0
  18. data/doc/images/growl-icon.tiff +0 -0
  19. data/doc/images/project-structure.png +0 -0
  20. data/doc/pages/artifacts.textile +46 -156
  21. data/doc/pages/building.textile +63 -323
  22. data/doc/pages/contributing.textile +112 -102
  23. data/doc/pages/download.textile +19 -27
  24. data/doc/pages/extending.textile +27 -81
  25. data/doc/pages/getting_started.textile +44 -119
  26. data/doc/pages/index.textile +26 -47
  27. data/doc/pages/languages.textile +407 -0
  28. data/doc/pages/more_stuff.textile +92 -173
  29. data/doc/pages/packaging.textile +71 -239
  30. data/doc/pages/projects.textile +58 -233
  31. data/doc/pages/recipes.textile +19 -43
  32. data/doc/pages/settings_profiles.textile +39 -104
  33. data/doc/pages/testing.textile +41 -304
  34. data/doc/pages/troubleshooting.textile +29 -47
  35. data/doc/pages/whats_new.textile +69 -167
  36. data/doc/print.haml +0 -1
  37. data/doc/print.toc.yaml +1 -0
  38. data/doc/scripts/buildr-git.rb +1 -1
  39. data/doc/site.haml +1 -0
  40. data/doc/site.toc.yaml +8 -5
  41. data/{KEYS → etc/KEYS} +0 -0
  42. data/etc/git-svn-authors +16 -0
  43. data/lib/buildr.rb +2 -5
  44. data/lib/buildr/core/application.rb +192 -98
  45. data/lib/buildr/core/build.rb +140 -91
  46. data/lib/buildr/core/checks.rb +5 -5
  47. data/lib/buildr/core/common.rb +1 -1
  48. data/lib/buildr/core/compile.rb +12 -10
  49. data/lib/buildr/core/filter.rb +151 -46
  50. data/lib/buildr/core/generate.rb +9 -9
  51. data/lib/buildr/core/progressbar.rb +1 -1
  52. data/lib/buildr/core/project.rb +8 -7
  53. data/lib/buildr/core/test.rb +51 -26
  54. data/lib/buildr/core/transports.rb +22 -38
  55. data/lib/buildr/core/util.rb +78 -26
  56. data/lib/buildr/groovy.rb +18 -0
  57. data/lib/buildr/groovy/bdd.rb +105 -0
  58. data/lib/buildr/groovy/compiler.rb +138 -0
  59. data/lib/buildr/ide/eclipse.rb +102 -71
  60. data/lib/buildr/ide/idea.rb +7 -12
  61. data/lib/buildr/ide/idea7x.rb +7 -8
  62. data/lib/buildr/java.rb +4 -7
  63. data/lib/buildr/java/ant.rb +26 -5
  64. data/lib/buildr/java/bdd.rb +449 -0
  65. data/lib/buildr/java/commands.rb +9 -9
  66. data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
  67. data/lib/buildr/java/jruby.rb +29 -11
  68. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  69. data/lib/buildr/java/packaging.rb +23 -16
  70. data/lib/buildr/java/pom.rb +1 -1
  71. data/lib/buildr/java/rjb.rb +21 -8
  72. data/lib/buildr/java/test_result.rb +308 -0
  73. data/lib/buildr/java/tests.rb +324 -0
  74. data/lib/buildr/packaging/artifact.rb +12 -11
  75. data/lib/buildr/packaging/artifact_namespace.rb +7 -4
  76. data/lib/buildr/packaging/gems.rb +3 -3
  77. data/lib/buildr/packaging/zip.rb +13 -10
  78. data/lib/buildr/resources/buildr.icns +0 -0
  79. data/lib/buildr/scala.rb +19 -0
  80. data/lib/buildr/scala/compiler.rb +109 -0
  81. data/lib/buildr/scala/tests.rb +203 -0
  82. data/rakelib/apache.rake +71 -45
  83. data/rakelib/doc.rake +2 -2
  84. data/rakelib/package.rake +3 -2
  85. data/rakelib/rspec.rake +23 -21
  86. data/rakelib/setup.rake +34 -9
  87. data/rakelib/stage.rake +4 -1
  88. data/spec/addon/cobertura_spec.rb +77 -0
  89. data/spec/addon/emma_spec.rb +120 -0
  90. data/spec/addon/test_coverage_spec.rb +255 -0
  91. data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
  92. data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
  93. data/spec/core/build_spec.rb +415 -0
  94. data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
  95. data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
  96. data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
  97. data/spec/core/generate_spec.rb +33 -0
  98. data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
  99. data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
  100. data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
  101. data/spec/groovy/bdd_spec.rb +80 -0
  102. data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
  103. data/spec/ide/eclipse_spec.rb +243 -0
  104. data/spec/{java_spec.rb → java/ant.rb} +7 -17
  105. data/spec/java/bdd_spec.rb +358 -0
  106. data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
  107. data/spec/java/java_spec.rb +88 -0
  108. data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
  109. data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
  110. data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
  111. data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
  112. data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
  113. data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
  114. data/spec/sandbox.rb +22 -5
  115. data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
  116. data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
  117. data/spec/spec_helpers.rb +38 -17
  118. metadata +93 -70
  119. data/lib/buildr/java/bdd_frameworks.rb +0 -265
  120. data/lib/buildr/java/groovyc.rb +0 -137
  121. data/lib/buildr/java/test_frameworks.rb +0 -450
  122. data/spec/build_spec.rb +0 -193
  123. data/spec/java_bdd_frameworks_spec.rb +0 -238
  124. data/spec/spec.opts +0 -6
Binary file
@@ -1,37 +1,22 @@
1
1
  h1. Artifacts
2
2
 
3
- In Buildr, almost everything is a file or a file task. You compile source files
4
- that come from the file system using dependencies found on the file system,
5
- generating even more files. But how do you get these dependencies to start
6
- with, and how do you share them with others?
3
+ 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?
7
4
 
8
- Artifacts. We designed Buildr to work as a drop-in replacement for Maven 2.0,
9
- and share artifacts through the same local and remote repositories. Artifact
10
- tasks know how to download a file from one of the remote repositories, and
11
- install it in the local repository, where Buildr can find it. Packages know how
12
- to create files and upload them to remote repositories.
5
+ 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.
13
6
 
14
- We'll get into all of that in a second, but first, let's introduce the artifact
15
- specification. It's a simple string that takes one of two forms:
7
+ 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:
16
8
 
17
9
  {{{
18
10
  group:id:type:version
19
11
  group:id:type:classifier:version
20
12
  }}}
21
13
 
22
- For example, @'org.apache.axis2:axis2:jar:1.2'@ refers to an artifact with
23
- group identifier org.apache.axis2, artifact identifier axis2, a JAR file with
24
- version 1.2. Classifiers are typically used to distinguish between similar
25
- file types, for example, a source distribution and a binary distribution that
26
- otherwise have the same identifier and are both ZIP files.
14
+ 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.
27
15
 
28
16
 
29
17
  h2. Specifying Artifacts
30
18
 
31
- If your Buildfile spells out @'org.apache.axis2:axis2:jar:1.2'@ more than once,
32
- you're doing something wrong. Repeating the same string over and over will
33
- make your code harder to maintain. You'll know that when you upgrade to a new
34
- version in one place, forget to do it in another, and end up with a mismatch.
19
+ 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.
35
20
 
36
21
  You can use Ruby's syntax to do simple string substitution, for example:
37
22
 
@@ -41,8 +26,7 @@ AXIS_VERSION = '1.2'
41
26
  compile.with "org.apache.axis2:axis2:jar:#{AXIS_VERSION}"
42
27
  }}}
43
28
 
44
- Better yet, you can define all your artifacts at the top of the Buildfile and
45
- use constants to reference them in your project definition. For example:
29
+ 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:
46
30
 
47
31
  {{{!ruby
48
32
  AXIS2 = 'org.apache.axis2:axis2:jar:1.2'
@@ -50,25 +34,18 @@ AXIS2 = 'org.apache.axis2:axis2:jar:1.2'
50
34
  compile.with AXIS2
51
35
  }}}
52
36
 
53
- Note that we're not using a separate constant for the version number. In our
54
- experience, it's unnecessary. The version number intentionally appears at the
55
- end of the string, where it stands out easily.
37
+ 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.
56
38
 
57
- If you have a set of artifacts that belong to the same group and version, and
58
- that's quite common, you can use the @group@ shortcut:
39
+ 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:
59
40
 
60
41
  {{{!ruby
61
42
  AXIOM = group('axiom-api', 'axiom-impl', 'axiom-dom',
62
43
  :under=>'org.apache.ws.commons.axiom', :version=>'1.2.4')
63
44
  }}}
64
45
 
65
- p(note). Buildr projects also define a @group@ attribute which can lead to
66
- some confusion. If you want to define an artifact group within a project
67
- definition, you should use the explicit qualifier @Buildr::group@.
46
+ 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@.
68
47
 
69
- If you have several artifacts you always use together, consider placing them in
70
- an array. Methods that accept lists of artifacts also accept arrays. For
71
- example:
48
+ 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:
72
49
 
73
50
  {{{!ruby
74
51
  OPENJPA = ['org.apache.openjpa:openjpa-all:jar:0.9.7',
@@ -78,8 +55,7 @@ AXIS_OF_WS = [AXIS2, AXIOM]
78
55
  compile.with OPENJPA, AXIS_OF_WS
79
56
  }}}
80
57
 
81
- Another way to group related artifacts together and access them individually is
82
- using the @struct@ shortcut. For example:
58
+ Another way to group related artifacts together and access them individually is using the @struct@ shortcut. For example:
83
59
 
84
60
  {{{!ruby
85
61
  JAVAX = struct(
@@ -91,23 +67,17 @@ JAVAX = struct(
91
67
  compile.with JAVAX.persistence, OPENJPA
92
68
  }}}
93
69
 
94
- In our experience, using constants in this manner makes your Buildfile much
95
- easier to write and maintain.
70
+ In our experience, using constants in this manner makes your Buildfile much easier to write and maintain.
96
71
 
97
- And, of course, you can always place your artifact specifications in a separate
98
- file and require it into your Buildfile. For example, if you're working on
99
- several different projects that all share the same artifacts:
72
+ 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:
100
73
 
101
74
  {{{!ruby
102
75
  require '../shared/artifacts'
103
76
  }}}
104
77
 
105
- When you use @require@, Ruby always looks for a filename with the @.rb@
106
- extension, so in this case it expects to find @artifacts.rb@ in the @shared@
107
- directory.
78
+ 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.
108
79
 
109
- One last thing. You can also treat artifact specifications as hashes. For
110
- example:
80
+ One last thing. You can also treat artifact specifications as hashes. For example:
111
81
 
112
82
  {{{!ruby
113
83
  AXIS = { :group=>'org.apache.axis2', :id=>'axis2', :version=>'1.2' }
@@ -120,22 +90,15 @@ puts compile.dependencies.first.to_hash
120
90
 
121
91
  h2. Specifying Repositories
122
92
 
123
- Buildr can download artifacts for you, but only if you tell it where to find
124
- them. You need to specify at least one remote repository, from which to
125
- download these artifacts.
93
+ 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.
126
94
 
127
- When you call @repositories.remote@, you get an array of URLs for the various
128
- remote repositories. Initially, it's an empty array, to which you can add new
129
- repositories. For example:
95
+ 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:
130
96
 
131
97
  {{{!ruby
132
98
  repositories.remote << 'http://www.ibiblio.org/maven2/'
133
99
  }}}
134
100
 
135
- If you need to use a proxy server to access remote repositories, you can set
136
- the environment variable @HTTP_PROXY@ to the proxy server URL. You can also
137
- work without a proxy for certain hosts by specifying the @NO_PROXY@ environment
138
- variable. For example:
101
+ 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. You can also work without a proxy for certain hosts by specifying the @NO_PROXY@ environment variable. For example:
139
102
 
140
103
  {{{!sh
141
104
  $ export HTTP_PROXY = 'http://myproxy:8080'
@@ -150,27 +113,17 @@ options.proxy.exclude << '*.mycompany.com'
150
113
  options.proxy.exclude << 'localhost'
151
114
  }}}
152
115
 
153
- All the artifacts download into the local repository. Since all your projects
154
- share the same local repository, you only need to download each artifact once.
155
- Buildr was designed to be used alongside Maven 2.0, for example, when migrating
156
- projects from Maven 2.0 over to Buildr. By default it will share the same
157
- local repository, expecting the repository to be the @.m2/repository@ directory
158
- inside your home directory.
116
+ 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.
159
117
 
160
- You can choose to relocate the local repository by giving it a different path,
161
- for example:
118
+ You can choose to relocate the local repository by giving it a different path, for example:
162
119
 
163
120
  {{{!ruby
164
121
  repositories.local = '/usr/local/maven/repository'
165
122
  }}}
166
123
 
167
- That's one change you don't want to commit into the Buildfile, so the best
168
- place to do it is in your home directory's @buildr.rb@ file.
124
+ That's one change you don't want to commit into the Buildfile, so the best place to do it is in your home directory's @buildr.rb@ file.
169
125
 
170
- Buildr downloads artifacts when it needs to use them, for example, to compile a
171
- project. You don't need to download artifacts directly. Except when you do,
172
- for example, if you want to download all the latest artifacts and then go
173
- off-line. It's as simple as:
126
+ 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:
174
127
 
175
128
  {{{!sh
176
129
  $ buildr artifacts
@@ -179,35 +132,20 @@ $ buildr artifacts
179
132
 
180
133
  h2. Downloading Artifacts
181
134
 
182
- Within your buildfile you can download artifacts directly by invoking them, for
183
- example:
135
+ Within your buildfile you can download artifacts directly by invoking them, for example:
184
136
 
185
137
  {{{!ruby
186
138
  artifact('org.apache.openjpa:openjpa-all:jar:0.9.7').invoke
187
139
  artifacts(OPENJPA).each(&:invoke)
188
140
  }}}
189
141
 
190
- When you let Buildr download artifacts for you, or by invoking the artifact
191
- task yourself, it scans through the remote repositories assuming each
192
- repository follows the Maven 2 structure. Starting from the root repository
193
- URL, it will look for each artifact using the path
194
- @group/id/version/id-version.type@ (or ...@/id-version-classifier.type@). The
195
- group identifier becomes a path by turning periods (@.@) into slashes (@/@).
196
- So to find @org.apache.axis2:axis2:jar:1.2@, we're going to look for
197
- @org/apache/axis2/axis2/1.2/axis2-1.2.jar@.
142
+ 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@.
198
143
 
199
- You'll find a lot of open source Java libraries in public repositories that
200
- support this structure (for example, the "Ibiblio
201
- Maven":http://www.ibiblio.org/maven2/ repository). And, of course, every
202
- remote repository you setup for your projects.
144
+ 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.
203
145
 
204
- But there are exceptions to the rule. Say we want to download the Dojo widget
205
- library and use it in our project. It's available from the Dojo Web site, but
206
- that site doesn't follow the Maven repository conventions, so our feeble
207
- attempt to use existing remote repositories will fail.
146
+ 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.
208
147
 
209
- We can still treat Dojo as an artifact, by telling Buildr where to download it
210
- from:
148
+ We can still treat Dojo as an artifact, by telling Buildr where to download it from:
211
149
 
212
150
  {{{!ruby
213
151
  DOJO = '0.2.2'
@@ -216,90 +154,45 @@ url = "http://download.dojotoolkit.org/release-#{DOJO}/dojo-#{DOJO}-widget.zip"
216
154
  download(artifact("dojo:dojo:zip:widget:#{DOJO}")=>url)
217
155
  }}}
218
156
 
219
- Explaining how it works is tricky, skip if you don't care for the details. On
220
- the other hand, it will give you a better understanding of Buildr/Rake, so if
221
- not now, come back and read it later.
222
-
223
- We use the @artifact@ method to create an @Artifact@ task that references the
224
- Dojo widget in our local repository. The @Artifact@ task is a file task with
225
- some additional behavior added by Buildr. When you call @compile.with@, that's
226
- exactly what it does internally, turning each of your artifact specifications
227
- into an @Artifact@ task.
228
-
229
- But the @Artifact@ task doesn't know how to download the Dojo widget, only how
230
- to handle conventional repositories. So we're going to create a download task
231
- as well. We use the @download@ method to create a file task that downloads the
232
- file from a remote URL. (Of course, it will only download the file if it
233
- doesn't already exist.)
234
-
235
- But which task gets used when? We could have defined these tasks separately
236
- and used some glue code to make one use the other. Instead, we call @download@
237
- with the results of @artifact@. Essentially, we're telling @download@ to use
238
- the same file path as @artifact@. So now we have two file tasks that point to
239
- the very same file. We wired them together.
240
-
241
- You can't have more than one task pointing to the same file. Rake's rule of
242
- the road. What Rake does is merge the tasks together, creating a single file
243
- task for @artifact@, and then enhancing it with another action from @download@.
244
- One task, two actions. Statistically, we've doubled the odds that at least one
245
- of these actions will manage to download the Dojo widget and install it in the
246
- local repository.
247
-
248
- Since we ordered the calls to @artifact@ first and @download@ second, we know
249
- the actions will execute in that order. But @artifact@ is slightly devilish:
250
- when its action runs, it adds another action to the end of the list. So the
251
- @artifact@ action runs first, adds an action at the end, the @download@ action
252
- runs second, and downloads the Dojo widget for us. The second @artifact@
253
- action runs last, but checks that the file already exist and doesn't try to
254
- download it again.
157
+ 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.
158
+
159
+ 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.
160
+
161
+ 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.)
162
+
163
+ 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.
164
+
165
+ 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.
166
+
167
+ 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.
255
168
 
256
169
  Magic.
257
170
 
258
171
 
259
172
  h2. Install and Upload
260
173
 
261
- Generally you use artifacts that download from remote repositories into the
262
- local repository, or artifacts packaged by the project itself (see
263
- "Packaging":packaging.html), which are then installed into the local repository
264
- and uploaded to the release server.
174
+ 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.
265
175
 
266
- Some artifacts do not fall into either category. In this example we're going
267
- to download a ZIP file, extract a JAR file from it, and use that JAR file as an
268
- artifact. We would then expect to install this JAR in the local repository and
269
- upload it to the release server, where it can be shared with other projects.
176
+ 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.
270
177
 
271
- So let's start by creating a task that downloads the ZIP, and another one to
272
- extract it and create the JAR file:
178
+ So let's start by creating a task that downloads the ZIP, and another one to extract it and create the JAR file:
273
179
 
274
180
  {{{!ruby
275
181
  app_zip = download('target/app.zip'=>url)
276
182
  bean_jar = file('target/app/bean.jar'=>unzip('target/app'=>app_zip))
277
183
  }}}
278
184
 
279
- When you call @artifact@, it returns an @Artifact@ task that points to the
280
- artifact file in the local repository, downloading the file if it doesn't
281
- already exist. You can override this behavior by enhancing the task and
282
- creating the file yourself (you may also want to create a POM file). Or much
283
- simpler, call the @from@ method on the artifact and tell it where to find the
284
- source file.
185
+ 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.
285
186
 
286
- So the next step is to specify the artifact and tell it to use the extracted
287
- JAR file:
187
+ So the next step is to specify the artifact and tell it to use the extracted JAR file:
288
188
 
289
189
  {{{!ruby
290
190
  bean = artifact('example.com:beans:jar:1.0').from(bean_jar)
291
191
  }}}
292
192
 
293
- The artifact still points to the local repository, but when we invoke the task
294
- it copies the source file over to the local repository, instead of attempting a
295
- download.
193
+ 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.
296
194
 
297
- Use the @install@ method if you want the artifact and its POM installed in the
298
- local repository when you run the @install@ task. Likewise, use the @upload@
299
- method if you want the artifact uploaded to the release server when you run the
300
- @upload@ task. You do not need to do this on artifacts downloaded from a
301
- remote server, or created with the @package@ method, the later are
302
- automatically added to the list of installed/uploaded artifacts.
195
+ 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.
303
196
 
304
197
  Our example ends by including the artifact in the @install@ and @upload@ tasks:
305
198
 
@@ -308,10 +201,7 @@ install bean
308
201
  upload bean
309
202
  }}}
310
203
 
311
- p(tip). Calling the @install@ (and likewise @upload@) method on an artifact
312
- does not install the artifact, it simply adds a task that will execute when you
313
- run @buildr install@. If you need to download and install an artifact, invoke
314
- the task directly with @install(<artifact>).invoke@.
204
+ 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@.
315
205
 
316
206
 
317
207
  Next we're going to "package some artifacts":packaging.html.
@@ -1,73 +1,29 @@
1
1
  h1. Building
2
2
 
3
- To remove any confusion, Buildr's build task is actually called @build@. It's
4
- also the default task that executes when you run @buildr@ without any task
5
- name.
3
+ 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.
6
4
 
7
- The @build@ task runs two other tasks: @compile@ and its associated tasks (that
8
- would be, @resources@) and @test@ and its associated tasks (@test:compile@,
9
- @test:setup@ and friends). We'll talk about @compile@ more in this section,
10
- and @test@ later on. We'll also show you how to run @build@ without testing,
11
- not something we recommend, but a necessary feature.
5
+ 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.
12
6
 
13
- Why @build@ and not @compile@? Some projects do more than just compiling.
14
- Other projects don't compile at all, but perform other build tasks, for
15
- example, creating a database schema or command line scripts. So we want you to
16
- get in the practice of running the @build@ task, and help you by making it the
17
- default task.
7
+ 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.
18
8
 
19
9
 
20
10
  h2. Compiling
21
11
 
22
- Each project has its own @compile@ task you can invoke directly, by running
23
- @buildr compile@ or as part of another build task. (Yes, that @build@).
24
-
25
- The @compile@ task looks for source files in well known directories, determines
26
- which compiler to use, and sets the target directory accordingly. For example,
27
- if it finds any Java source files in the @src/main/java@ directory, it selects
28
- the Javac compiler and generates bytecode in the @target/classes@ directories.
29
- If it finds Scala source files in the @src/main/scala@ directory it selects the
30
- Scalac compiler, and so forth.
31
- A single project cannot use multiple compilers at the same time, hence you may
32
- prefer creating subprojects by programming language.
33
- Some compilers like Groovy's are joint-compilers, this means they can handle
34
- several languages. When the Groovy compiler is selected for a project, .groovy
35
- and .java files are compiled by groovyc.
36
-
37
- Most often, that's just good enough and the only change you need to make is
38
- adding compile dependencies. You can use @compile.dependencies@ to get the
39
- array of dependency file tasks. For Java, each of these tasks points to a JAR
40
- or a directory containing Java classes, and the entire set of dependencies is
41
- passed to Javac as the classpath.
42
-
43
- Buildr uses file tasks to handle dependencies, but here we're talking about the
44
- Rake dependency mechanism. It's a double entendre. It invokes these tasks
45
- before running the compiler. Some of these tasks will download JARs from
46
- remote repositories, others will create them by compiling and packaging from a
47
- different project. Using file task ensures all the dependencies exist before
48
- the compiler can use them.
49
-
50
- An easier way to specify dependencies is by calling the @compile.with@ method.
51
- It takes a list of arguments and adds them to the dependency list. The
52
- @compile.with@ method is easier to use, it accepts several type of
53
- dependencies. You can use file names, file tasks, projects, artifacts
54
- specifications and even pass arrays of dependencies.
55
-
56
- Most dependencies fall into the last three categories. When you pass a project
57
- to @compile.with@, it picks up all the packages created by that project. In
58
- doing so, it establishes an order of dependency between the two projects (see
59
- "Defining the Project":projects.html#defining_the_project). For example, if
60
- you make a change in project _teh-api_ and build _teh-impl_, Buildr will detect
61
- that change, recompile and package _teh-api_ before compiling _teh-impl_. You
62
- can also select a specific package using the @package@ or @packages@ methods
63
- (see "Packaging":packaging.html).
64
-
65
- When you pass an artifact specification to @compile.with@, it creates an
66
- @Artifact@ task that will download that artifact from one of the remote
67
- repositories, install it in the local repository, and use it in your project.
68
- Rake's dependency mechanism is used here to make sure the artifact is
69
- downloaded once, when needed. Check the "Artifacts":artifacts.html section for
70
- more information about artifact specification and repositories.
12
+ 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@).
13
+
14
+ 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.
15
+
16
+ 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.
17
+
18
+ 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.
19
+
20
+ 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.
21
+
22
+ 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.
23
+
24
+ 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_the_project). 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 @package@ or @packages@ methods (see "Packaging":packaging.html).
25
+
26
+ 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.
71
27
 
72
28
  For now let's just show a simple example:
73
29
 
@@ -76,28 +32,17 @@ compile.with 'org.apache.axis2:axis2:jar:1.2',
76
32
  'org.apache.derby:derby:jar:10.1.2.1', projects('teh-api', 'teh-impl')
77
33
  }}}
78
34
 
79
- Passing arrays to @compile.with@ is just a convenient for handling multiple
80
- dependencies, we'll show more examples of that when we talk about
81
- "Artifacts":#artifacts.
35
+ 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.
82
36
 
83
- Likewise, the @compile@ task has an array of file tasks that point at the
84
- source directories you want to compile from. You can access that array by
85
- calling @compile.sources@. You can use @compile.from@ to add new source
86
- directories by passing a file name or a file task.
37
+ 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.
87
38
 
88
- For example, let's run the APT tool on our annotated source code before
89
- compiling it:
39
+ For example, let's run the APT tool on our annotated source code before compiling it:
90
40
 
91
41
  {{{!ruby
92
42
  compile.from apt
93
43
  }}}
94
44
 
95
- When you call @apt@ on a project, it returns a file task that points to the
96
- @target/generated/apt@ directory. This file task executes by running APT,
97
- using the same list of source directories, dependencies and compiler options.
98
- It then generates new source files in the target directory. Calling
99
- @compile.from@ with that file task includes those additional source files in
100
- the list of compiled sources.
45
+ 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.
101
46
 
102
47
  Here's another example:
103
48
 
@@ -106,30 +51,13 @@ jjtree = jjtree(_('src/main/jjtree'), :in_package=>'com.acme')
106
51
  compile.from javacc(jjtree, :in_package=>'com.acme'), jjtree
107
52
  }}}
108
53
 
109
- This time, the variable @jjtree@ is a file task that reads a JJTree source file
110
- from the @src/main/jjtree@ directory, and generates additional source files in
111
- the @target/generated/jjtree@ directory. The second line creates another file
112
- task that takes those source files, runs JavaCC on them, and generates yet more
113
- source files in @target/generated/javacc@. Finally, we include both sets of
114
- source files in addition to those already in @src/main/java@, and compile the
115
- lot.
116
-
117
- The interesting thing about these two examples is how you're wiring file tasks
118
- together to create more complicated tasks, piping the output of one task into
119
- the inputs of another. Wiring tasks this way is the most common way to handle
120
- complex builds, and uses Rake's dependency mechanism to only run tasks when it
121
- detects a change to one of the source files.
122
-
123
- You can also control the target directory. Use @compile.target@ to get the
124
- target directory file task. If you need to change the target directory, call
125
- the @compile.into@ method with the new path.
126
-
127
- We use method pairs to give you finer control over the compiler, but also a way
128
- to easily configure it. Methods like @dependencies@ and @sources@ give you a
129
- live array you can manipulate, or iterate over. On the other hand, methods
130
- like @with@ and @from@ accept a wider set of arguments and clean them up for
131
- you. They also all return the same task you're calling, so you can chain
132
- methods together.
54
+ 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.
55
+
56
+ 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.
57
+
58
+ 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.
59
+
60
+ 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.
133
61
 
134
62
  For example:
135
63
 
@@ -138,24 +66,17 @@ compile.from('srcs').with('org.apache.axis2:axis2:jar:1.2').
138
66
  into('classes').using(:target=>'1.4')
139
67
  }}}
140
68
 
141
- Buildr uses the method pair and method chaining idiom in many places to make
142
- your life easier without sacrificing flexibility.
69
+ Buildr uses the method pair and method chaining idiom in many places to make your life easier without sacrificing flexibility.
143
70
 
144
- Occasionally, you'll need to post-process the generated bytecode. Since you
145
- only want to do that after compiling, and let the compiler decide when to do
146
- that – only when changes require re-compiling – you'll want to extend the
147
- @compile@ task. You can do that by calling @compile@ with a block.
71
+ 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.
148
72
 
149
- For example, to run the OpenJPA bytecode enhancer after compiling the source
150
- files:
73
+ For example, to run the OpenJPA bytecode enhancer after compiling the source files:
151
74
 
152
75
  {{{!ruby
153
76
  compile { open_jpa_enhance }
154
77
  }}}
155
78
 
156
- You can change various compile options by calling, you guessed,
157
- @compile.options@. For example, to set the compiler to VM compatibility with
158
- Java 1.5 and turn on all Lint messages:
79
+ 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:
159
80
 
160
81
  {{{!ruby
161
82
  compile.options.target = '1.5'
@@ -168,18 +89,12 @@ Or, if you want to chain methods together:
168
89
  compile.using :target=>'1.5', :lint=>'all'
169
90
  }}}
170
91
 
171
- Sub-projects inherit compile options from their parent project, so you only
172
- need to change these settings once in the top project. You can do so, even if
173
- the top project itself doesn't compile anything.
174
92
 
175
- The options available to you depend on which compiler you are using for this
176
- particular project, obviously the options are not the same for Java and Flash.
177
- Two options are designed to work consistently across compilers.
93
+ 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.
94
+
95
+ 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.
178
96
 
179
- Buildr turns the @warning@ option on by default, but turns it off when you run
180
- @buildr --silent@. It also sets the @debug@ option on, but turns it off when
181
- making a release. You can also control the @debug@ option from the command
182
- line, for example:
97
+ 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:
183
98
 
184
99
  {{{!ruby
185
100
  # When calling buildr
@@ -190,147 +105,22 @@ $ export DEBUG=off
190
105
  $ buildr compile
191
106
  }}}
192
107
 
193
-
194
- h3. Compiling Java
195
-
196
- The Java compiler looks for source files in the project's @src/main/java@
197
- directory, and defaults to compiling them into the @target/classes@ directory.
198
- It looks for test cases in the project's @src/test/java@ and defaults to
199
- compile them into the @target/test/classes@ directory.
200
-
201
- If you point the @compile@ task at any other source directory, it will use the
202
- Java compiler if any of these directories contains files with the extension
203
- @.java@.
204
-
205
- When using the Java compiler, if you don't specify the packaging type, it
206
- defaults to JAR. If you don't specify the test framework, it defaults to
207
- JUnit.
208
-
209
- The Java compiler supports the following options:
210
-
211
- |_. Option |_. Usage |
212
- | @:debug@ | Generates bytecode with debugging information. You can
213
- also override this by setting the environment variable @debug@ to @off@. |
214
- | @:deprecation@ | If true, shows deprecation messages. False by default. |
215
- | @:lint@ | Defaults to false. Set this option to true to use all lint
216
- options, or specify a specific lint option (e.g. @:lint=>'cast'@). |
217
- | @:other@ | Array of options passed to the compiler (e.g.
218
- @:other=>'-implicit:none'@). |
219
- | @:source@ | Source code compatibility (e.g. '1.5'). |
220
- | @:target@ | Bytecode compatibility (e.g. '1.4'). |
221
- | @:warnings@ | Issue warnings when compiling. True when running in
222
- verbose mode. |
223
-
224
-
225
- h3. Compiling Scala
226
-
227
- Before using the Scala compiler, you must first set the environment variable
228
- @SCALA_HOME@.
229
-
230
- The Scala compiler looks for source files in the project's @src/main/scala@
231
- directory, and defaults to compiling them into the @target/classes@ directory.
232
- It looks for test cases in the project's @src/test/scala@ and defaults to
233
- compile them into the @target/test/classes@ directory.
234
-
235
- If you point the @compile@ task at any other source directory, it will use the
236
- Scala compiler if any of these directories contains files with the extension
237
- @.scala@.
238
-
239
- When using the Scala compiler, if you don't specify the packaging type, it
240
- defaults to JAR.
241
-
242
- The Scala compiler supports the following options:
243
-
244
- |_. Option |_. Usage |
245
- | @:debug@ | Generates bytecode with debugging information. You can
246
- also override this by setting the environment variable @debug@ to @off@. |
247
- | @:deprecation@ | If true, shows deprecation messages. False by default. |
248
- | @:optimise@ | Generates faster bytecode by applying optimisations to the
249
- program. |
250
- | @:other@ | Array of options passed to the compiler (e.g.
251
- @:other=>'-Xprint-types'@). |
252
- | @:target@ | Bytecode compatibility (e.g. '1.4'). |
253
- | @:warnings@ | Issue warnings when compiling. True when running in verbose
254
- mode. |
255
-
256
- You may use @fsc@, the Fast Scala Compiler, which submits compilation jobs to a
257
- compilation daemon, by setting the environment variable @USE_FSC@ to @yes@. Note
258
- that @fsc@ _may_ cache class libraries -- don't forget to run @fsc -reset@ if you
259
- upgrade a library.
260
-
261
-
262
- h3. Compiling Groovy
263
-
264
- Before using the Groovy compiler, you must first require it on your buildfile:
265
-
266
- {{{!ruby
267
- require 'buildr/java/groovyc'
268
- }}}
269
-
270
- Once loaded, the groovyc compiler will be automatically selected if any .groovy
271
- source files are found under @src/main/groovy@ directory, compiling them by
272
- default into the @target/classes@ directory.
273
-
274
- If the project has java sources in @src/main/java@ they will get compiled using
275
- the groovyc joint compiler.
276
-
277
- Sources found in @src/test/groovy@ are compiled into the @target/test/classes@.
278
-
279
- If you don't specify the packaging type, it defaults to JAR.
280
-
281
- The Groovy compiler supports the following options:
282
-
283
- |_. Option |_. Usage |
284
- | @encoding@ | Encoding of source files. |
285
- | @verbose@ | Asks the compiler for verbose output, true when running
286
- in verbose mode. |
287
- | @fork@ | Whether to execute groovyc using a spawned instance of
288
- the JVM. Defaults to no. |
289
- | @memoryInitialSize@ | The initial size of the memory for the underlying VM,
290
- if using fork mode, ignored otherwise. Defaults to the standard VM memory
291
- setting. (Examples: @83886080@, @81920k@, or @80m@) |
292
- | @memoryMaximumSize@ | The maximum size of the memory for the underlying VM,
293
- if using fork mode, ignored otherwise. Defaults to the standard VM memory
294
- setting. (Examples: @83886080@, @81920k@, or @80m@) |
295
- | @listfiles@ | Indicates whether the source files to be compiled will
296
- be listed. Defaults to no. |
297
- | @stacktrace@ | If true each compile error message will contain a
298
- stacktrace. |
299
- | @warnings@ | Issue warnings when compiling. True when running in
300
- verbose mode. |
301
- | @debug@ | Generates bytecode with debugging information. Set
302
- from the debug environment variable/global option. |
303
- | @deprecation@ | If true, shows deprecation messages. False by default. |
304
- | @optimise@ | Generates faster bytecode by applying optimisations to
305
- the program. |
306
- | @source@ | Source code compatibility. |
307
- | @target@ | Bytecode compatibility. |
308
- | @javac@ | Hash of options passed to the ant javac task. |
108
+ 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.
309
109
 
310
110
 
311
111
  h2. Resources
312
112
 
313
- The @compile@ task comes bundled with a @resources@ task. It copies files from
314
- the @src/main/resources@ directory into @target/resources@. Best used for
315
- copying files that you want to included in the generated code, like
316
- configuration files, i18n messages, images, etc.
317
113
 
318
- The @resources@ task uses a filter that can change files as it copies them from
319
- source to destination. The most common use is by mapping values using a hash.
320
- For example, to substitute "${version}" for the project's version number and
321
- "${copyright}" for "Acme Inc (C) 2007" :
114
+ 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 included in the generated code, like configuration files, i18n messages, images, etc.
115
+
116
+ 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" :
322
117
 
323
118
  {{{!ruby
324
119
  resources.filter.using 'version'=>version,
325
120
  'copyright'=>'Acme Inc (C) 2007'
326
121
  }}}
327
122
 
328
-
329
- You can also use "profiles":settings_profiles.html#profiles to supply a
330
- name/value map that all @resources@ task should default to, by adding a
331
- @filter@ element to each of the profiles. The following examples shows a
332
- @profiles.yaml@ file that applies the same filter in development and test
333
- environments:
123
+ 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:
334
124
 
335
125
  {{{!yaml
336
126
  filter: &alpha1
@@ -343,15 +133,13 @@ test:
343
133
  filter: *alpha1
344
134
  }}}
345
135
 
346
- You can specify a different format by passing it as the first argument.
347
- Supported formats include:
136
+ You can specify a different format by passing it as the first argument. Supported formats include:
348
137
 
349
138
  |_. Format |_. Usage |
350
139
  | @:ant@ | Map from <code>@key@</code> to value. |
351
140
  | @:maven@ | Map from @${key}@ to value (default). |
352
141
  | @:ruby@ | Map from @#{key}@ to value. |
353
- | @Regexp@ | Map using the matched value of the regular expression (e.g.
354
- @/=(.*?)=/@). |
142
+ | @Regexp@ | Map using the matched value of the regular expression (e.g. @/=(.*?)=/@). |
355
143
 
356
144
  For example, using the @:ruby@ format instead of the default @:maven@ format:
357
145
 
@@ -360,18 +148,15 @@ resources.filter.using :ruby, 'version'=>version,
360
148
  'copyright'=>'Acme Inc (C) 2007'
361
149
  }}}
362
150
 
363
- For more complicated mapping you can also pass a method or a proc. The filter
364
- will call it once for each file with the file name and content.
151
+ 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.
365
152
 
366
- If you need to copy resource files from other directories, add these source
367
- directories by calling the @from@ method, for example:
153
+ If you need to copy resource files from other directories, add these source directories by calling the @from@ method, for example:
368
154
 
369
155
  {{{!ruby
370
156
  resources.from _('src/etc')
371
157
  }}}
372
158
 
373
- You can select to copy only specific files using common file matching patterns.
374
- For example, to include only HTML files:
159
+ You can select to copy only specific files using common file matching patterns. For example, to include only HTML files:
375
160
 
376
161
  {{{!ruby
377
162
  resources.include '*.html'
@@ -383,19 +168,11 @@ To include all files, except for files in the @scratch@ directory:
383
168
  resources.exclude 'scratch/*'
384
169
  }}}
385
170
 
386
- The filter always excludes the @CVS@ and @.svn@ directories, and all files
387
- ending with @.bak@ or @~@, so no need to worry about these.
171
+ The filter always excludes the @CVS@ and @.svn@ directories, and all files ending with @.bak@ or @~@, so no need to worry about these.
388
172
 
389
- A file pattern can match any file name or part of a file name using an asterisk
390
- (@*@). Double asterisk (@**@) matches directories recursively, for example,
391
- @'src/main/java/**/*.java'@. You can match any character using a question mark
392
- (@?@), or a set of characters using square brackets (@[]@), similar to regular
393
- expressions, for example, @'[Rr]eadme'@. You can also match from a set of names
394
- using curly braces (@{}@), for example, @'*.{html,css}'@.
173
+ 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}'@.
395
174
 
396
- You can use filters elsewhere. The @filter@ method creates a filter, the
397
- @into@ method sets the target directory, and @using@ specifies the mapping.
398
- Last, you call @run@ on the filter to activate it.
175
+ 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.
399
176
 
400
177
  For example:
401
178
 
@@ -404,45 +181,25 @@ filter('src/specs').into('target/specs').
404
181
  using('version'=>version, 'created'=>Time.now).run
405
182
  }}}
406
183
 
407
- The @resources@ task is, in fact, just a wrapper around such a filter that
408
- automatically adds the @src/main/resources@ directory as one of the source
409
- directories.
184
+ 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.
410
185
 
411
186
 
412
187
  h2. More On Building
413
188
 
414
- The @build@ task runs the @compile@ (and @resources@) tasks as prerequisites,
415
- followed by any actions you add to it, and completes by running the @test@
416
- task. The @build@ task itself is a prerequisite to other tasks, for example,
417
- @package@ and @upload@.
189
+ 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@.
418
190
 
419
- You can extend the @build@ task in two ways. You can add more prerequisites
420
- that will execute before the task itself, or you can add actions that will
421
- execute as part of the task. Which one you choose is up to you, we'll show you
422
- how they differ in a second. If you call @build@ with a list of tasks, it adds
423
- these tasks as prerequisites. Call @build@ with a block, and it adds that
424
- block as an action. Again, a common idiom you'll see elsewhere in Buildr and
425
- Rake.
191
+ 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.
426
192
 
427
- Let's look at a simple example. Say we want to generate a Derby database from
428
- an SQL file and include it in the ZIP package:
193
+ 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:
429
194
 
430
195
  {{{!ruby
431
196
  db = Derby.create(_('target/derby/db')=>_('src/main/sql/derby.sql'))
432
197
  package(:zip).include db
433
198
  }}}
434
199
 
435
- There's nothing fundamentally wrong with this code, if that's what you intend
436
- to do. But in practice, you don't always run the @package@ task during
437
- development, so you won't notice if something is wrong with this task when you
438
- build. For example, if it fails to generate the SQL file. In addition, the
439
- @package@ task runs after @build@, so you can't use the database in your test
440
- cases.
200
+ 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.
441
201
 
442
- So let's refactor it. We're going to use the variable @db@ to reference the
443
- file task that creates the database, and make it a prerequisite of the @build@
444
- task. And use that same variable again to include the database in the ZIP
445
- package:
202
+ 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:
446
203
 
447
204
  {{{!ruby
448
205
  db = Derby.create(_('target/derby/db')=>_('src/main/sql/derby.sql'))
@@ -450,17 +207,11 @@ build db
450
207
  package(:zip).include db
451
208
  }}}
452
209
 
453
- Much better. We're using the same task twice, but since we're using Rake here,
454
- it will only execute once. In fact, it will only execute if we don't already
455
- have a Derby database, or if it detects a change to the SQL file and needs to
456
- recreate the database.
210
+ 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.
457
211
 
458
- p(tip). @Derby.create@ is not part of Buildr, you can get
459
- "derby.rake":http://svn.apache.org/repos/asf/incubator/ode/trunk/tasks/derby.rake
460
- here.
212
+ p(tip). @Derby.create@ is not part of Buildr, you can get "derby.rake":http://svn.apache.org/repos/asf/incubator/ode/trunk/tasks/derby.rake here.
461
213
 
462
- Here's another example. We want to copy some files over as part of the build,
463
- and apply a filter to them. This time, we're going to extend the @build@ task:
214
+ 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:
464
215
 
465
216
  {{{!ruby
466
217
  build do
@@ -469,21 +220,14 @@ build do
469
220
  end
470
221
  }}}
471
222
 
472
- The @build@ task is recursive, so running @buildr build@ picks the current
473
- project and runs its @build@ task, which in turn runs the @build@ task on each
474
- of its sub-projects. One @build@ task to rule them all.
223
+ 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.
475
224
 
476
225
 
477
226
  h2. Cleaning
478
227
 
479
- The @build@ task has an evil twin, the @clean@ task. It's the task you use to
480
- remove all the files created during the build, especially when you mess things
481
- up and want to start all over.
228
+ 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.
482
229
 
483
- It basically erases the target directories, the one called @target@, and if you
484
- get creative and change the target directory for tasks like @compile@, it will
485
- also erase those. If you decide to generate files outside the target directory
486
- and want to cleanup after yourself, just extend the @clean@ task.
230
+ 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.
487
231
 
488
232
  For example:
489
233
 
@@ -491,10 +235,6 @@ For example:
491
235
  clean { rm_rf _('staged') }
492
236
  }}}
493
237
 
494
- The @rm_rf@ method deletes the directory and all files in it. It's named after
495
- UNIX's infamous @rm -rf@. Use it wisely. This is also a good time to
496
- introduce you to @FileUtils@, a standard Ruby library that contains convenient
497
- methods for creating and deleting directories, copying and moving files, even
498
- comparing two files. They're all free of charge when you use Buildr.
238
+ 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.
499
239
 
500
240
  Now let's "talk about the artifacts":artifacts.html we mentioned before.