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
@@ -3,44 +3,19 @@ h1. More Stuff
|
|
3
3
|
|
4
4
|
h2. Using Gems
|
5
5
|
|
6
|
-
The purpose of the buildfile is to define your projects, and the various tasks
|
7
|
-
|
8
|
-
projects
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
all other Ruby applications you may have running. You can install a gem from a
|
20
|
-
local file, or download and install it from any number of remote repositories.
|
21
|
-
|
22
|
-
RubyGems is preconfigured to use the "RubyForge":http://rubyforge.org
|
23
|
-
repository. You'll find a large number of open source Ruby libraries there,
|
24
|
-
including Buildr itself and all its dependencies. RubyForge provides a free
|
25
|
-
account that you can use to host your projects and distribute your gems (you
|
26
|
-
can use RubyForge strictly for distribution, as we do with Buildr).
|
27
|
-
|
28
|
-
You can also set up your own private repository and use it instead or in
|
29
|
-
addition to RubyForge. Use the @gem sources@ command to add repositories, and
|
30
|
-
the @gem server@ command to run a remote repository. You can see all available
|
31
|
-
options by running @gem help@.
|
32
|
-
|
33
|
-
If your build depends on other gems, you will want to specify these
|
34
|
-
dependencies as part of your build and check that configuration into source
|
35
|
-
control. That way you can have a specific environment that will guarantee
|
36
|
-
repeatable builds, whether you're building a particular version, moving between
|
37
|
-
branches, or joining an existing project. Buildr will take care of installing
|
38
|
-
all the necessary dependencies, which you can then manage with the @gem@
|
39
|
-
command.
|
40
|
-
|
41
|
-
Use the @build.yaml@ file to specify these dependencies (see "Build
|
42
|
-
Settings":settings_profiles.html#build_settings for more information), for
|
43
|
-
example:
|
6
|
+
The purpose of the buildfile is to define your projects, and the various tasks and functions used for building them. Some of these are specific to your projects, others are more general in nature, and you may want to share them across projects.
|
7
|
+
|
8
|
+
There are several mechanisms for developing extensions and build features across projects which we cover in more details in the section "Extending Buildr":extending.html. Here we will talk about using extensions that are distributed in the form of RubyGems.
|
9
|
+
|
10
|
+
"RubyGems":http://rubygems.rubyforge.org provides the @gem@ command line tool that you can use to search, install, upgrade, package and distribute gems. It installs all gems into a local repository that is shared across your builds and all other Ruby applications you may have running. You can install a gem from a local file, or download and install it from any number of remote repositories.
|
11
|
+
|
12
|
+
RubyGems is preconfigured to use the "RubyForge":http://rubyforge.org repository. You'll find a large number of open source Ruby libraries there, including Buildr itself and all its dependencies. RubyForge provides a free account that you can use to host your projects and distribute your gems (you can use RubyForge strictly for distribution, as we do with Buildr).
|
13
|
+
|
14
|
+
You can also set up your own private repository and use it instead or in addition to RubyForge. Use the @gem sources@ command to add repositories, and the @gem server@ command to run a remote repository. You can see all available options by running @gem help@.
|
15
|
+
|
16
|
+
If your build depends on other gems, you will want to specify these dependencies as part of your build and check that configuration into source control. That way you can have a specific environment that will guarantee repeatable builds, whether you're building a particular version, moving between branches, or joining an existing project. Buildr will take care of installing all the necessary dependencies, which you can then manage with the @gem@ command.
|
17
|
+
|
18
|
+
Use the @build.yaml@ file to specify these dependencies (see "Build Settings":settings_profiles.html#build_settings for more information), for example:
|
44
19
|
|
45
20
|
{{{!yaml
|
46
21
|
# This project requires the following gems
|
@@ -52,52 +27,29 @@ gems:
|
|
52
27
|
- ci_reporter
|
53
28
|
}}}
|
54
29
|
|
55
|
-
Gems contain executable code, and for that reason Buildr will not install gems
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
When installing a gem for the first time, Buildr will automatically look for
|
68
|
-
the latest available version. You can specify a particular version number, or
|
69
|
-
a set of version numbers known to work with that build. You can use equality
|
70
|
-
operations to specify a range of versions, for example, @1.2.3@ to install only
|
71
|
-
version 1.2.3, and @=> 1.2.3@ to install version 1.2.3 or later.
|
72
|
-
|
73
|
-
You can also specify a range up to one version bump, for example, @~> 1.2.3@ is
|
74
|
-
the same as @>= 1.2.3 < 1.3.0@, and @~> 1.2@ is the same as @>= 1.2.0 < 2.0.0@.
|
75
|
-
If necessary, you can exclude a particular version number, for example, @~>
|
76
|
-
1.2.3 != 1.2.7@.
|
77
|
-
|
78
|
-
Buildr will install the latest version that matches the version requirement.
|
79
|
-
To keep up with newer versions, execute the @gem update@ command periodically.
|
80
|
-
You can also use @gem outdated@ to determine which new versions are available.
|
81
|
-
|
82
|
-
Most gems include documentation that you can access in several forms. You can
|
83
|
-
use the @ri@ command line tool to find out more about a class, module or
|
84
|
-
specific method. For example:
|
30
|
+
Gems contain executable code, and for that reason Buildr will not install gems without your permission. When you run a build that includes any dependencies that are not already installed on your machine, Buildr will ask for permission before installing them. On Unix-based operating systems, you will also need sudo privileges and will be asked for your password before proceeding.
|
31
|
+
|
32
|
+
Since this step requires your input, it will only happen when running Buildr interactively from the command line. In all other cases, Buildr will fail and report the missing dependencies. If you have an automated build environment, make sure to run the build once manually to install all the necessary dependencies.
|
33
|
+
|
34
|
+
When installing a gem for the first time, Buildr will automatically look for the latest available version. You can specify a particular version number, or a set of version numbers known to work with that build. You can use equality operations to specify a range of versions, for example, @1.2.3@ to install only version 1.2.3, and @=> 1.2.3@ to install version 1.2.3 or later.
|
35
|
+
|
36
|
+
You can also specify a range up to one version bump, for example, @~> 1.2.3@ is the same as @>= 1.2.3 < 1.3.0@, and @~> 1.2@ is the same as @>= 1.2.0 < 2.0.0@. If necessary, you can exclude a particular version number, for example, @~> 1.2.3 != 1.2.7@.
|
37
|
+
|
38
|
+
Buildr will install the latest version that matches the version requirement. To keep up with newer versions, execute the @gem update@ command periodically. You can also use @gem outdated@ to determine which new versions are available.
|
39
|
+
|
40
|
+
Most gems include documentation that you can access in several forms. You can use the @ri@ command line tool to find out more about a class, module or specific method. For example:
|
85
41
|
|
86
42
|
{{{!sh
|
87
43
|
$ ri Buildr::Jetty
|
88
44
|
$ ri Buildr::Jetty.start
|
89
45
|
}}}
|
90
46
|
|
91
|
-
You can also access documentation from a Web browser by running @gem server@
|
92
|
-
and pointing your browser to "http://localhost:8808":http://localhost:8808.
|
93
|
-
Note that after installing a new gem, you will need to restart the gem server
|
94
|
-
to see its documentation.
|
47
|
+
You can also access documentation from a Web browser by running @gem server@ and pointing your browser to "http://localhost:8808":http://localhost:8808. Note that after installing a new gem, you will need to restart the gem server to see its documentation.
|
95
48
|
|
96
49
|
|
97
50
|
h2. Using Java Libraries
|
98
51
|
|
99
|
-
Buildr runs along side a JVM, using either RJB or JRuby. The Java module
|
100
|
-
allows you to access Java classes and create Java objects.
|
52
|
+
Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows you to access Java classes and create Java objects.
|
101
53
|
|
102
54
|
Java classes are accessed as static methods on the @Java@ module, for example:
|
103
55
|
|
@@ -110,12 +62,9 @@ Java.java.lang.String.isInstance(str)
|
|
110
62
|
Java.com.sun.tools.javac.Main.compile(args)
|
111
63
|
}}}
|
112
64
|
|
113
|
-
The @classpath@ attribute allows Buildr to add JARs and directories to the
|
114
|
-
classpath, for example, we use it to load Ant and various Ant tasks, code
|
115
|
-
generators, test frameworks, and so forth.
|
65
|
+
The @classpath@ attribute allows Buildr to add JARs and directories to the classpath, for example, we use it to load Ant and various Ant tasks, code generators, test frameworks, and so forth.
|
116
66
|
|
117
|
-
When using an artifact specification, Buildr will automatically download and
|
118
|
-
install the artifact before adding it to the classpath.
|
67
|
+
When using an artifact specification, Buildr will automatically download and install the artifact before adding it to the classpath.
|
119
68
|
|
120
69
|
For example, Ant is loaded as follows:
|
121
70
|
|
@@ -123,37 +72,21 @@ For example, Ant is loaded as follows:
|
|
123
72
|
Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
124
73
|
}}}
|
125
74
|
|
126
|
-
Artifacts can only be downloaded after the Buildfile has loaded, giving it a
|
127
|
-
chance to specify which remote repositories to use, so adding to classpath does
|
128
|
-
not by itself load any libraries. You must call @Java.load@ before accessing any
|
129
|
-
Java classes to give Buildr a chance to load the libraries specified in the
|
130
|
-
classpath.
|
75
|
+
Artifacts can only be downloaded after the Buildfile has loaded, giving it a chance to specify which remote repositories to use, so adding to classpath does not by itself load any libraries. You must call @Java.load@ before accessing any Java classes to give Buildr a chance to load the libraries specified in the classpath.
|
131
76
|
|
132
77
|
When building an extension, make sure to follow these rules:
|
133
78
|
|
134
|
-
# Add to the @classpath@ when the extension is loaded (i.e. in module or class
|
135
|
-
|
136
|
-
|
137
|
-
# Call @Java.load@ once before accessing any Java classes, allowing Buildr to
|
138
|
-
set up the classpath.
|
139
|
-
# Only call @Java.load@ when invoked, otherwise you may end up loading the JVM
|
140
|
-
with a partial classpath, or before all remote repositories are listed.
|
79
|
+
# Add to the @classpath@ when the extension is loaded (i.e. in module or class definition), so the first call to @Java.load@ anywhere in the code will include the libraries you specify.
|
80
|
+
# Call @Java.load@ once before accessing any Java classes, allowing Buildr to set up the classpath.
|
81
|
+
# Only call @Java.load@ when invoked, otherwise you may end up loading the JVM with a partial classpath, or before all remote repositories are listed.
|
141
82
|
# Check on a clean build with empty local repository.
|
142
83
|
|
143
84
|
|
144
85
|
h2. Nailgun
|
145
86
|
|
146
|
-
"Nailgun":http://www.martiansoftware.com/nailgun/index.html is a client,
|
147
|
-
protocol, and server for running Java programs from the command line without
|
148
|
-
incurring the JVM startup overhead.
|
149
|
-
Nailgun integration is available only when running Buildr within JRuby.
|
87
|
+
"Nailgun":http://www.martiansoftware.com/nailgun/index.html is a client, protocol, and server for running Java programs from the command line without incurring the JVM startup overhead. Nailgun integration is available only when running Buildr within JRuby.
|
150
88
|
|
151
|
-
Buildr provides a custom nailgun server, allowing you to start a single JVM
|
152
|
-
and let buildr create a queue of runtimes.
|
153
|
-
These JRuby runtimes can be cached (indexed by buildfile path) and are
|
154
|
-
automatically reloaded when the buildfile has been modified.
|
155
|
-
Runtime caching allows you to execute tasks without spending time creating
|
156
|
-
the buildr environment.
|
89
|
+
Buildr provides a custom nailgun server, allowing you to start a single JVM and let buildr create a queue of runtimes. These JRuby runtimes can be cached (indexed by buildfile path) and are automatically reloaded when the buildfile has been modified. Runtime caching allows you to execute tasks without spending time creating the buildr environment.
|
157
90
|
|
158
91
|
Start the BuildrServer by executing
|
159
92
|
|
@@ -161,11 +94,7 @@ Start the BuildrServer by executing
|
|
161
94
|
$ jruby -S buildr -rbuildr/nailgun nailgun:start
|
162
95
|
}}}
|
163
96
|
|
164
|
-
Server output will display a message when it becomes ready, you
|
165
|
-
will also see messages when the JRuby runtimes are being created,
|
166
|
-
or when a new buildr environment is being loaded on them.
|
167
|
-
After the runtime queues have been populated, you can start calling
|
168
|
-
buildr as you normally do, by invoking the $NAILGUN_HOME/ng binary:
|
97
|
+
Server output will display a message when it becomes ready, you will also see messages when the JRuby runtimes are being created, or when a new buildr environment is being loaded on them. After the runtime queues have been populated, you can start calling buildr as you normally do, by invoking the $NAILGUN_HOME/ng binary:
|
169
98
|
|
170
99
|
{{{!sh
|
171
100
|
# on another terminal, change directory to a project.
|
@@ -180,29 +109,54 @@ ng nailgun:tasks # display overview of ng tasks
|
|
180
109
|
ng clean compile # just invoke those two tasks
|
181
110
|
}}}
|
182
111
|
|
183
|
-
Some nailgun tasks have been provided to manage the cached runtimes,
|
184
|
-
to get an overview of them execute the @nailgun:tasks@ task.
|
112
|
+
Some nailgun tasks have been provided to manage the cached runtimes, to get an overview of them execute the @nailgun:tasks@ task.
|
185
113
|
|
186
114
|
Be sure to read the nailgun help by executing the @nailgun:help@ task.
|
187
115
|
|
188
116
|
|
117
|
+
h2. Growl, Qube
|
118
|
+
|
119
|
+
For OS X users, Buildr supports "Growl":http://growl.info/ out of the box to send "completed and "failed" notifications to the user.
|
120
|
+
|
121
|
+
For other platforms or if you want to notify the user differently, Buildr offers two extension points:
|
122
|
+
|
123
|
+
* @Buildr.application.on_completion@
|
124
|
+
* @Buildr.application.on_failure@
|
125
|
+
|
126
|
+
Here is an example using these extension points to send notifications using "Qube":http://launchpad.net/qube:
|
127
|
+
|
128
|
+
{{{!ruby
|
129
|
+
# Send notifications using Qube
|
130
|
+
notify = lambda do |type, title, message|
|
131
|
+
param = case type
|
132
|
+
when 'completed'; '-i'
|
133
|
+
when 'failed'; '-e'
|
134
|
+
else '-i'
|
135
|
+
end
|
136
|
+
system "qube #{param} #{title.inspect} #{message.inspect}"
|
137
|
+
end
|
138
|
+
|
139
|
+
Buildr.application.on_completion do |title, message|
|
140
|
+
notify['completed', title, message]
|
141
|
+
end
|
142
|
+
Buildr.application.on_failure do |title, message, ex|
|
143
|
+
notify['failed', title, message]
|
144
|
+
end
|
145
|
+
}}}
|
146
|
+
|
147
|
+
You can place this code inside @buildr.rb@ in your home directory.
|
148
|
+
|
189
149
|
h2. Eclipse, IDEA
|
190
150
|
|
191
|
-
If you're using Eclipse, you can generate @.classpath@ and @.project@ from
|
192
|
-
your Buildfile and use them to create a project in your workspace:
|
151
|
+
If you're using Eclipse, you can generate @.classpath@ and @.project@ from your Buildfile and use them to create a project in your workspace:
|
193
152
|
|
194
153
|
{{{!sh
|
195
154
|
$ buildr eclipse
|
196
155
|
}}}
|
197
156
|
|
198
|
-
The @eclipse@ task will generate a @.classpath@ and @.project@ file for each
|
199
|
-
of projects (and sub-project) that compiles source code. It will not generate
|
200
|
-
files for other projects, for examples, projects you use strictly for
|
201
|
-
packaging a distribution, or creating command line scripts, etc.
|
157
|
+
The @eclipse@ task will generate a @.classpath@ and @.project@ file for each of projects (and sub-project) that compiles source code. It will not generate files for other projects, for examples, projects you use strictly for packaging a distribution, or creating command line scripts, etc.
|
202
158
|
|
203
|
-
If you add a new project, change the dependencies, or make any other change to
|
204
|
-
your Buildfile, just run the @eclipse@ task again to re-generate the Eclipse
|
205
|
-
project files.
|
159
|
+
If you add a new project, change the dependencies, or make any other change to your Buildfile, just run the @eclipse@ task again to re-generate the Eclipse project files.
|
206
160
|
|
207
161
|
If you prefer IntelliJ IDEA, you can always:
|
208
162
|
|
@@ -210,50 +164,32 @@ If you prefer IntelliJ IDEA, you can always:
|
|
210
164
|
$ buildr idea
|
211
165
|
}}}
|
212
166
|
|
213
|
-
It will generate a @.iml@ file for every project (or subproject) and a @.ipr@
|
214
|
-
that you can directly open for the root project. To allow IntelliJ Idea to
|
215
|
-
resolve external dependencies properly, you will need to add a @M2_REPO@
|
216
|
-
variable pointing to your Maven2 repository directory (@Settings / Path
|
217
|
-
Variables@).
|
167
|
+
It will generate a @.iml@ file for every project (or subproject) and a @.ipr@ that you can directly open for the root project. To allow IntelliJ Idea to resolve external dependencies properly, you will need to add a @M2_REPO@ variable pointing to your Maven2 repository directory (@Settings / Path Variables@).
|
218
168
|
|
219
|
-
If you're using IDEA 7 or later, use the @buildr idea7x@ task instead. This
|
220
|
-
task creates the proper @.ipr@ and @.iml@ files for IDEA version 7. It
|
221
|
-
includes the @-7x@ suffix in the generated files, so you can use the @idea@ and
|
222
|
-
@idea7x@ tasks side by side on the same project.
|
169
|
+
If you're using IDEA 7 or later, use the @buildr idea7x@ task instead. This task creates the proper @.ipr@ and @.iml@ files for IDEA version 7. It includes the @-7x@ suffix in the generated files, so you can use the @idea@ and @idea7x@ tasks side by side on the same project.
|
223
170
|
|
224
|
-
Also, check out the "Buildr plugin for
|
225
|
-
IDEA":http://www.digitalsanctum.com/buildr-plug-in/ (IDEA 7 and later). Once
|
226
|
-
installed, open your project with IDEA. If IDEA finds that you have Buildr
|
227
|
-
installed and finds a buildfile in the project's directory, it will show all
|
228
|
-
the tasks available for that project. To run a task, double-click it. When
|
229
|
-
the task completes, IDEA will show the results in the Buildr Output window.
|
171
|
+
Also, check out the "Buildr plugin for IDEA":http://www.digitalsanctum.com/buildr-plug-in/ (IDEA 7 and later). Once installed, open your project with IDEA. If IDEA finds that you have Buildr installed and finds a buildfile in the project's directory, it will show all the tasks available for that project. To run a task, double-click it. When the task completes, IDEA will show the results in the Buildr Output window.
|
230
172
|
|
231
173
|
|
232
|
-
h2. Cobertura, JDepend
|
174
|
+
h2. Cobertura, Emma, JDepend
|
233
175
|
|
234
|
-
You can use "Cobertura":http://cobertura.sourceforge.net/ to instrument your
|
235
|
-
code, run the tests and create a test coverage report in either HTML or XML
|
236
|
-
format.
|
176
|
+
You can use "Cobertura":http://cobertura.sourceforge.net/ or "Emma":http://emma.sourceforge.net/ to instrument your code, run the tests and create a test coverage report in either HTML or XML format.
|
237
177
|
|
238
|
-
There are two tasks, both of which generate a test coverage report in the
|
239
|
-
@reports/cobertura@ directory. For example:
|
178
|
+
There are two tasks for each tool, both of which generate a test coverage report in the @reports/cobertura@ (respectively @reports/emma@) directory. For example:
|
240
179
|
|
241
180
|
{{{!sh
|
242
181
|
$ buildr test cobertura:html
|
243
182
|
}}}
|
244
183
|
|
245
|
-
As you can guess, the other
|
184
|
+
As you can guess, the other tasks are @cobertura:xml@, @emma:html@ and @emma:xml@.
|
246
185
|
|
247
|
-
If you want to generate
|
248
|
-
can do so by using the project name as prefix to cobertura tasks.
|
186
|
+
If you want to generate a test coverage report only for a specific project, you can do so by using the project name as prefix to the tasks.
|
249
187
|
|
250
188
|
{{{!sh
|
251
189
|
$ buildr subModule:cobertura:html
|
252
190
|
}}}
|
253
191
|
|
254
|
-
Each project can specify which classes to include or exclude from cobertura
|
255
|
-
instrumentation by giving a class-name regexp to the @cobertura.include@ or
|
256
|
-
@cobertura.exclude@ methods:
|
192
|
+
Each project can specify which classes to include or exclude from cobertura instrumentation by giving a class-name regexp to the @cobertura.include@ or @cobertura.exclude@ methods:
|
257
193
|
|
258
194
|
{{{!ruby
|
259
195
|
define 'someModule' do
|
@@ -264,9 +200,9 @@ define 'someModule' do
|
|
264
200
|
end
|
265
201
|
}}}
|
266
202
|
|
267
|
-
|
268
|
-
|
269
|
-
candy one:
|
203
|
+
Emma has @include@ and @exclude@ methods too, but they take glob patterns instead of regexps.
|
204
|
+
|
205
|
+
You can use "JDepend":http://clarkware.com/software/JDepend.html on to generate design quality metrics. There are three tasks this time, the eye candy one:
|
270
206
|
|
271
207
|
{{{!sh
|
272
208
|
$ buildr jdepend:swing
|
@@ -274,22 +210,17 @@ $ buildr jdepend:swing
|
|
274
210
|
|
275
211
|
The other two tasks are @jdepend:text@ and @jdepend:xml@.
|
276
212
|
|
277
|
-
We want Buildr to load fast, and not everyone cares for these tasks, so we
|
278
|
-
don't include them by default. If you want to use either one, you need to
|
279
|
-
require it explicitly. The proper way to do it in Ruby:
|
213
|
+
We want Buildr to load fast, and not everyone cares for these tasks, so we don't include them by default. If you want to use one of them, you need to require it explicitly. The proper way to do it in Ruby:
|
280
214
|
|
281
215
|
{{{!ruby
|
282
216
|
require 'buildr/cobertura'
|
217
|
+
require 'buildr/emma'
|
283
218
|
require 'buildr/jdepend'
|
284
219
|
}}}
|
285
220
|
|
286
|
-
You may want to add those to the Buildfile. Alternatively, you can use these
|
287
|
-
tasks for all your projects without modifying the Buildfile. One convenient
|
288
|
-
method is to add these two likes to the @buildr.rb@ file in your home
|
289
|
-
directory.
|
221
|
+
You may want to add those to the Buildfile. Alternatively, you can use these tasks for all your projects without modifying the Buildfile. One convenient method is to add these lines to the @buildr.rb@ file in your home directory.
|
290
222
|
|
291
|
-
Another option is to require it from the command line (@--require@ or @-r@),
|
292
|
-
for example:
|
223
|
+
Another option is to require it from the command line (@--require@ or @-r@), for example:
|
293
224
|
|
294
225
|
{{{!sh
|
295
226
|
$ buildr --require buildr/jdepend jdepend:swing
|
@@ -299,18 +230,11 @@ $ buildr -rbuildr/cobertura cobertura:html
|
|
299
230
|
|
300
231
|
h2. Anything Ruby Can Do
|
301
232
|
|
302
|
-
Buildr is Ruby code. That's an implementation detail for some, but a useful
|
303
|
-
features for others. You can use Ruby to keep your build scripts simple and
|
304
|
-
DRY, tackle ad hoc tasks and write reusable features without the complexity of
|
305
|
-
"plugins".
|
233
|
+
Buildr is Ruby code. That's an implementation detail for some, but a useful features for others. You can use Ruby to keep your build scripts simple and DRY, tackle ad hoc tasks and write reusable features without the complexity of "plugins".
|
306
234
|
|
307
|
-
We already showed you one example where Ruby could help. You can use Ruby to
|
308
|
-
manage dependency by setting constants and reusing them, grouping related
|
309
|
-
dependencies into arrays and structures.
|
235
|
+
We already showed you one example where Ruby could help. You can use Ruby to manage dependency by setting constants and reusing them, grouping related dependencies into arrays and structures.
|
310
236
|
|
311
|
-
You can use Ruby to perform ad hoc tasks. For example, Buildr doesn't have
|
312
|
-
any pre-canned task for setting file permissions. But Ruby has a method for
|
313
|
-
that, so it's just a matter of writing a task:
|
237
|
+
You can use Ruby to perform ad hoc tasks. For example, Buildr doesn't have any pre-canned task for setting file permissions. But Ruby has a method for that, so it's just a matter of writing a task:
|
314
238
|
|
315
239
|
{{{!ruby
|
316
240
|
bins = file('target/bin'=>FileList[_('src/main/dist/bin/*')]) do |task|
|
@@ -320,10 +244,7 @@ bins = file('target/bin'=>FileList[_('src/main/dist/bin/*')]) do |task|
|
|
320
244
|
end
|
321
245
|
}}}
|
322
246
|
|
323
|
-
You can use functions to keep your code simple. For example, in the ODE
|
324
|
-
project we create two binary distributions, both of which contain a common set
|
325
|
-
of files, and one additional file unique to each distribution. We use a
|
326
|
-
method to define the common distribution:
|
247
|
+
You can use functions to keep your code simple. For example, in the ODE project we create two binary distributions, both of which contain a common set of files, and one additional file unique to each distribution. We use a method to define the common distribution:
|
327
248
|
|
328
249
|
{{{!ruby
|
329
250
|
def distro(project, id)
|
@@ -352,9 +273,7 @@ define 'distro-axis2' do
|
|
352
273
|
end
|
353
274
|
}}}
|
354
275
|
|
355
|
-
Ruby's functional style and blocks make some task extremely easy. For
|
356
|
-
example, let's say we wanted to count how many source files we have, and total
|
357
|
-
number of lines:
|
276
|
+
Ruby's functional style and blocks make some task extremely easy. For example, let's say we wanted to count how many source files we have, and total number of lines:
|
358
277
|
|
359
278
|
{{{!ruby
|
360
279
|
sources = projects.map { |prj| prj.compile.sources.
|
data/doc/pages/packaging.textile
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
h1. Packaging
|
2
2
|
|
3
|
-
For our next trick, we're going to try and create an artifact ourselves. We're
|
4
|
-
going to start with:
|
3
|
+
For our next trick, we're going to try and create an artifact ourselves. We're going to start with:
|
5
4
|
|
6
5
|
{{{!ruby
|
7
6
|
package :jar
|
8
7
|
}}}
|
9
8
|
|
10
|
-
We just told the project to create a JAR file in the @target@ directory,
|
11
|
-
including all the classes (and resources) that we previously compiled into
|
12
|
-
@target/classes@. Or we can create a WAR file:
|
9
|
+
We just told the project to create a JAR file in the @target@ directory, including all the classes (and resources) that we previously compiled into @target/classes@. Or we can create a WAR file:
|
13
10
|
|
14
11
|
{{{!ruby
|
15
12
|
package :war
|
16
13
|
}}}
|
17
14
|
|
18
|
-
The easy case is always easy, but sometimes we have more complicated use cases
|
19
|
-
which we'll address through the rest of this section.
|
15
|
+
The easy case is always easy, but sometimes we have more complicated use cases which we'll address through the rest of this section.
|
20
16
|
|
21
17
|
Now let's run the build, test cases and create these packages:
|
22
18
|
|
@@ -24,23 +20,14 @@ Now let's run the build, test cases and create these packages:
|
|
24
20
|
$ buildr package
|
25
21
|
}}}
|
26
22
|
|
27
|
-
The @package@ task runs the @build@ task (remember: @compile@ and @test@) and
|
28
|
-
then runs each of the packaging tasks, creating packages in the projects'
|
29
|
-
target directories.
|
23
|
+
The @package@ task runs the @build@ task (remember: @compile@ and @test@) and then runs each of the packaging tasks, creating packages in the projects' target directories.
|
30
24
|
|
31
|
-
p(tip). The @package@ task and @package@ methods are related, but that relation is
|
32
|
-
different from other task/method pairs. The @package@ method creates a file
|
33
|
-
task that points to the package in the @target@ directory and knows how to
|
34
|
-
create it. It then adds itself as a prerequisite to the @package@ task.
|
35
|
-
Translation: you can create multiple packages from the same project.
|
25
|
+
p(tip). The @package@ task and @package@ methods are related, but that relation is different from other task/method pairs. The @package@ method creates a file task that points to the package in the @target@ directory and knows how to create it. It then adds itself as a prerequisite to the @package@ task. Translation: you can create multiple packages from the same project.
|
36
26
|
|
37
27
|
|
38
28
|
h2. Specifying And Referencing Packages
|
39
29
|
|
40
|
-
Buildr supports several packaging types, and so when dealing with packages, you
|
41
|
-
have to indicate the desired package type. The packaging type can be the first
|
42
|
-
argument, or the value of the @:type@ argument. The following two are
|
43
|
-
equivalent:
|
30
|
+
Buildr supports several packaging types, and so when dealing with packages, you have to indicate the desired package type. The packaging type can be the first argument, or the value of the @:type@ argument. The following two are equivalent:
|
44
31
|
|
45
32
|
{{{!ruby
|
46
33
|
package :jar
|
@@ -49,10 +36,7 @@ package :type=>:jar
|
|
49
36
|
|
50
37
|
If you do not specify a package type, Buildr will attempt to infer one.
|
51
38
|
|
52
|
-
In the documentation you will find a number of tasks dealing with specific
|
53
|
-
packaging types (@ZipTask@, @JarTask@, etc). The @package@ method is a
|
54
|
-
convenience mechanism that sets up the package for you associates it with
|
55
|
-
various project life cycle tasks.
|
39
|
+
In the documentation you will find a number of tasks dealing with specific packaging types (@ZipTask@, @JarTask@, etc). The @package@ method is a convenience mechanism that sets up the package for you associates it with various project life cycle tasks.
|
56
40
|
|
57
41
|
To package a particular file, use the @:file@ argument, for example:
|
58
42
|
|
@@ -60,25 +44,13 @@ To package a particular file, use the @:file@ argument, for example:
|
|
60
44
|
package :zip, :file=>_('target/interesting.zip')
|
61
45
|
}}}
|
62
46
|
|
63
|
-
This returns a file task that will run as part of the project's @package@ task
|
64
|
-
(generating all packages). It will invoke the @build@ task to generate any
|
65
|
-
necessary prerequisites, before creating the specified file.
|
47
|
+
This returns a file task that will run as part of the project's @package@ task (generating all packages). It will invoke the @build@ task to generate any necessary prerequisites, before creating the specified file.
|
66
48
|
|
67
|
-
The package type does not have to be the same as the file name extension, but
|
68
|
-
if you don't specify the package type, it will be inferred from the extension.
|
49
|
+
The package type does not have to be the same as the file name extension, but if you don't specify the package type, it will be inferred from the extension.
|
69
50
|
|
70
|
-
Most often you will want to use the second form to generate packages that are
|
71
|
-
also artifacts. These packages have an artifact specification, which you can
|
72
|
-
use to reference them from other projects (and buildfiles). They are also
|
73
|
-
easier to share across projects: artifacts install themselves in the local
|
74
|
-
repository when running the @install@ task, and upload to the remote repository
|
75
|
-
when running the @upload@ task (see "Installing and
|
76
|
-
Uploading":#installing_and_uploading).
|
51
|
+
Most often you will want to use the second form to generate packages that are also artifacts. These packages have an artifact specification, which you can use to reference them from other projects (and buildfiles). They are also easier to share across projects: artifacts install themselves in the local repository when running the @install@ task, and upload to the remote repository when running the @upload@ task (see "Installing and Uploading":#installing_and_uploading).
|
77
52
|
|
78
|
-
The artifact specification is based on the project name (using dashes instead
|
79
|
-
of colons), group identifier and version number, all three obtained from the
|
80
|
-
project definition. You can specify different values using the @:id@,
|
81
|
-
@:group@, @:version@ and @:classifier@ arguments. For example:
|
53
|
+
The artifact specification is based on the project name (using dashes instead of colons), group identifier and version number, all three obtained from the project definition. You can specify different values using the @:id@, @:group@, @:version@ and @:classifier@ arguments. For example:
|
82
54
|
|
83
55
|
{{{!ruby
|
84
56
|
define 'killer-app', :version=>'1.0' do
|
@@ -97,24 +69,13 @@ define 'killer-app', :version=>'1.0' do
|
|
97
69
|
end
|
98
70
|
}}}
|
99
71
|
|
100
|
-
The file name is determined from the identifier, version number, classifier and
|
101
|
-
extension associated with that packaging type.
|
72
|
+
The file name is determined from the identifier, version number, classifier and extension associated with that packaging type.
|
102
73
|
|
103
|
-
If you do not specify the packaging type, Buildr attempt to infer it from the
|
104
|
-
project definition. In the general case it will use the default packaging
|
105
|
-
type, ZIP. A project that compiles Java classes will default to JAR packaging;
|
106
|
-
for other languages, consult the specific documentation.
|
74
|
+
If you do not specify the packaging type, Buildr attempt to infer it from the project definition. In the general case it will use the default packaging type, ZIP. A project that compiles Java classes will default to JAR packaging; for other languages, consult the specific documentation.
|
107
75
|
|
108
|
-
A single project can create multiple packages. For example, a Java project may
|
109
|
-
generate a JAR package for the runtime library and another JAR containing just
|
110
|
-
the API; a ZIP file for the source code and another ZIP for the documentation.
|
111
|
-
Make sure to always call @package@ with enough information to identify the
|
112
|
-
specific package you are referencing. Even if the project only defines a
|
113
|
-
single package, calling the @package@ method with no arguments does not
|
114
|
-
necessarily refer to that one.
|
76
|
+
A single project can create multiple packages. For example, a Java project may generate a JAR package for the runtime library and another JAR containing just the API; a ZIP file for the source code and another ZIP for the documentation. Make sure to always call @package@ with enough information to identify the specific package you are referencing. Even if the project only defines a single package, calling the @package@ method with no arguments does not necessarily refer to that one.
|
115
77
|
|
116
|
-
You can use the @packages@ method to obtain a list of all packages defined in
|
117
|
-
the project, for example:
|
78
|
+
You can use the @packages@ method to obtain a list of all packages defined in the project, for example:
|
118
79
|
|
119
80
|
{{{!ruby
|
120
81
|
project('killer-app:teh-impl').packages.first
|
@@ -124,42 +85,30 @@ project('killer-app:teh-impl').packages.select { |pkg| pkg.type == :zip }
|
|
124
85
|
|
125
86
|
h2. Packaging ZIPs
|
126
87
|
|
127
|
-
ZIP is the most common form of packaging, used by default when no other
|
128
|
-
packaging type applies. It also forms the basis for many other packaging types
|
129
|
-
(e.g. JAR and WAR). Most of what you'll find here applies to other packaging
|
130
|
-
types.
|
88
|
+
ZIP is the most common form of packaging, used by default when no other packaging type applies. It also forms the basis for many other packaging types (e.g. JAR and WAR). Most of what you'll find here applies to other packaging types.
|
131
89
|
|
132
|
-
Let's start by including additional files in the ZIP package. We're going to
|
133
|
-
include the @target/docs@ directory and @README@ file:
|
90
|
+
Let's start by including additional files in the ZIP package. We're going to include the @target/docs@ directory and @README@ file:
|
134
91
|
|
135
92
|
{{{!ruby
|
136
93
|
package(:zip).include _('target/docs'), 'README'
|
137
94
|
}}}
|
138
95
|
|
139
|
-
The @include@ method accepts files, directories and file tasks. You can also
|
140
|
-
use file pattern to match multiple files and directories. File patterns
|
141
|
-
include asterisk (@*@) to match any file name or part of a file name, double
|
142
|
-
asterisk (@**@) to match directories recursively, question mark (@?@) to match
|
143
|
-
any character, square braces (@[]@) to match a set of characters, and curly
|
144
|
-
braces (@{}@) to match one of several names.
|
96
|
+
The @include@ method accepts files, directories and file tasks. You can also use file pattern to match multiple files and directories. File patterns include asterisk (@*@) to match any file name or part of a file name, double asterisk (@**@) to match directories recursively, question mark (@?@) to match any character, square braces (@[]@) to match a set of characters, and curly braces (@{}@) to match one of several names.
|
145
97
|
|
146
|
-
And the same way you @include@, you can also @exclude@ specific files you don't
|
147
|
-
want showing up in the ZIP. For example, to exclude @.draft@ and @.raw@ files:
|
98
|
+
And the same way you @include@, you can also @exclude@ specific files you don't want showing up in the ZIP. For example, to exclude @.draft@ and @.raw@ files:
|
148
99
|
|
149
100
|
{{{!ruby
|
150
101
|
package(:zip).include('target/docs').
|
151
102
|
exclude('target/docs/**/*.{draft,raw}')
|
152
103
|
}}}
|
153
104
|
|
154
|
-
So far we've included files under the root of the ZIP. Let's include some
|
155
|
-
files under a given path using the @:path@ option:
|
105
|
+
So far we've included files under the root of the ZIP. Let's include some files under a given path using the @:path@ option:
|
156
106
|
|
157
107
|
{{{!ruby
|
158
108
|
package(:zip).include 'target/docs', :path=>"#{id}-#{version}"
|
159
109
|
}}}
|
160
110
|
|
161
|
-
If you need to use the @:path@ option repeatedly, consider using the @tap@
|
162
|
-
method instead. For example:
|
111
|
+
If you need to use the @:path@ option repeatedly, consider using the @tap@ method instead. For example:
|
163
112
|
|
164
113
|
{{{!ruby
|
165
114
|
package(:zip).path("#{id}-#{version}").tap do |path|
|
@@ -168,56 +117,36 @@ package(:zip).path("#{id}-#{version}").tap do |path|
|
|
168
117
|
end
|
169
118
|
}}}
|
170
119
|
|
171
|
-
p(tip). The @tap@ method is not part of the core library, but a very useful
|
172
|
-
extension. It takes an object, yields to the block with that object, and then
|
173
|
-
returns that object.
|
120
|
+
p(tip). The @tap@ method is not part of the core library, but a very useful extension. It takes an object, yields to the block with that object, and then returns that object.
|
174
121
|
|
175
|
-
p(note). To allow you to spread files across different paths, the
|
176
|
-
include/exclude patterns are specific to a path. So in the above example, if
|
177
|
-
you want to exclude some files from the "target/docs" directory, make sure to
|
178
|
-
call @exclude@ on the path, not on the ZIP task itself.
|
122
|
+
p(note). To allow you to spread files across different paths, the include/exclude patterns are specific to a path. So in the above example, if you want to exclude some files from the "target/docs" directory, make sure to call @exclude@ on the path, not on the ZIP task itself.
|
179
123
|
|
180
|
-
If you need to include a file or directory under a different name, use the
|
181
|
-
@:as@ option. For example:
|
124
|
+
If you need to include a file or directory under a different name, use the @:as@ option. For example:
|
182
125
|
|
183
126
|
{{{!ruby
|
184
127
|
package(:zip).include('corporate-logo-350x240.png', :as=>'logo.png')
|
185
128
|
}}}
|
186
129
|
|
187
|
-
You can also use @:as=>'.'@ to include all files from the given directory. For
|
188
|
-
example:
|
130
|
+
You can also use @:as=>'.'@ to include all files from the given directory. For example:
|
189
131
|
|
190
132
|
{{{!ruby
|
191
133
|
package(:zip).include 'target/docs/*'
|
192
134
|
package(:zip).include 'target/docs', :as=>'.'
|
193
135
|
}}}
|
194
136
|
|
195
|
-
These two are almost identical. They both include all the files from the
|
196
|
-
@target/docs@ directory, but not the directory itself. But they operate
|
197
|
-
differently. The first line expands to include all the files in @target/docs@.
|
198
|
-
If you don't already have files in @target/docs@, well, then it won't do
|
199
|
-
anything interesting. Your ZIP will come up empty. The second file includes
|
200
|
-
the directory itself, but strips the path during inclusion. You can define it
|
201
|
-
now, create these files later, and then ZIP them all up.
|
137
|
+
These two are almost identical. They both include all the files from the @target/docs@ directory, but not the directory itself. But they operate differently. The first line expands to include all the files in @target/docs@. If you don't already have files in @target/docs@, well, then it won't do anything interesting. Your ZIP will come up empty. The second file includes the directory itself, but strips the path during inclusion. You can define it now, create these files later, and then ZIP them all up.
|
202
138
|
|
203
|
-
For example, when @package :jar@ decides to include all the files from
|
204
|
-
@target/classes@, it's still working on the project definition, and has yet to
|
205
|
-
compile anything. Since @target/classes@ may be empty, may not even exist, it
|
206
|
-
uses @:as=>'.'@.
|
139
|
+
For example, when @package :jar@ decides to include all the files from @target/classes@, it's still working on the project definition, and has yet to compile anything. Since @target/classes@ may be empty, may not even exist, it uses @:as=>'.'@.
|
207
140
|
|
208
|
-
If you need to get rid of all the included files, call the @clean@ method.
|
209
|
-
Some packaging types default to adding various files and directories, for
|
210
|
-
example, JAR packaging will include all the compiled classes and resources.
|
141
|
+
If you need to get rid of all the included files, call the @clean@ method. Some packaging types default to adding various files and directories, for example, JAR packaging will include all the compiled classes and resources.
|
211
142
|
|
212
|
-
You can also merge two ZIP files together, expanding the content of one ZIP
|
213
|
-
into the other. For example:
|
143
|
+
You can also merge two ZIP files together, expanding the content of one ZIP into the other. For example:
|
214
144
|
|
215
145
|
{{{!ruby
|
216
146
|
package(:zip).merge 'part1.zip', 'part2.zip'
|
217
147
|
}}}
|
218
148
|
|
219
|
-
If you need to be more selective, you can apply the include/exclude pattern to
|
220
|
-
the expanded ZIP. For example:
|
149
|
+
If you need to be more selective, you can apply the include/exclude pattern to the expanded ZIP. For example:
|
221
150
|
|
222
151
|
{{{!ruby
|
223
152
|
# Everything but the libs
|
@@ -227,9 +156,7 @@ package(:zip).merge('bigbad.war').exclude('libs/**/*')
|
|
227
156
|
|
228
157
|
h2. Packaging JARs
|
229
158
|
|
230
|
-
JAR packages extend ZIP packages with support for Manifest files and the
|
231
|
-
META-INF directory. They also default to include the class files found in the
|
232
|
-
@target/classes@ directory.
|
159
|
+
JAR packages extend ZIP packages with support for Manifest files and the META-INF directory. They also default to include the class files found in the @target/classes@ directory.
|
233
160
|
|
234
161
|
You can tell the JAR package to include a particular Manifest file:
|
235
162
|
|
@@ -243,14 +170,9 @@ Or generate a manifest from a hash:
|
|
243
170
|
package(:jar).with :manifest=>{ 'Copyright'=>'Acme Inc (C) 2007' }
|
244
171
|
}}}
|
245
172
|
|
246
|
-
You can also generate a JAR with no manifest with the value @false@, create a
|
247
|
-
manifest with several sections using an array of hashes, or create it from a
|
248
|
-
proc.
|
173
|
+
You can also generate a JAR with no manifest with the value @false@, create a manifest with several sections using an array of hashes, or create it from a proc.
|
249
174
|
|
250
|
-
In large projects, where all the packages use the same manifest, it's easier to
|
251
|
-
set it once on the top project using the @manifest@ project property.
|
252
|
-
Sub-projects inherit the property from their parents, and the @package@ method
|
253
|
-
uses that property if you don't override it, as we do above.
|
175
|
+
In large projects, where all the packages use the same manifest, it's easier to set it once on the top project using the @manifest@ project property. Sub-projects inherit the property from their parents, and the @package@ method uses that property if you don't override it, as we do above.
|
254
176
|
|
255
177
|
For example, we can get the same result by specifying this at the top project:
|
256
178
|
|
@@ -258,30 +180,21 @@ For example, we can get the same result by specifying this at the top project:
|
|
258
180
|
manifest['Copyright'] = 'Acme Inc (C) 2007'
|
259
181
|
}}}
|
260
182
|
|
261
|
-
If you need to mix-in the project's manifest with values that only one package
|
262
|
-
uses, you can do so easily:
|
183
|
+
If you need to mix-in the project's manifest with values that only one package uses, you can do so easily:
|
263
184
|
|
264
185
|
{{{!ruby
|
265
186
|
package(:jar).with :manifest=>manifest.merge('Main-Class'=>'com.acme.Main')
|
266
187
|
}}}
|
267
188
|
|
268
|
-
If you need to include more files in the @META-INF@ directory, you can use the
|
269
|
-
@:meta_inf@ option. You can give it a file, or array of files. And yes, there
|
270
|
-
is a @meta_inf@ project property you can set once to include the same set of
|
271
|
-
file in all the JARs. It works like this:
|
189
|
+
If you need to include more files in the @META-INF@ directory, you can use the @:meta_inf@ option. You can give it a file, or array of files. And yes, there is a @meta_inf@ project property you can set once to include the same set of file in all the JARs. It works like this:
|
272
190
|
|
273
191
|
{{{!ruby
|
274
192
|
meta_inf << file('DISCLAIMER') << file('NOTICE')
|
275
193
|
}}}
|
276
194
|
|
277
|
-
If you have a @LICENSE@ file, it's already included in the @meta_inf@ list of
|
278
|
-
files.
|
195
|
+
If you have a @LICENSE@ file, it's already included in the @meta_inf@ list of files.
|
279
196
|
|
280
|
-
Other than that, @package :jar@ includes the contents of the compiler's target
|
281
|
-
directory and resources, which most often is exactly what you intend it to do.
|
282
|
-
If you want to include other files in the JAR, instead or in addition, you can
|
283
|
-
do so using the @include@ and @exclude@ methods. If you do not want the target
|
284
|
-
directory included in your JAR, simply call the @clean@ method on it:
|
197
|
+
Other than that, @package :jar@ includes the contents of the compiler's target directory and resources, which most often is exactly what you intend it to do. If you want to include other files in the JAR, instead or in addition, you can do so using the @include@ and @exclude@ methods. If you do not want the target directory included in your JAR, simply call the @clean@ method on it:
|
285
198
|
|
286
199
|
{{{!ruby
|
287
200
|
package(:jar).clean.include( only_these_files )
|
@@ -290,18 +203,11 @@ package(:jar).clean.include( only_these_files )
|
|
290
203
|
|
291
204
|
h2. Packaging WARs
|
292
205
|
|
293
|
-
Pretty much everything you know about JARs works the same way for WARs, so
|
294
|
-
let's just look at the differences.
|
206
|
+
Pretty much everything you know about JARs works the same way for WARs, so let's just look at the differences.
|
295
207
|
|
296
|
-
Without much prompting, @package :war@ picks the contents of the
|
297
|
-
@src/main/webapp@ directory and places it at the root of the WAR, copies the
|
298
|
-
compiler target directory into the @WEB-INF/classes@ path, and copies any
|
299
|
-
compiled dependencies into the @WEB-INF/libs@ paths.
|
208
|
+
Without much prompting, @package :war@ picks the contents of the @src/main/webapp@ directory and places it at the root of the WAR, copies the compiler target directory into the @WEB-INF/classes@ path, and copies any compiled dependencies into the @WEB-INF/libs@ paths.
|
300
209
|
|
301
|
-
Again, you can use the @include@ and @exclude@ methods to change the contents
|
302
|
-
of the WAR. There are two convenience options you can use to make the more
|
303
|
-
common changes. If you need to include a classes directory other than the
|
304
|
-
default:
|
210
|
+
Again, you can use the @include@ and @exclude@ methods to change the contents of the WAR. There are two convenience options you can use to make the more common changes. If you need to include a classes directory other than the default:
|
305
211
|
|
306
212
|
{{{!ruby
|
307
213
|
package(:war).with :classes=>_('target/additional')
|
@@ -313,15 +219,9 @@ If you want to include a different set of libraries other than the default:
|
|
313
219
|
package(:war).with :libs=>MYSQL_JDBC
|
314
220
|
}}}
|
315
221
|
|
316
|
-
Both options accept a single value or an array. The @:classes@ option accepts
|
317
|
-
the name of a directory containing class files, initially set to
|
318
|
-
@compile.target@ and @resources.target@. The @:libs@ option accepts artifact
|
319
|
-
specifications, file names and tasks, initially set to include everything in
|
320
|
-
@compile.dependencies@.
|
222
|
+
Both options accept a single value or an array. The @:classes@ option accepts the name of a directory containing class files, initially set to @compile.target@ and @resources.target@. The @:libs@ option accepts artifact specifications, file names and tasks, initially set to include everything in @compile.dependencies@.
|
321
223
|
|
322
|
-
As you can guess, the package task has two attributes called @classes@ and
|
323
|
-
@libs@; the @with@ method merely sets their value. If you need more precise
|
324
|
-
control over these arrays, you can always work with them directly, for example:
|
224
|
+
As you can guess, the package task has two attributes called @classes@ and @libs@; the @with@ method merely sets their value. If you need more precise control over these arrays, you can always work with them directly, for example:
|
325
225
|
|
326
226
|
{{{!ruby
|
327
227
|
# Add an artifact to the existing set:
|
@@ -336,34 +236,20 @@ puts package(:war).libs.map(&:to_spec)
|
|
336
236
|
|
337
237
|
h2. Packaging AARs
|
338
238
|
|
339
|
-
Axis2 service archives are similar to JAR's (compiled classes go into the root
|
340
|
-
of the archive) but they can embed additional libraries under /lib and include
|
341
|
-
@services.xml@ and WSDL files.
|
239
|
+
Axis2 service archives are similar to JAR's (compiled classes go into the root of the archive) but they can embed additional libraries under /lib and include @services.xml@ and WSDL files.
|
342
240
|
|
343
241
|
{{{!ruby
|
344
242
|
package(:aar).with(:libs=>'log4j:log4j:jar:1.1')
|
345
243
|
package(:aar).with(:services_xml=>_('target/services.xml'), :wsdls=>_('target/*.wsdl'))
|
346
244
|
}}}
|
347
245
|
|
348
|
-
The @libs@ attribute is a list of .jar artifacts to be included in the archive
|
349
|
-
under /lib. The default is no artifacts; compile dependencies are not included
|
350
|
-
by default.
|
246
|
+
The @libs@ attribute is a list of .jar artifacts to be included in the archive under /lib. The default is no artifacts; compile dependencies are not included by default.
|
351
247
|
|
352
|
-
The @services_xml@ attribute points to an Axis2 services configuration file
|
353
|
-
called @services.xml@ that will be placed in the @META-INF@ directory inside
|
354
|
-
the archive. The default behavior is to point to the @services.xml@ file in
|
355
|
-
the project's @src/main/axis2@ directory. In the second example above we set
|
356
|
-
it explicitly.
|
248
|
+
The @services_xml@ attribute points to an Axis2 services configuration file called @services.xml@ that will be placed in the @META-INF@ directory inside the archive. The default behavior is to point to the @services.xml@ file in the project's @src/main/axis2@ directory. In the second example above we set it explicitly.
|
357
249
|
|
358
|
-
The @wsdls@ attribute is a collection of file names or glob patterns for WSDL
|
359
|
-
files that get included in the @META-INF@ directory. In the second example we
|
360
|
-
include WSDL files from the @target@ directory, presumably created by an
|
361
|
-
earlier build task. In addition, AAR packaging will include all files ending
|
362
|
-
with @.wsdl@ from the @src/main/axis2@ directory.
|
250
|
+
The @wsdls@ attribute is a collection of file names or glob patterns for WSDL files that get included in the @META-INF@ directory. In the second example we include WSDL files from the @target@ directory, presumably created by an earlier build task. In addition, AAR packaging will include all files ending with @.wsdl@ from the @src/main/axis2@ directory.
|
363
251
|
|
364
|
-
If you already have WSDL files in the @src/main/axis2@ directory but would like
|
365
|
-
to perform some filtering, for example, to set the HTTP port number, consider
|
366
|
-
ignoring the originals and including only the filtered files, for example:
|
252
|
+
If you already have WSDL files in the @src/main/axis2@ directory but would like to perform some filtering, for example, to set the HTTP port number, consider ignoring the originals and including only the filtered files, for example:
|
367
253
|
|
368
254
|
{{{!ruby
|
369
255
|
# Host name depends on environment.
|
@@ -377,10 +263,7 @@ package(:aar).with(:services_xml=>_('target/services.xml'), :wsdls=>_('target/*.
|
|
377
263
|
|
378
264
|
h2. Packaging EARs
|
379
265
|
|
380
|
-
EAR packaging is slightly different from JAR/WAR packaging. It's main purpose
|
381
|
-
is to package components together, and so it includes special methods for
|
382
|
-
handling component inclusion that take care to update application.xml and the
|
383
|
-
component's classpath.
|
266
|
+
EAR packaging is slightly different from JAR/WAR packaging. It's main purpose is to package components together, and so it includes special methods for handling component inclusion that take care to update application.xml and the component's classpath.
|
384
267
|
|
385
268
|
EAR packages support four component types:
|
386
269
|
|
@@ -397,11 +280,7 @@ package(:ear) << project('coolWebService').package(:war)
|
|
397
280
|
package(:ear).add project('commonLib') # By default, the JAR package
|
398
281
|
}}}
|
399
282
|
|
400
|
-
Adding a WAR package assumes it's a WAR component and treats it as such, but
|
401
|
-
JAR packages can be any of three component types, so by default they are all
|
402
|
-
treated as shared libraries. If you want to add an EJB or Application Client
|
403
|
-
component, you need to say so explicitly, either passing @:type=>package@, or by
|
404
|
-
passing the component type in the @:type@ option.
|
283
|
+
Adding a WAR package assumes it's a WAR component and treats it as such, but JAR packages can be any of three component types, so by default they are all treated as shared libraries. If you want to add an EJB or Application Client component, you need to say so explicitly, either passing @:type=>package@, or by passing the component type in the @:type@ option.
|
405
284
|
|
406
285
|
Here are three examples:
|
407
286
|
|
@@ -414,13 +293,9 @@ package(:ear).add :ejb=>project('beanery')
|
|
414
293
|
package(:ear).add project('client'), :type=>:jar
|
415
294
|
}}}
|
416
295
|
|
417
|
-
By default, WAR components are all added under the @/war@ path, and likewise,
|
418
|
-
EJB components are added under the @/ejb@ path, shared libraries under @/lib@
|
419
|
-
and Application Client components under @/jar@.
|
296
|
+
By default, WAR components are all added under the @/war@ path, and likewise, EJB components are added under the @/ejb@ path, shared libraries under @/lib@ and Application Client components under @/jar@.
|
420
297
|
|
421
|
-
If you want to place components in different locations you can do so using the
|
422
|
-
@:path@ option, or by specifying a different mapping between component types
|
423
|
-
and their destination directory. The following two examples are equivalent:
|
298
|
+
If you want to place components in different locations you can do so using the @:path@ option, or by specifying a different mapping between component types and their destination directory. The following two examples are equivalent:
|
424
299
|
|
425
300
|
{{{!ruby
|
426
301
|
# Specify once per component.
|
@@ -430,18 +305,11 @@ package(:ear).dirs[:war] = 'coolServices'
|
|
430
305
|
package(:ear) << project('coolWebService').package(:war)
|
431
306
|
}}}
|
432
307
|
|
433
|
-
EAR packages include an @application.xml@ file in the @META-INF@ directory that
|
434
|
-
describes the application and its components. This file is created for you
|
435
|
-
during packaging, by referencing all the components added to the EAR. There
|
436
|
-
are a couple of things you will typically want to change.
|
308
|
+
EAR packages include an @application.xml@ file in the @META-INF@ directory that describes the application and its components. This file is created for you during packaging, by referencing all the components added to the EAR. There are a couple of things you will typically want to change.
|
437
309
|
|
438
|
-
* *display-name* -- The application's display name defaults to the project's
|
439
|
-
identifier. You can change that by setting the @display_name@ attribute.
|
310
|
+
* *display-name* -- The application's display name defaults to the project's identifier. You can change that by setting the @display_name@ attribute.
|
440
311
|
|
441
|
-
* *context-root* -- WAR components specify a context root, based on the package
|
442
|
-
identifier, for example, "cool-web-1.0.war" will have the context root
|
443
|
-
"cool-web". To specify a different context root, add the WAR package with the
|
444
|
-
@context_root@ option.
|
312
|
+
* *context-root* -- WAR components specify a context root, based on the package identifier, for example, "cool-web-1.0.war" will have the context root "cool-web". To specify a different context root, add the WAR package with the @context_root@ option.
|
445
313
|
|
446
314
|
Again, by example:
|
447
315
|
|
@@ -450,40 +318,28 @@ package(:ear).display_name = 'MyCoolWebService'
|
|
450
318
|
package(:ear).add project('coolWebService').package(:war), :context-root=>'coolness'
|
451
319
|
}}}
|
452
320
|
|
453
|
-
If you need to disable the context root (e.g. for Portlets), set @context_root@
|
454
|
-
to @false@.
|
321
|
+
If you need to disable the context root (e.g. for Portlets), set @context_root@ to @false@.
|
455
322
|
|
456
323
|
|
457
324
|
h2. Packaging Tars and GZipped Tars
|
458
325
|
|
459
|
-
Everything you know about working with ZIP files translates to Tar files, the
|
460
|
-
two tasks are identical in more respect, so here we'll just go over the
|
461
|
-
differences.
|
326
|
+
Everything you know about working with ZIP files translates to Tar files, the two tasks are identical in more respect, so here we'll just go over the differences.
|
462
327
|
|
463
328
|
{{{!ruby
|
464
329
|
package(:tar).include _('target/docs'), 'README'
|
465
330
|
package(:tgz).include _('target/docs'), 'README'
|
466
331
|
}}}
|
467
332
|
|
468
|
-
The first line creates a Tar archive with the extension @.tar@, the second
|
469
|
-
creates a GZipped Tar archive with the extension @.tgz@.
|
333
|
+
The first line creates a Tar archive with the extension @.tar@, the second creates a GZipped Tar archive with the extension @.tgz@.
|
470
334
|
|
471
|
-
In addition to packaging that includes the archive in the list of
|
472
|
-
installed/released files, you can use the method @tar@ to create a @TarTask@.
|
473
|
-
This task is similar to @ZipTask@, and introduces the @gzip@ attribute, which
|
474
|
-
you can use to tell it whether to create a regular file, or GZip it. By
|
475
|
-
default the attribute it set to true (GZip) if the file name ends with either
|
476
|
-
@.gz@ or @.tgz@.
|
335
|
+
In addition to packaging that includes the archive in the list of installed/released files, you can use the method @tar@ to create a @TarTask@. This task is similar to @ZipTask@, and introduces the @gzip@ attribute, which you can use to tell it whether to create a regular file, or GZip it. By default the attribute it set to true (GZip) if the file name ends with either @.gz@ or @.tgz@.
|
477
336
|
|
478
337
|
|
479
338
|
h2. Installing and Uploading
|
480
339
|
|
481
|
-
You can bring in the artifacts you need from remote repositories and install
|
482
|
-
them in the local repositories. Other projects have the same expectation, that
|
483
|
-
your packages be their artifacts.
|
340
|
+
You can bring in the artifacts you need from remote repositories and install them in the local repositories. Other projects have the same expectation, that your packages be their artifacts.
|
484
341
|
|
485
|
-
So let's create these packages and install them in the local repository where
|
486
|
-
other projects can access them:
|
342
|
+
So let's create these packages and install them in the local repository where other projects can access them:
|
487
343
|
|
488
344
|
{{{!sh
|
489
345
|
$ buildr install
|
@@ -495,8 +351,7 @@ If you changes your mind you can always:
|
|
495
351
|
$ buildr uninstall
|
496
352
|
}}}
|
497
353
|
|
498
|
-
That works between projects you build on the same machine. Now let's share
|
499
|
-
these artifacts with other developers through a remote repository:
|
354
|
+
That works between projects you build on the same machine. Now let's share these artifacts with other developers through a remote repository:
|
500
355
|
|
501
356
|
{{{!sh
|
502
357
|
$ buildr upload
|
@@ -508,20 +363,11 @@ Of course, you'll need to tell Buildr about the release server:
|
|
508
363
|
repositories.release_to = 'sftp://john:secret@release/usr/share/repo'
|
509
364
|
}}}
|
510
365
|
|
511
|
-
This example uses the SFTP protocol. In addition, you can use the HTTP
|
512
|
-
protocol -- Buildr supports HTTP and HTTPS, Basic Authentication and uploads
|
513
|
-
using PUT -- or point to a directory on your file system.
|
366
|
+
This example uses the SFTP protocol. In addition, you can use the HTTP protocol -- Buildr supports HTTP and HTTPS, Basic Authentication and uploads using PUT -- or point to a directory on your file system.
|
514
367
|
|
515
|
-
The URL in this example contains the release server ("release"), path to
|
516
|
-
repository ("user/share/repo") and username/password for access. The way SFTP
|
517
|
-
works, you specify the path on the release server, and give the user
|
518
|
-
permissions to create directories and files inside the repository. The file
|
519
|
-
system path is different from the path you use to download these artifacts
|
520
|
-
through an HTTP server, and starts at the root, not the user's home directory.
|
368
|
+
The URL in this example contains the release server ("release"), path to repository ("user/share/repo") and username/password for access. The way SFTP works, you specify the path on the release server, and give the user permissions to create directories and files inside the repository. The file system path is different from the path you use to download these artifacts through an HTTP server, and starts at the root, not the user's home directory.
|
521
369
|
|
522
|
-
Of course, you'll want to specify the release server URL in the Buildfile, but
|
523
|
-
leave the username/password settings private in your local @buildr.rb@ file.
|
524
|
-
Let's break up the release server settings:
|
370
|
+
Of course, you'll want to specify the release server URL in the Buildfile, but leave the username/password settings private in your local @buildr.rb@ file. Let's break up the release server settings:
|
525
371
|
|
526
372
|
{{{!ruby
|
527
373
|
# build.rb, loaded first
|
@@ -532,14 +378,9 @@ repositories.release_to[:password] = 'secret'
|
|
532
378
|
repositories.release_to[:url] = 'sftp://release/usr/share/repo'
|
533
379
|
}}}
|
534
380
|
|
535
|
-
The @upload@ task takes care of uploading all the packages created by your
|
536
|
-
project, along with their associated POM files and MD5/SHA1 signatures (Buildr
|
537
|
-
creates these for you).
|
381
|
+
The @upload@ task takes care of uploading all the packages created by your project, along with their associated POM files and MD5/SHA1 signatures (Buildr creates these for you).
|
538
382
|
|
539
|
-
If you need to upload other files, you can always extend the @upload@ task and
|
540
|
-
use @repositories.release_to@ in combination with @URI.upload@. You can also
|
541
|
-
extend it to upload to different servers, for example, to publish the
|
542
|
-
documentation and test coverage reports to your site:
|
383
|
+
If you need to upload other files, you can always extend the @upload@ task and use @repositories.release_to@ in combination with @URI.upload@. You can also extend it to upload to different servers, for example, to publish the documentation and test coverage reports to your site:
|
543
384
|
|
544
385
|
{{{!ruby
|
545
386
|
# We'll let some other task decide how to create 'docs'
|
@@ -552,21 +393,15 @@ end
|
|
552
393
|
|
553
394
|
h2. Packaging Sources and JavaDocs
|
554
395
|
|
555
|
-
IDEs can take advantage of source packages to help you debug and trace through
|
556
|
-
compiled code. We'll start with a simple example:
|
396
|
+
IDEs can take advantage of source packages to help you debug and trace through compiled code. We'll start with a simple example:
|
557
397
|
|
558
398
|
{{{!ruby
|
559
399
|
package :sources
|
560
400
|
}}}
|
561
401
|
|
562
|
-
This one creates a ZIP package with the classifier "sources" that will contain
|
563
|
-
all the source directories in that project, typically @src/main/java@, but also
|
564
|
-
other sources generated from Apt, JavaCC, XMLBeans and friends.
|
402
|
+
This one creates a ZIP package with the classifier "sources" that will contain all the source directories in that project, typically @src/main/java@, but also other sources generated from Apt, JavaCC, XMLBeans and friends.
|
565
403
|
|
566
|
-
You can also generate a ZIP package with the classifier "javadoc" that contains
|
567
|
-
the JavaDoc documentation for the project. It uses the same set of
|
568
|
-
documentation files generated by the project's @javadoc@ task, so you can use
|
569
|
-
it in combination with the @javadoc@ method. For example:
|
404
|
+
You can also generate a ZIP package with the classifier "javadoc" that contains the JavaDoc documentation for the project. It uses the same set of documentation files generated by the project's @javadoc@ task, so you can use it in combination with the @javadoc@ method. For example:
|
570
405
|
|
571
406
|
{{{!ruby
|
572
407
|
package :javadoc
|
@@ -575,9 +410,7 @@ javadoc :windowtitle=>'Buggy but Works'
|
|
575
410
|
|
576
411
|
By default Buildr picks the project's description for the window title.
|
577
412
|
|
578
|
-
You can also tell Buildr to automatically create sources and JavaDoc packages
|
579
|
-
in all the sub-projects that have any source files to package or document.
|
580
|
-
Just add either or both of these methods in the top-level project:
|
413
|
+
You can also tell Buildr to automatically create sources and JavaDoc packages in all the sub-projects that have any source files to package or document. Just add either or both of these methods in the top-level project:
|
581
414
|
|
582
415
|
{{{!ruby
|
583
416
|
package_with_sources
|
@@ -591,5 +424,4 @@ For example:
|
|
591
424
|
package_with_javadoc :except=>'la-web'
|
592
425
|
}}}
|
593
426
|
|
594
|
-
We packaged the code, but will it actually work? Let's see "what the tests
|
595
|
-
say":testing.html.
|
427
|
+
We packaged the code, but will it actually work? Let's see "what the tests say":testing.html.
|