buildr 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +66 -4
- data/{README → README.rdoc} +29 -16
- data/Rakefile +16 -20
- data/_buildr +38 -0
- data/addon/buildr/cobertura.rb +49 -45
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +585 -661
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +21 -14
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/pages/artifacts.textile +46 -156
- data/doc/pages/building.textile +63 -323
- data/doc/pages/contributing.textile +112 -102
- data/doc/pages/download.textile +19 -27
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +44 -119
- data/doc/pages/index.textile +26 -47
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +71 -239
- data/doc/pages/projects.textile +58 -233
- data/doc/pages/recipes.textile +19 -43
- data/doc/pages/settings_profiles.textile +39 -104
- data/doc/pages/testing.textile +41 -304
- data/doc/pages/troubleshooting.textile +29 -47
- data/doc/pages/whats_new.textile +69 -167
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/site.haml +1 -0
- data/doc/site.toc.yaml +8 -5
- data/{KEYS → etc/KEYS} +0 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +2 -5
- data/lib/buildr/core/application.rb +192 -98
- data/lib/buildr/core/build.rb +140 -91
- data/lib/buildr/core/checks.rb +5 -5
- data/lib/buildr/core/common.rb +1 -1
- data/lib/buildr/core/compile.rb +12 -10
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -9
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +51 -26
- data/lib/buildr/core/transports.rb +22 -38
- data/lib/buildr/core/util.rb +78 -26
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide/eclipse.rb +102 -71
- data/lib/buildr/ide/idea.rb +7 -12
- data/lib/buildr/ide/idea7x.rb +7 -8
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +9 -9
- data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
- data/lib/buildr/java/jruby.rb +29 -11
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/packaging.rb +23 -16
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/rjb.rb +21 -8
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/packaging/artifact.rb +12 -11
- data/lib/buildr/packaging/artifact_namespace.rb +7 -4
- data/lib/buildr/packaging/gems.rb +3 -3
- data/lib/buildr/packaging/zip.rb +13 -10
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +71 -45
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +3 -2
- data/rakelib/rspec.rake +23 -21
- data/rakelib/setup.rake +34 -9
- data/rakelib/stage.rake +4 -1
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +255 -0
- data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
- data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
- data/spec/core/build_spec.rb +415 -0
- data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/core/generate_spec.rb +33 -0
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
- data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/{java_spec.rb → java/ant.rb} +7 -17
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
- data/spec/java/java_spec.rb +88 -0
- data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
- data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
- data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
- data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
- data/spec/sandbox.rb +22 -5
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
- data/spec/spec_helpers.rb +38 -17
- metadata +103 -70
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/lib/buildr/java/test_frameworks.rb +0 -450
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
data/doc/pages/projects.textile
CHANGED
@@ -2,17 +2,11 @@ h1. Projects
|
|
2
2
|
|
3
3
|
h2. Starting Out
|
4
4
|
|
5
|
-
In Java, most projects are built the same way: compile source code, run test
|
6
|
-
cases, package the code, release it. Rinse, repeat.
|
5
|
+
In Java, most projects are built the same way: compile source code, run test cases, package the code, release it. Rinse, repeat.
|
7
6
|
|
8
|
-
Feed it a project definition, and Buildr will set up all these tasks for you.
|
9
|
-
The only thing you need to do is specify the parts that are specific to your
|
10
|
-
project, like the classpath dependencies, whether you're packaging a JAR or a
|
11
|
-
WAR, etc.
|
7
|
+
Feed it a project definition, and Buildr will set up all these tasks for you. The only thing you need to do is specify the parts that are specific to your project, like the classpath dependencies, whether you're packaging a JAR or a WAR, etc.
|
12
8
|
|
13
|
-
The remainder of this guide deals with what it takes to build a project. But
|
14
|
-
first, let's pick up a sample project to work with. We'll call it
|
15
|
-
_killer-app_:
|
9
|
+
The remainder of this guide deals with what it takes to build a project. But first, let's pick up a sample project to work with. We'll call it _killer-app_:
|
16
10
|
|
17
11
|
{{{!ruby
|
18
12
|
require 'buildr'
|
@@ -60,131 +54,45 @@ define 'killer-app' do
|
|
60
54
|
end
|
61
55
|
}}}
|
62
56
|
|
63
|
-
A project definition requires four pieces of information: the project name,
|
64
|
-
group identifier, version number and base directory. The project name ... do
|
65
|
-
we need to explain why its necessary? The group identifier and version number
|
66
|
-
are used for packaging and deployment, we'll talk more about that in the
|
67
|
-
"Packaging":packaging.html section. The base directory lets you find files
|
68
|
-
inside the project.
|
57
|
+
A project definition requires four pieces of information: the project name, group identifier, version number and base directory. The project name ... do we need to explain why its necessary? The group identifier and version number are used for packaging and deployment, we'll talk more about that in the "Packaging":packaging.html section. The base directory lets you find files inside the project.
|
69
58
|
|
70
|
-
Everything else depends on what that particular project is building. And it
|
71
|
-
all goes inside the project definition block, the piece of code that comes
|
72
|
-
between @define <name> .. do@ and @end@.
|
59
|
+
Everything else depends on what that particular project is building. And it all goes inside the project definition block, the piece of code that comes between @define <name> .. do@ and @end@.
|
73
60
|
|
74
61
|
|
75
62
|
h2. The Directory Structure
|
76
63
|
|
77
|
-
Buildr follows a convention we picked from years of working with Apache
|
78
|
-
projects.
|
64
|
+
Buildr follows a convention we picked from years of working with Apache projects.
|
79
65
|
|
80
|
-
Java projects are laid out so the source files are in the @src/main/java@
|
81
|
-
directory and compile into the @target/classes@ directory. Resource files go
|
82
|
-
in the @src/main/resources@ directory, and copied over to @target/resources@.
|
83
|
-
Likewise, tests come from @src/test/java@ and @src/test/resources@, and end
|
84
|
-
life in @target/test/classes@ and @target/test/resources@, respectively.
|
66
|
+
Java projects are laid out so the source files are in the @src/main/java@ directory and compile into the @target/classes@ directory. Resource files go in the @src/main/resources@ directory, and copied over to @target/resources@. Likewise, tests come from @src/test/java@ and @src/test/resources@, and end life in @target/test/classes@ and @target/test/resources@, respectively.
|
85
67
|
|
86
|
-
WAR packages pick up additional files from the aptly named @src/main/webapp@.
|
87
|
-
And most stuff, including generated source files are parked under the @target@
|
88
|
-
directory. Test cases and such may generate reports in the, you guessed it,
|
89
|
-
@reports@ directory.
|
68
|
+
WAR packages pick up additional files from the aptly named @src/main/webapp@. And most stuff, including generated source files are parked under the @target@ directory. Test cases and such may generate reports in the, you guessed it, @reports@ directory.
|
90
69
|
|
91
|
-
Other languages will use different directories, but following the same general
|
92
|
-
conventions. For example, Scala code compiles from the @src/main/scala@
|
93
|
-
directory, RSpec tests are found in the @src/test/rspec@ directory, and Flash
|
94
|
-
will compile to @target/flash@. Throughout this document we will show examples
|
95
|
-
using mostly Java, but you can imagine how this pattern applies to other
|
96
|
-
languages.
|
70
|
+
Other languages will use different directories, but following the same general conventions. For example, Scala code compiles from the @src/main/scala@ directory, RSpec tests are found in the @src/test/rspec@ directory, and Flash will compile to @target/flash@. Throughout this document we will show examples using mostly Java, but you can imagine how this pattern applies to other languages.
|
97
71
|
|
98
|
-
When projects grow big, you split them into smaller projects by nesting
|
99
|
-
projects inside each other. Each sub-project has a sub-directory under the
|
100
|
-
parent project and follows the same internal directory structure. You can, of
|
101
|
-
course, change all of that to suite your needs, but if you follow these
|
102
|
-
conventions, Buildr will figure all the paths for you.
|
72
|
+
When projects grow big, you split them into smaller projects by nesting projects inside each other. Each sub-project has a sub-directory under the parent project and follows the same internal directory structure. You can, of course, change all of that to suite your needs, but if you follow these conventions, Buildr will figure all the paths for you.
|
103
73
|
|
104
|
-
Going back to the example above, the directory structure
|
74
|
+
Going back to the example above, the directory structure will look something like this:
|
105
75
|
|
106
|
-
|
107
|
-
./buildfile <- Top of the world (killer-app)
|
108
|
-
|
|
109
|
-
|__ teh-api
|
110
|
-
| |__ src
|
111
|
-
| | |__ main
|
112
|
-
| | |__ java <- Java sources
|
113
|
-
| |
|
114
|
-
| |__ target <- JAR goes here
|
115
|
-
| | |__ classes <- Generated bytecode
|
116
|
-
| |__ reports <- From test cases,
|
117
|
-
| |__ junit <- like JUnit
|
118
|
-
|
|
119
|
-
|__ teh-impl
|
120
|
-
| |__ src
|
121
|
-
| | |__ main
|
122
|
-
| | | |__ java
|
123
|
-
| | | |__ resources
|
124
|
-
| | |__ test
|
125
|
-
| | |__ java
|
126
|
-
| |
|
127
|
-
| |__ target
|
128
|
-
| | |__ classes
|
129
|
-
| |__ reports
|
130
|
-
|
|
131
|
-
|__ la-web
|
132
|
-
| |__ src
|
133
|
-
| | |__ main
|
134
|
-
| | |__ webapp <- Webapp files
|
135
|
-
| |
|
136
|
-
| |__ target <- The WAR goes here
|
137
|
-
|
|
138
|
-
|__ reports
|
139
|
-
|__ junit <- For all test cases
|
140
|
-
}}}
|
76
|
+
p=. !images/project-structure.png!
|
141
77
|
|
142
|
-
Notice the @buildfile@ at the top. That's your project build script, the one
|
143
|
-
Buildr runs.
|
78
|
+
Notice the @buildfile@ at the top. That's your project build script, the one Buildr runs.
|
144
79
|
|
145
|
-
When you run the @buildr@ command, it picks up the @buildfile@ (which here
|
146
|
-
we'll just call _Buildfile_) from the current directory, or if not there, from
|
147
|
-
the closest parent directory. So you can run @buildr@ from any directory
|
148
|
-
inside your project, and it will always pick up the same Buildfile. That also
|
149
|
-
happens to be the base directory for the top project. If you have any
|
150
|
-
sub-projects, Buildr assumes they reflect sub-directories under their parent.
|
80
|
+
When you run the @buildr@ command, it picks up the @buildfile@ (which here we'll just call _Buildfile_) from the current directory, or if not there, from the closest parent directory. So you can run @buildr@ from any directory inside your project, and it will always pick up the same Buildfile. That also happens to be the base directory for the top project. If you have any sub-projects, Buildr assumes they reflect sub-directories under their parent.
|
151
81
|
|
152
|
-
And yes, you can have two top projects in the same Buildfile. For example, you
|
153
|
-
can use that to have one project that groups all the application modules (JARs,
|
154
|
-
WARs, etc) and another project that groups all the distribution packages
|
155
|
-
(binary, sources, javadocs).
|
82
|
+
And yes, you can have two top projects in the same Buildfile. For example, you can use that to have one project that groups all the application modules (JARs, WARs, etc) and another project that groups all the distribution packages (binary, sources, javadocs).
|
156
83
|
|
157
|
-
When you start with a new project you won't see the @target@ or @reports@
|
158
|
-
directories. Buildr creates these when it needs to. Just know that they're
|
159
|
-
there.
|
84
|
+
When you start with a new project you won't see the @target@ or @reports@ directories. Buildr creates these when it needs to. Just know that they're there.
|
160
85
|
|
161
86
|
|
162
87
|
h2. Naming And Finding Projects
|
163
88
|
|
164
|
-
Each project has a given name, the first argument you pass when calling
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
can reference them from within the project using just the given name. In other
|
172
|
-
cases, you'll need to use the full name. The full name is just @parent:child@.
|
173
|
-
So if you wanted to refer to _teh-impl_, you could do so with either
|
174
|
-
@project('killer-app:teh-impl')@ or
|
175
|
-
@project('killer-app').project('teh-impl')@.
|
176
|
-
|
177
|
-
The @project@ method is convenient when you have a dependency from one project
|
178
|
-
to another, e.g. using the other project in the classpath, or accessing one of
|
179
|
-
its source files. Call it with a project name and it will return that object
|
180
|
-
or raise an error. You can also call it with no arguments and it will return
|
181
|
-
the project itself. It's syntactic sugar that's useful when accessing project
|
182
|
-
properties.
|
183
|
-
|
184
|
-
The @projects@ method takes a list of names and returns a list of projects. If
|
185
|
-
you call it with no arguments on a project, it returns all its sub-projects.
|
186
|
-
If you call it with no argument in any other context, it returns all the
|
187
|
-
projects defined so far.
|
89
|
+
Each project has a given name, the first argument you pass when calling @define@. The project name is just a string, but we advise to stay clear of colon (@:@) and slashes (@/@ and @\@), which could conflict with other task and file names. Also, avoid using common Buildr task names, don't pick @compile@ or @build@ for your project name.
|
90
|
+
|
91
|
+
Since each project knows its parent project, child projects and siblings, you can reference them from within the project using just the given name. In other cases, you'll need to use the full name. The full name is just @parent:child@. So if you wanted to refer to _teh-impl_, you could do so with either @project('killer-app:teh-impl')@ or @project('killer-app').project('teh-impl')@.
|
92
|
+
|
93
|
+
The @project@ method is convenient when you have a dependency from one project to another, e.g. using the other project in the classpath, or accessing one of its source files. Call it with a project name and it will return that object or raise an error. You can also call it with no arguments and it will return the project itself. It's syntactic sugar that's useful when accessing project properties.
|
94
|
+
|
95
|
+
The @projects@ method takes a list of names and returns a list of projects. If you call it with no arguments on a project, it returns all its sub-projects. If you call it with no argument in any other context, it returns all the projects defined so far.
|
188
96
|
|
189
97
|
Let's illustrate this with a few examples:
|
190
98
|
|
@@ -214,11 +122,7 @@ $ buildr help:projects
|
|
214
122
|
|
215
123
|
h2. Running Project Tasks
|
216
124
|
|
217
|
-
Most times, you run tasks like @build@ or @package@ that operate on the current
|
218
|
-
project and recursively on its sub-projects. The "current project" is the one
|
219
|
-
that uses the current working directory. So if you're in the @la-web/src@
|
220
|
-
directory looking at source files, _la-web_ is the current project. For
|
221
|
-
example:
|
125
|
+
Most times, you run tasks like @build@ or @package@ that operate on the current project and recursively on its sub-projects. The "current project" is the one that uses the current working directory. So if you're in the @la-web/src@ directory looking at source files, _la-web_ is the current project. For example:
|
222
126
|
|
223
127
|
{{{!sh
|
224
128
|
# build killer-app and all its sub-projects
|
@@ -233,8 +137,7 @@ $ cd ../la-web
|
|
233
137
|
$ buildr package
|
234
138
|
}}}
|
235
139
|
|
236
|
-
You can use the project's full name to invoke one of its tasks directly, and it
|
237
|
-
doesn't matter which directory you're in. For example:
|
140
|
+
You can use the project's full name to invoke one of its tasks directly, and it doesn't matter which directory you're in. For example:
|
238
141
|
|
239
142
|
{{{!sh
|
240
143
|
# build killer-app and all its sub-projects
|
@@ -247,8 +150,7 @@ $ buildr killer-app:teh-impl:test
|
|
247
150
|
$ buildr killer-app:la-web:package
|
248
151
|
}}}
|
249
152
|
|
250
|
-
Buildr provides the following tasks that you can run on the current project, or
|
251
|
-
on a specific project by prefixing them with the project's full name:
|
153
|
+
Buildr provides the following tasks that you can run on the current project, or on a specific project by prefixing them with the project's full name:
|
252
154
|
|
253
155
|
{{{
|
254
156
|
clean # Clean files generated during a build
|
@@ -268,15 +170,11 @@ To see a list of all the tasks provided by Buildr:
|
|
268
170
|
$ buildr help:tasks
|
269
171
|
}}}
|
270
172
|
|
271
|
-
|
272
173
|
h2. Setting Project Properties
|
273
174
|
|
274
|
-
We mentioned the group identifier, version number and base directory. These
|
275
|
-
are project properties. There are a few more properties we'll cover later on.
|
175
|
+
We mentioned the group identifier, version number and base directory. These are project properties. There are a few more properties we'll cover later on.
|
276
176
|
|
277
|
-
There are two ways to set project properties. You can pass them as a hash when
|
278
|
-
you call @define@, or use accessors to set them on the project directly. For
|
279
|
-
example:
|
177
|
+
There are two ways to set project properties. You can pass them as a hash when you call @define@, or use accessors to set them on the project directly. For example:
|
280
178
|
|
281
179
|
{{{!ruby
|
282
180
|
define 'silly', :version=>'1.0' do
|
@@ -289,28 +187,16 @@ puts project('silly').group
|
|
289
187
|
=> acme
|
290
188
|
}}}
|
291
189
|
|
292
|
-
Project properties are inherited. You can specify them once in the parent
|
293
|
-
project, and they'll have the same value in all its sub-projects. In the
|
294
|
-
example, we only specify the version number once, for use in all sub-projects.
|
190
|
+
Project properties are inherited. You can specify them once in the parent project, and they'll have the same value in all its sub-projects. In the example, we only specify the version number once, for use in all sub-projects.
|
295
191
|
|
296
192
|
|
297
193
|
h2. Resolving Paths
|
298
194
|
|
299
|
-
You can run @buildr@ from any directory in your project. To keep tasks
|
300
|
-
consistent and happy, it switches over to the Buildfile directory and executes
|
301
|
-
all the tasks from there, before returning back to your working directory.
|
302
|
-
Your tasks can all rely on relative paths that start from the same directory as
|
303
|
-
the Buildfile.
|
195
|
+
You can run @buildr@ from any directory in your project. To keep tasks consistent and happy, it switches over to the Buildfile directory and executes all the tasks from there, before returning back to your working directory. Your tasks can all rely on relative paths that start from the same directory as the Buildfile.
|
304
196
|
|
305
|
-
But in practice, you'll want to use the @path_to@ method. This method
|
306
|
-
calculates a path relative to the project, a better way if you ever need to
|
307
|
-
refactor your code, say turn a ad hoc task into a function you reuse.
|
197
|
+
But in practice, you'll want to use the @path_to@ method. This method calculates a path relative to the project, a better way if you ever need to refactor your code, say turn a ad hoc task into a function you reuse.
|
308
198
|
|
309
|
-
The @path_to@ method takes an array of strings and concatenates them into a
|
310
|
-
path. Absolute paths are returned as they are, relative paths are expanded
|
311
|
-
relative to the project's base directory. Slashes, if you don't already know,
|
312
|
-
work very well on both Windows, Linux and OS/X. And as a shortcut, you can use
|
313
|
-
@_@.
|
199
|
+
The @path_to@ method takes an array of strings and concatenates them into a path. Absolute paths are returned as they are, relative paths are expanded relative to the project's base directory. Slashes, if you don't already know, work very well on both Windows, Linux and OS X. And as a shortcut, you can use @_@.
|
314
200
|
|
315
201
|
For example:
|
316
202
|
|
@@ -328,17 +214,9 @@ project('teh-impl')._('src/main/java')
|
|
328
214
|
|
329
215
|
h2. Defining The Project
|
330
216
|
|
331
|
-
The project definition itself gives you a lot of pre-canned tasks to start
|
332
|
-
with, but that's not enough to build a project. You need to specify what gets
|
333
|
-
built and how, which dependencies to use, the packages you want to create and
|
334
|
-
so forth. You can configure existing tasks, extend them to do additional work,
|
335
|
-
and create new tasks. All that magic happens inside the project definition
|
336
|
-
block.
|
217
|
+
The project definition itself gives you a lot of pre-canned tasks to start with, but that's not enough to build a project. You need to specify what gets built and how, which dependencies to use, the packages you want to create and so forth. You can configure existing tasks, extend them to do additional work, and create new tasks. All that magic happens inside the project definition block.
|
337
218
|
|
338
|
-
Since the project definition executes each time you run Buildr, you don't want
|
339
|
-
to perform any work directly inside the project definition block. Rather, you
|
340
|
-
want to use it to specify how different build task work when you invoke them.
|
341
|
-
Here's an example to illustrate the point:
|
219
|
+
Since the project definition executes each time you run Buildr, you don't want to perform any work directly inside the project definition block. Rather, you want to use it to specify how different build task work when you invoke them. Here's an example to illustrate the point:
|
342
220
|
|
343
221
|
{{{!ruby
|
344
222
|
define 'silly' do
|
@@ -350,40 +228,17 @@ define 'silly' do
|
|
350
228
|
end
|
351
229
|
}}}
|
352
230
|
|
353
|
-
Each time you run Buildr, it will execute the project definition and print out
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
the
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
Executing a project definition will also execute all its sub-projects'
|
365
|
-
definitions. And, of course, all project definitions are executed once the
|
366
|
-
Buildfile loads, so Buildr can determine how to execute each of the build
|
367
|
-
tasks.
|
368
|
-
|
369
|
-
If this sounds a bit complex, don't worry. In reality, it does the right
|
370
|
-
thing. A simple rule to remember is that each project definition is executed
|
371
|
-
before you need it, lazy evaluation of sort. The reason we do that? So you
|
372
|
-
can write projects that depend on each other without worrying about their
|
373
|
-
order.
|
374
|
-
|
375
|
-
In our example, the _la-web_ project depends on packages created by the
|
376
|
-
_teh-api_ and _teh-impl_ projects, the later requiring _teh-api_ to compile.
|
377
|
-
That example is simple enough that we ended up specifying the projects in order
|
378
|
-
of dependency. But you don't always want to do that. For large projects, you
|
379
|
-
may want to group sub-projects by logical units, or sort them alphabetically
|
380
|
-
for easier editing.
|
381
|
-
|
382
|
-
One project can reference another ahead of its definition. If Buildr detects a
|
383
|
-
cyclic dependency, it will let you know.
|
384
|
-
|
385
|
-
In this example we define one project in terms of another, using the same
|
386
|
-
dependencies, so we only need to specify them once:
|
231
|
+
Each time you run Buildr, it will execute the project definition and print out "Running buildr". We also extend the @build@ task, and whenever we run it, it will print "Building silly". Incidentally, @build@ is the default task, so if you run Buildr with no arguments, it will print both messages while executing the build. If you run Buildr with a different task, say @clean@, it will only print the first message.
|
232
|
+
|
233
|
+
The @define@ method gathers the project definition, but does not execute it immediately. It executes the project definition the first time you reference that project, directly or indirectly, for example, by calling @project@ with that project's name, or calling @projects@ to return a list of all projects. Executing a project definition will also execute all its sub-projects' definitions. And, of course, all project definitions are executed once the Buildfile loads, so Buildr can determine how to execute each of the build tasks.
|
234
|
+
|
235
|
+
If this sounds a bit complex, don't worry. In reality, it does the right thing. A simple rule to remember is that each project definition is executed before you need it, lazy evaluation of sort. The reason we do that? So you can write projects that depend on each other without worrying about their order.
|
236
|
+
|
237
|
+
In our example, the _la-web_ project depends on packages created by the _teh-api_ and _teh-impl_ projects, the later requiring _teh-api_ to compile. That example is simple enough that we ended up specifying the projects in order of dependency. But you don't always want to do that. For large projects, you may want to group sub-projects by logical units, or sort them alphabetically for easier editing.
|
238
|
+
|
239
|
+
One project can reference another ahead of its definition. If Buildr detects a cyclic dependency, it will let you know.
|
240
|
+
|
241
|
+
In this example we define one project in terms of another, using the same dependencies, so we only need to specify them once:
|
387
242
|
|
388
243
|
{{{!ruby
|
389
244
|
define 'bar' do
|
@@ -397,53 +252,23 @@ end
|
|
397
252
|
|
398
253
|
One last thing to remember. Actually three, but they all go hand in hand.
|
399
254
|
|
400
|
-
*Self is project* Each of these project definition blocks executes in the
|
401
|
-
context of that project, just as if it was a method defined on the project. So
|
402
|
-
when you call the @compile@ method, you're essentially calling that method on
|
403
|
-
the current project: @compile@, @self.compile@ and @project.compile@ are all
|
404
|
-
the same.
|
255
|
+
*Self is project* Each of these project definition blocks executes in the context of that project, just as if it was a method defined on the project. So when you call the @compile@ method, you're essentially calling that method on the current project: @compile@, @self.compile@ and @project.compile@ are all the same.
|
405
256
|
|
406
|
-
*Blocks are closures* The project definition is also a closure, which can
|
407
|
-
reference variables from enclosing scopes. You can use that, for example, to
|
408
|
-
define constants, variables and even functions in your Buildfile, and reference
|
409
|
-
them from your project definition. As you'll see later on, in the
|
410
|
-
"Artifacts":#artifacts section, it will save you a lot of work.
|
257
|
+
*Blocks are closures* The project definition is also a closure, which can reference variables from enclosing scopes. You can use that, for example, to define constants, variables and even functions in your Buildfile, and reference them from your project definition. As you'll see later on, in the "Artifacts":#artifacts section, it will save you a lot of work.
|
411
258
|
|
412
|
-
*Projects are namespaces* While executing the project definition, Buildr
|
413
|
-
switches the namespace to the project name. If you define the task "do-this"
|
414
|
-
inside the _teh-impl_ project, the actual task name is
|
415
|
-
"killer-app:teh-impl:do-this". Likewise, the @compile@ task is actually
|
416
|
-
"killer-app:teh-impl:compile".
|
259
|
+
*Projects are namespaces* While executing the project definition, Buildr switches the namespace to the project name. If you define the task "do-this" inside the _teh-impl_ project, the actual task name is "killer-app:teh-impl:do-this". Likewise, the @compile@ task is actually "killer-app:teh-impl:compile".
|
417
260
|
|
418
|
-
From outside the project you can reference a task by its full name, either
|
419
|
-
@task('foo:do')@ or @project('foo').task('do')@. If you need to reference a
|
420
|
-
task defined outside the project from within the project, prefix it with
|
421
|
-
"rake:", for example, @task('rake:globally-defined')@.
|
261
|
+
From outside the project you can reference a task by its full name, either @task('foo:do')@ or @project('foo').task('do')@. If you need to reference a task defined outside the project from within the project, prefix it with "rake:", for example, @task('rake:globally-defined')@.
|
422
262
|
|
423
263
|
|
424
264
|
h2. Writing Your Own Tasks
|
425
265
|
|
426
|
-
Of all the features Buildr provide, it doesn't have a task for making coffee.
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
source code for the @compile@ method, you'll find that it's little more than a
|
436
|
-
shortcut for @task('compile')@.
|
437
|
-
|
438
|
-
Another shortcut is the @file@ method. When you call @file@ on a project,
|
439
|
-
Buildr uses the @path_to@ method to expand relative paths using the project's
|
440
|
-
base directory. If you call @file('src')@ on _teh-impl_, it will return you a
|
441
|
-
file task that points at the @teh-impl/src@ directory.
|
442
|
-
|
443
|
-
In the current implementation projects are also created as tasks, although you
|
444
|
-
don't invoke these tasks directly. That's the reason for not using a project
|
445
|
-
name that conflicts with an existing task name. If you do that, you'll find
|
446
|
-
quick enough, as the task will execute each time you run Buildr.
|
447
|
-
|
448
|
-
So now that you know everything about projects and tasks, let's go and "build
|
449
|
-
some code":building.html.
|
266
|
+
Of all the features Buildr provide, it doesn't have a task for making coffee. Yet. If you need to write your own tasks, you get all the power of Rake: you can use regular tasks, file tasks, task rules and even write your own custom task classes. Check out the "Rake documentation":http://docs.rubyrake.org/ for more information.
|
267
|
+
|
268
|
+
We mentioned projects as namespaces before. When you call @task@ on a project, it finds or defines the task using the project namespace. So given a project object, @task('do-this')@ will return it's "do-this" task. If you lookup the source code for the @compile@ method, you'll find that it's little more than a shortcut for @task('compile')@.
|
269
|
+
|
270
|
+
Another shortcut is the @file@ method. When you call @file@ on a project, Buildr uses the @path_to@ method to expand relative paths using the project's base directory. If you call @file('src')@ on _teh-impl_, it will return you a file task that points at the @teh-impl/src@ directory.
|
271
|
+
|
272
|
+
In the current implementation projects are also created as tasks, although you don't invoke these tasks directly. That's the reason for not using a project name that conflicts with an existing task name. If you do that, you'll find quick enough, as the task will execute each time you run Buildr.
|
273
|
+
|
274
|
+
So now that you know everything about projects and tasks, let's go and "build some code":building.html.
|
data/doc/pages/recipes.textile
CHANGED
@@ -5,32 +5,25 @@ Commond recipes for Buildr, collected from the mailing list.
|
|
5
5
|
|
6
6
|
h2. Creating a classpath
|
7
7
|
|
8
|
-
For Java, the classpath argument is simply a list of paths joined with an
|
9
|
-
OS-specific path separator:
|
8
|
+
For Java, the classpath argument is simply a list of paths joined with an OS-specific path separator:
|
10
9
|
|
11
10
|
{{{!ruby
|
12
11
|
cp = paths.join(File::PATH_SEPARATOR)
|
13
12
|
}}}
|
14
13
|
|
15
|
-
This assumes @paths@ points to files and/or directories, but what if you have a
|
16
|
-
list of artifact specifications? You can turn those into file names in two
|
17
|
-
steps. First, use @artifacts@ to return a list of file tasks that point to the
|
18
|
-
local repository:
|
14
|
+
This assumes @paths@ points to files and/or directories, but what if you have a list of artifact specifications? You can turn those into file names in two steps. First, use @artifacts@ to return a list of file tasks that point to the local repository:
|
19
15
|
|
20
16
|
{{{!ruby
|
21
17
|
tasks = Buildr.artifacts(specs)
|
22
18
|
}}}
|
23
19
|
|
24
|
-
Next, map that list of tasks into list of file names (essentially calling
|
25
|
-
@name@ on each task):
|
20
|
+
Next, map that list of tasks into list of file names (essentially calling @name@ on each task):
|
26
21
|
|
27
22
|
{{{!ruby
|
28
23
|
paths = tasks.map(&:name)
|
29
24
|
}}}
|
30
25
|
|
31
|
-
This works as long as the artifacts are already in your local repository,
|
32
|
-
otherwise they can't be found, but you can ask Buildr to download them by
|
33
|
-
calling @invoke@ on each of these tasks:
|
26
|
+
This works as long as the artifacts are already in your local repository, otherwise they can't be found, but you can ask Buildr to download them by calling @invoke@ on each of these tasks:
|
34
27
|
|
35
28
|
{{{!ruby
|
36
29
|
tasks = Buildr.artifacts(specs).each(&:invoke)
|
@@ -45,9 +38,7 @@ cp = Buildr.artifacts(specs).each(&:invoke).map(&:name).join(File::PATH_SEPARATO
|
|
45
38
|
|
46
39
|
h2. Keeping your Profiles.yaml file DRY
|
47
40
|
|
48
|
-
YAML allows you to use anchors (@&@), similar to ID attributes in XML, and
|
49
|
-
reference them later on (@*@). For example, if you have two profiles that are
|
50
|
-
identical, you can tell YAML that one is an alias for the other:
|
41
|
+
YAML allows you to use anchors (@&@), similar to ID attributes in XML, and reference them later on (@*@). For example, if you have two profiles that are identical, you can tell YAML that one is an alias for the other:
|
51
42
|
|
52
43
|
{{{!yaml
|
53
44
|
development: &common
|
@@ -57,8 +48,7 @@ test: *common
|
|
57
48
|
production: *common
|
58
49
|
}}}
|
59
50
|
|
60
|
-
If you have two elements that are almost identical, you can merge the values of
|
61
|
-
one element into another (@<<@), for example:
|
51
|
+
If you have two elements that are almost identical, you can merge the values of one element into another (@<<@), for example:
|
62
52
|
|
63
53
|
{{{!yaml
|
64
54
|
development: &common
|
@@ -72,9 +62,7 @@ test:
|
|
72
62
|
|
73
63
|
h2. Speeding JRuby
|
74
64
|
|
75
|
-
When using JRuby you will notice that Buildr takes a few seconds to start up.
|
76
|
-
To speed it up, we recommend switching to Java 1.6 and running the JVM in
|
77
|
-
client mode:
|
65
|
+
When using JRuby you will notice that Buildr takes a few seconds to start up. To speed it up, we recommend switching to Java 1.6 and running the JVM in client mode:
|
78
66
|
|
79
67
|
{{{!
|
80
68
|
$ export JAVA_OPTS=-client
|
@@ -83,45 +71,33 @@ $ export JAVA_OPTS=-client
|
|
83
71
|
|
84
72
|
h2. Continuous Integration with Atlassian Bamboo
|
85
73
|
|
86
|
-
This recipe outlines how to configure a new Bamboo project to use Buildr. The
|
87
|
-
following steps assume that you have logged-on to Bamboo as an Administrator.
|
74
|
+
This recipe outlines how to configure a new Bamboo project to use Buildr. The following steps assume that you have logged-on to Bamboo as an Administrator.
|
88
75
|
|
89
76
|
*1. Configure a Builder*
|
90
77
|
|
91
78
|
* Select the Administration tab from the Bamboo toolbar.
|
92
79
|
* Select the Builders area (first option) from the Administration menu.
|
93
|
-
* Using the Add Builder dialog, configure a custom builder for Buildr with the
|
94
|
-
following options:
|
80
|
+
* Using the Add Builder dialog, configure a custom builder for Buildr with the following options:
|
95
81
|
** Label: @buildr@
|
96
82
|
** Type: @Custom Command@
|
97
83
|
** Path: @/path/to/buildr@ (typically "/usr/bin/buildr")
|
98
84
|
|
99
85
|
*2. Create a Plan*
|
100
86
|
|
101
|
-
* Select the Create Plan tab from the Bamboo toolbar to enter the Create Plan
|
102
|
-
|
103
|
-
* In "
|
104
|
-
|
105
|
-
|
106
|
-
or
|
107
|
-
*
|
108
|
-
above, along with the following:
|
109
|
-
** Argument: @"test=all"@ (ensures that all tests are run through even if
|
110
|
-
failures are encountered)
|
111
|
-
** Test Results Directory: @"**/reports/junit/*.xml"@ (or your path to test
|
112
|
-
results, if different).
|
113
|
-
* The remaining wizard sections may be either skipped or configured with your
|
114
|
-
preferred settings.
|
87
|
+
* Select the Create Plan tab from the Bamboo toolbar to enter the Create Plan wizard.
|
88
|
+
* In "1. Plan Details", define your build plan including project name, project key, build plan name and build plan key.
|
89
|
+
* In "2. Source Repository", specify your source code repository settings (CVS or SVN).
|
90
|
+
* In "3. Builder Configuration", specify the "buildr" builder that you defined above, along with the following:
|
91
|
+
** Argument: @"test=all"@ (ensures that all tests are run through even if failures are encountered)
|
92
|
+
** Test Results Directory: @"**/reports/junit/*.xml"@ (or your path to test results, if different).
|
93
|
+
* The remaining wizard sections may be either skipped or configured with your preferred settings.
|
115
94
|
|
116
95
|
*3. Trigger a Build*
|
117
96
|
|
118
|
-
A build should occur automatically at the point of project creation. It can
|
119
|
-
also be manually triggered at any time
|
97
|
+
A build should occur automatically at the point of project creation. It can also be manually triggered at any time
|
120
98
|
|
121
|
-
* Navigate to the project summary page (located at:
|
122
|
-
@http://YOUR_BAMBOO_URL/browse/PROJECTKEY-YOURPLAN@).
|
99
|
+
* Navigate to the project summary page (located at: @http://YOUR_BAMBOO_URL/browse/PROJECTKEY-YOURPLAN@).
|
123
100
|
* Click on the small arrow to the left of the label "Build Actions"
|
124
101
|
* Select "Checkout and Build" from the pop-up menu to force a build.
|
125
102
|
|
126
|
-
The project page will contain full status information for previous builds and
|
127
|
-
the results tabs will integrate the results from your JUnit tests.
|
103
|
+
The project page will contain full status information for previous builds and the results tabs will integrate the results from your JUnit tests.
|