buildr 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +35 -0
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/buildr.buildfile +6 -1
- data/buildr.gemspec +10 -9
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +25 -19
- data/doc/artifacts.textile +0 -36
- data/doc/building.textile +0 -38
- data/doc/contributing.textile +51 -15
- data/doc/css/default.css +11 -4
- data/doc/css/print.css +32 -24
- data/doc/download.textile +2 -1
- data/doc/extending.textile +10 -20
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/index.textile +39 -17
- data/doc/{getting_started.textile → installing.textile} +2 -67
- data/doc/languages.textile +50 -52
- data/doc/more_stuff.textile +154 -62
- data/doc/packaging.textile +0 -82
- data/doc/preface.textile +41 -15
- data/doc/projects.textile +0 -18
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/install-linux.sh +10 -2
- data/doc/settings_profiles.textile +1 -33
- data/doc/testing.textile +6 -32
- data/lib/buildr.rb +2 -1
- data/lib/buildr/core.rb +6 -0
- data/lib/buildr/core/application.rb +2 -5
- data/lib/buildr/core/build.rb +29 -19
- data/lib/buildr/core/compile.rb +22 -4
- data/lib/buildr/core/filter.rb +2 -4
- data/lib/buildr/core/project.rb +5 -4
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +2 -0
- data/lib/buildr/core/transports.rb +18 -19
- data/lib/buildr/core/util.rb +178 -9
- data/lib/buildr/groovy.rb +1 -0
- data/lib/buildr/groovy/bdd.rb +5 -5
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide/eclipse.rb +148 -36
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/java/bdd.rb +16 -8
- data/lib/buildr/java/cobertura.rb +44 -13
- data/lib/buildr/java/commands.rb +5 -3
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +18 -0
- data/lib/buildr/java/packaging.rb +2 -2
- data/lib/buildr/java/rjb.rb +1 -1
- data/lib/buildr/java/test_result.rb +48 -1
- data/lib/buildr/java/tests.rb +8 -5
- data/lib/buildr/packaging/artifact_namespace.rb +1 -1
- data/lib/buildr/packaging/package.rb +6 -2
- data/lib/buildr/packaging/zip.rb +10 -1
- data/lib/buildr/packaging/ziptask.rb +5 -2
- data/lib/buildr/scala.rb +1 -0
- data/lib/buildr/scala/bdd.rb +17 -8
- data/lib/buildr/scala/compiler.rb +66 -21
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +6 -5
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/doc.rake +2 -3
- data/rakelib/jekylltask.rb +42 -32
- data/rakelib/package.rake +4 -2
- data/rakelib/rspec.rake +3 -3
- data/rakelib/setup.rake +7 -1
- data/rakelib/stage.rake +9 -2
- data/rakelib/stage.rake~ +213 -0
- data/spec/core/application_spec.rb +84 -1
- data/spec/core/build_spec.rb +54 -2
- data/spec/core/common_spec.rb +1 -1
- data/spec/core/compile_spec.rb +2 -1
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/test_spec.rb +2 -2
- data/spec/core/transport_spec.rb +1 -1
- data/spec/groovy/bdd_spec.rb +6 -6
- data/spec/groovy/compiler_spec.rb +1 -0
- data/spec/ide/eclipse_spec.rb +262 -72
- data/spec/java/{ant.rb → ant_spec.rb} +0 -0
- data/spec/java/bdd_spec.rb +15 -0
- data/spec/java/cobertura_spec.rb +9 -1
- data/spec/java/emma_spec.rb +1 -1
- data/spec/java/java_spec.rb +26 -0
- data/spec/java/packaging_spec.rb +9 -7
- data/spec/java/{test_coverage_spec.rb → test_coverage_helper.rb} +6 -4
- data/spec/java/tests_spec.rb +22 -0
- data/spec/packaging/archive_spec.rb +14 -0
- data/spec/packaging/artifact_spec.rb +2 -2
- data/spec/packaging/packaging_spec.rb +97 -2
- data/spec/sandbox.rb +3 -1
- data/spec/scala/bdd_spec.rb +17 -48
- data/spec/scala/compiler_spec.rb +31 -2
- data/spec/scala/tests_spec.rb +1 -0
- data/spec/spec_helpers.rb +12 -0
- metadata +145 -148
data/doc/more_stuff.textile
CHANGED
@@ -3,6 +3,118 @@ layout: default
|
|
3
3
|
title: More Stuff
|
4
4
|
---
|
5
5
|
|
6
|
+
h2(#shell). Interactive Shells (REPLs)
|
7
|
+
|
8
|
+
Many languages (including Scala and Groovy) provide an interactive shell tool which allows developers to run arbitrary expressions and see the results immediately:
|
9
|
+
|
10
|
+
<pre>$ scala
|
11
|
+
Welcome to Scala version 2.7.4.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_03-p3).
|
12
|
+
Type in expressions to have them evaluated.
|
13
|
+
Type :help for more information.
|
14
|
+
|
15
|
+
scala> 6 * 7
|
16
|
+
res0: Int = 42
|
17
|
+
|
18
|
+
scala> </pre>
|
19
|
+
|
20
|
+
These tools are alternatively known as "REPLs" (Read, Eval, Print Loop), a term which originally comes from Lisp. This sort of interactive shell can be an invaluable asset when developing frameworks or other non-UI-oriented modules. A common use-case is running a quick, manual test to make sure that the framework is functioning properly. It is faster and easier to do this in a shell, and also averts the need for extra test cases to be developed just to check simple things during development.
|
21
|
+
|
22
|
+
Unfortunately, for such a tool to be useful in Java, Scala or Groovy development, it must have access to the @CLASSPATH@, not only the compiled project binaries, but also its full list of dependencies. While it is usually possible with such tools to specify the classpath upon startup (e.g. the @-cp@ switch for the Scala shell), this can get extremely tedious for project's with more dependencies, especially when some of these dependencies are defined using @transitive@ artifacts.
|
23
|
+
|
24
|
+
Buildr is capable of easing this workflow by providing full support for the configuration and launch of interactive shells, the relevant shell may be launched simply by invoking the @shell@ task:
|
25
|
+
|
26
|
+
{% highlight sh %}
|
27
|
+
$ buildr shell
|
28
|
+
{% endhighlight %}
|
29
|
+
|
30
|
+
The @shell@ task depends upon @compile@, meaning that any changed source files will be recompiled prior to the shell's launch. Tests will not be run, nor will test files be recompiled. From within the shell itself, you should have access to your project's compilation classpath (anything specified using @compile.with@) as well as the compiled sources for your project.
|
31
|
+
|
32
|
+
The project classpath is determined by checking the current working directory of your system shell (the path from which the @buildr shell@ command was invoked) and recursively finding the relevant project for that directory. Thus, if you have a parent project @foo@ which has sub-projects @bar@ and @baz@, you may invoke an interactive shell for the @baz@ project simply by @cd@-ing into its project directory (or any of its sub-directories) and invoking the @shell@ task. You may also invoke a shell against a specific project by giving its fully-qualified descriptor as a prefix to the @shell@ task:
|
33
|
+
|
34
|
+
{% highlight sh %}
|
35
|
+
$ buildr foo:bar:shell
|
36
|
+
{% endhighlight %}
|
37
|
+
|
38
|
+
h3. Supported Shells
|
39
|
+
|
40
|
+
By default, Buildr will open the interactive shell which corresponds to your project's language. Thus, if your project is using Groovy, it will invoke the @groovysh@ command, configured with the appropriate classpath. If your project is using Scala, then the @shell@ task will invoke the @scala@ command. Unfortunately, the Java language does not define an interactive shell of any kind, however for those projects using exclusively the Java language, Buildr will use the "BeanShell":http://www.beanshell.org/manual/quickstart.html#The_BeanShell_GUI console.
|
41
|
+
|
42
|
+
However, you may still wish to exploit the advantages of an interactive shell from some other JVM language even while working in Java. Alternatively, you may want to use some shell other than the default even when working in a language which has its own. There are two ways to acheive this aim. The quickest way is to explicitly specify the relevant shell at the call-site:
|
43
|
+
|
44
|
+
{% highlight sh %}
|
45
|
+
$ buildr foo:shell:jirb
|
46
|
+
{% endhighlight %}
|
47
|
+
|
48
|
+
This will open the JIRB shell (the JRuby REPL) for the @foo@ project. Whenever you are specifying a shell explicitly in this fashion, you *must* fully-qualify the project name:
|
49
|
+
|
50
|
+
{% highlight sh %}
|
51
|
+
$ buildr shell:jirb # wrong!!
|
52
|
+
{% endhighlight %}
|
53
|
+
|
54
|
+
The above will fail because of the way that Rake tasks are dispatched.
|
55
|
+
|
56
|
+
Obviously, this explicit specification is a little bit clunky. It would be much easier if we could simply say that we *always* want to use the JIRB shell for this particular project. This can be done by using the @shell.using@ directive within your project definition:
|
57
|
+
|
58
|
+
{% highlight ruby %}
|
59
|
+
define 'foo' do
|
60
|
+
shell.using :jirb
|
61
|
+
end
|
62
|
+
{% endhighlight %}
|
63
|
+
|
64
|
+
With this project definition, we can now invoke the @shell@ task and JIRB will be launched, regardless of the default for our project's language:
|
65
|
+
|
66
|
+
{% highlight sh %}
|
67
|
+
$ buildr shell
|
68
|
+
{% endhighlight %}
|
69
|
+
|
70
|
+
Buildr supports several different shell providers, and the framework is flexible enough that additional support can be added almost trivially. The following table gives the complete list of supported shells, their corresponding @shell.using@ descriptor and the language for which they are the default (if applicable):
|
71
|
+
|
72
|
+
|_. Shell Name |_. Descriptor |_. Language |
|
73
|
+
| BeanShell Console | @:bsh@ | Java |
|
74
|
+
| Clojure REPL | @:clj@ | *N/A* |
|
75
|
+
| GroovySH | @:groovysh@ | Groovy |
|
76
|
+
| JRuby IRB | @:jirb@ | *N/A* |
|
77
|
+
| Scala Interpreter | @:scala@ | Scala |
|
78
|
+
|
79
|
+
Note that some of these shells impose certain requirements to enable use. The Groovy shell requires the @GROOVY_HOME@ environment variable to point to the Groovy install path. The Clojure REPL makes a similar requirement of @CLOJURE_HOME@. The JRuby and Scala shells will use @JRUBY_HOME@ and @SCALA_HOME@ respectively if they are defined. However, if these environment variables are not defined, the relevant JAR files will be automatically downloaded from the appropriate Maven2 repository.
|
80
|
+
|
81
|
+
h3. JavaRebel Integration
|
82
|
+
|
83
|
+
"JavaRebel":http://www.zeroturnaround.com/javarebel is a live bytecode reloading solution by Zero Turnaround. It's a lot like the hot code reload feature found in many Java IDE debuggers (like Eclipse and IntelliJ), but capable of handling things like member addition or removal and new class definition. The tool itself is commercial and works with any JVM language, but they do offer a free license for use with Scala classes only.
|
84
|
+
|
85
|
+
If available, Buildr will use JavaRebel when configuring the launch for each interactive shell. Shells launched with JavaRebel integration will automatically receive recompiled changes on the fly without any need to restart the shell. There are some limitations to this which are specific to the shell in question, but for the most part, things Just Work.
|
86
|
+
|
87
|
+
JavaRebel auto-magical integration is done by searching for a valid JavaRebel install path in the following list of environment variables (in order):
|
88
|
+
|
89
|
+
* @REBEL_HOME@
|
90
|
+
* @JAVA_REBEL@
|
91
|
+
* @JAVAREBEL@
|
92
|
+
* @JAVAREBEL_HOME@
|
93
|
+
|
94
|
+
These environment variables may point to either the JavaRebel install directory (e.g. @~/javarebel-2.0.1@), or the JAR file itself (e.g. @~/javarebel-2.0.1/javarebel.jar@). If the path is valid, Buildr will automatically append the appropriate JVM switches to the launch configurations of each shell:
|
95
|
+
|
96
|
+
<pre>$ buildr shell
|
97
|
+
(in ~/foo, development)
|
98
|
+
Compiling foo into ~/foo/target/classes
|
99
|
+
Running java scala.tools.nsc.MainGenericRunner
|
100
|
+
|
101
|
+
#############################################################
|
102
|
+
|
103
|
+
ZeroTurnaround JavaRebel 2.0.1 (200905251513)
|
104
|
+
(c) Copyright Webmedia, Ltd, 2007-2009. All rights reserved.
|
105
|
+
|
106
|
+
This product is licensed to Daniel Spiewak
|
107
|
+
for personal use only.
|
108
|
+
|
109
|
+
#############################################################
|
110
|
+
|
111
|
+
Welcome to Scala version 2.7.4.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_03-p3).
|
112
|
+
Type in expressions to have them evaluated.
|
113
|
+
Type :help for more information.
|
114
|
+
|
115
|
+
scala> </pre>
|
116
|
+
|
117
|
+
Note that Buildr does *not* check to make sure that you have a valid JavaRebel license, so you may end up launching with JavaRebel configured but without the ability to use it (in which case, JavaRebel will print a notification).
|
6
118
|
|
7
119
|
h2(#gems). Using Gems
|
8
120
|
|
@@ -20,7 +132,6 @@ If your build depends on other gems, you will want to specify these dependencies
|
|
20
132
|
|
21
133
|
Use the @build.yaml@ file to specify these dependencies (see "Build Settings":settings_profiles.html#build for more information), for example:
|
22
134
|
|
23
|
-
<notextile>
|
24
135
|
{% highlight yaml %}
|
25
136
|
# This project requires the following gems
|
26
137
|
gems:
|
@@ -30,7 +141,6 @@ gems:
|
|
30
141
|
- mocha
|
31
142
|
- ci_reporter
|
32
143
|
{% endhighlight %}
|
33
|
-
</notextile>
|
34
144
|
|
35
145
|
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.
|
36
146
|
|
@@ -44,12 +154,10 @@ Buildr will install the latest version that matches the version requirement. To
|
|
44
154
|
|
45
155
|
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:
|
46
156
|
|
47
|
-
<notextile>
|
48
157
|
{% highlight sh %}
|
49
158
|
$ ri Buildr::Jetty
|
50
159
|
$ ri Buildr::Jetty.start
|
51
160
|
{% endhighlight %}
|
52
|
-
</notextile>
|
53
161
|
|
54
162
|
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.
|
55
163
|
|
@@ -60,7 +168,6 @@ Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows
|
|
60
168
|
|
61
169
|
Java classes are accessed as static methods on the @Java@ module, for example:
|
62
170
|
|
63
|
-
<notextile>
|
64
171
|
{% highlight ruby %}
|
65
172
|
str = Java.java.lang.String.new('hai!')
|
66
173
|
str.toUpperCase
|
@@ -69,7 +176,6 @@ Java.java.lang.String.isInstance(str)
|
|
69
176
|
=> true
|
70
177
|
Java.com.sun.tools.javac.Main.compile(args)
|
71
178
|
{% endhighlight %}
|
72
|
-
</notextile>
|
73
179
|
|
74
180
|
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.
|
75
181
|
|
@@ -77,11 +183,9 @@ When using an artifact specification, Buildr will automatically download and ins
|
|
77
183
|
|
78
184
|
For example, Ant is loaded as follows:
|
79
185
|
|
80
|
-
<notextile>
|
81
186
|
{% highlight ruby %}
|
82
187
|
Java.classpath << 'org.apache.ant:ant:jar:1.7.0'
|
83
188
|
{% endhighlight %}
|
84
|
-
</notextile>
|
85
189
|
|
86
190
|
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.
|
87
191
|
|
@@ -99,68 +203,56 @@ Buildr provides an addon that allows you start a "dRuby":http://www.ruby-doc.org
|
|
99
203
|
|
100
204
|
Usage:
|
101
205
|
|
102
|
-
<notextile>
|
103
206
|
{% highlight sh %}
|
104
207
|
buildr -r buildr/drb drb:start
|
105
208
|
{% endhighlight %}
|
106
|
-
</notextile>
|
107
209
|
|
108
210
|
To stop the BuildrServer simply use Ctrl+C or kill the process.
|
109
211
|
|
110
212
|
Once the server has been started you can invoke tasks using a simple script:
|
111
213
|
|
112
|
-
<notextile>
|
113
214
|
{% highlight ruby %}
|
114
215
|
#!/usr/bin/env ruby
|
115
216
|
require 'rubygems'
|
116
217
|
require 'buildr/drb'
|
117
218
|
Buildr::DRbApplication.run
|
118
219
|
{% endhighlight %}
|
119
|
-
</notextile>
|
120
220
|
|
121
221
|
Save this script as @dbuildr@, make it executable and use it to invoke tasks.
|
122
|
-
|
222
|
+
|
123
223
|
<notextile>
|
124
224
|
{% highlight sh %}
|
125
225
|
$ dbuildr clean compile
|
126
226
|
{% endhighlight %}
|
127
227
|
</notextile>
|
128
228
|
|
129
|
-
@dbuildr@ will start the BuildrServer if there isn't one already running.
|
130
|
-
Subsequent calls to dbuildr will act as the client and invoke the tasks you
|
131
|
-
provide to the server.
|
132
|
-
If the buildfile has been modified it will be reloaded on the BuildrServer.
|
229
|
+
The @dbuildr@ command will start the BuildrServer if there isn't one already running. Subsequent calls to dbuildr will act as the client and invoke the tasks you provide to the server. If the buildfile has been modified it will be reloaded on the BuildrServer.
|
133
230
|
|
134
231
|
h3(#nailgun). Nailgun
|
135
232
|
|
136
233
|
"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.
|
137
234
|
|
138
|
-
JRuby users need not to create the @dbuildr@ script listed on the previous section, as they can benefit from
|
139
|
-
using a nailgun client to invoke tasks without having to wait for JVM+JRuby to load.
|
235
|
+
JRuby users need not to create the @dbuildr@ script listed on the previous section, as they can benefit from using a nailgun client to invoke tasks without having to wait for JVM+JRuby to load.
|
140
236
|
|
141
237
|
Start the BuildrServer by executing
|
142
238
|
|
143
|
-
<notextile>
|
144
239
|
{% highlight sh %}
|
145
240
|
$ jruby -S buildr -rbuildr/nailgun nailgun:start
|
146
241
|
{% endhighlight %}
|
147
|
-
</notextile>
|
148
242
|
|
149
243
|
To stop the BuildrServer simply use Ctrl+C or kill the process.
|
150
244
|
|
151
245
|
Once the server has been started you can invoke tasks using the nailgun client
|
152
246
|
installed on @$JRUBY_HOME/tool/nailgun/ng@
|
153
247
|
|
154
|
-
<notextile>
|
155
248
|
{% highlight sh %}
|
156
249
|
$ ng clean compile
|
157
250
|
{% endhighlight %}
|
158
|
-
</notextile>
|
159
251
|
|
160
252
|
|
161
253
|
h2(#growl). Growl, Qube
|
162
254
|
|
163
|
-
For OS X users, Buildr supports "Growl":http://growl.info/ out of the box to send "completed and "failed" notifications to the user.
|
255
|
+
For OS X users, Buildr supports "Growl":http://growl.info/ out of the box to send "completed" and "failed" notifications to the user.
|
164
256
|
|
165
257
|
For other platforms or if you want to notify the user differently, Buildr offers two extension points:
|
166
258
|
|
@@ -169,7 +261,6 @@ For other platforms or if you want to notify the user differently, Buildr offers
|
|
169
261
|
|
170
262
|
Here is an example using these extension points to send notifications using "Qube":http://launchpad.net/qube:
|
171
263
|
|
172
|
-
<notextile>
|
173
264
|
{% highlight ruby %}
|
174
265
|
# Send notifications using Qube
|
175
266
|
notify = lambda do |type, title, message|
|
@@ -188,39 +279,48 @@ Buildr.application.on_failure do |title, message, ex|
|
|
188
279
|
notify['failed', title, message]
|
189
280
|
end
|
190
281
|
{% endhighlight %}
|
191
|
-
</notextile>
|
192
282
|
|
193
283
|
You can place this code inside @buildr.rb@ in your home directory.
|
194
284
|
|
195
|
-
h2(#
|
285
|
+
h2(#eclipse). Eclipse
|
196
286
|
|
197
287
|
If you're using Eclipse, you can generate @.classpath@ and @.project@ from your Buildfile and use them to create a project in your workspace:
|
198
288
|
|
199
|
-
<notextile>
|
200
289
|
{% highlight sh %}
|
201
290
|
$ buildr eclipse
|
202
291
|
{% endhighlight %}
|
203
|
-
</notextile>
|
204
292
|
|
205
293
|
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.
|
206
294
|
|
207
|
-
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.
|
295
|
+
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. To have your libraries' source code available in Eclipse, run the @artifacts:sources@ task.
|
208
296
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
297
|
+
You may explicitly specify the nature of your project, for example if you are developing an Eclipse plugin:
|
298
|
+
|
299
|
+
{% highlight ruby %}
|
300
|
+
define 'my-plugin' do
|
301
|
+
eclipse.natures :plugin
|
302
|
+
end
|
214
303
|
{% endhighlight %}
|
215
|
-
</notextile>
|
216
304
|
|
217
|
-
If you
|
305
|
+
The currently supported natures are @:java@, @:scala@ and @:plugin@. Buildr will attempts to auto-detect your project type and apply the most relevant settings by default. If it doesn't or you need something special, you may also explicitly set the nature, container and builders of your project by doing:
|
306
|
+
|
307
|
+
{% highlight ruby %}
|
308
|
+
define 'custom-plugin' do
|
309
|
+
eclipse.natures 'org.eclipse.pde.PluginNature'
|
310
|
+
eclipse.classpath_containers 'org.eclipse.pde.core.requiredPlugins'
|
311
|
+
eclipse.builders ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']
|
312
|
+
end
|
313
|
+
{% endhighlight %}
|
314
|
+
|
315
|
+
One more thing; these settings are inherited hierarchically so you may set them on a parent project if you want to share them across different projects.
|
316
|
+
|
317
|
+
h2(#idea). IntelliJ IDEA
|
318
|
+
|
319
|
+
If you use IntelliJ IDEA, you can generate project files by issuing:
|
218
320
|
|
219
|
-
<notextile>
|
220
321
|
{% highlight sh %}
|
221
322
|
$ buildr idea
|
222
323
|
{% endhighlight %}
|
223
|
-
</notextile>
|
224
324
|
|
225
325
|
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@).
|
226
326
|
|
@@ -233,27 +333,22 @@ h2(#cobertura_emma_jdepend). Cobertura, Emma, JDepend
|
|
233
333
|
|
234
334
|
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.
|
235
335
|
|
236
|
-
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:
|
336
|
+
There are two main tasks for each tool, both of which generate a test coverage report in the @reports/cobertura@ (respectively @reports/emma@) directory. For example:
|
237
337
|
|
238
|
-
<notextile>
|
239
338
|
{% highlight sh %}
|
240
339
|
$ buildr test cobertura:html
|
241
340
|
{% endhighlight %}
|
242
|
-
</notextile>
|
243
341
|
|
244
342
|
As you can guess, the other tasks are @cobertura:xml@, @emma:html@ and @emma:xml@.
|
245
343
|
|
246
344
|
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.
|
247
345
|
|
248
|
-
<notextile>
|
249
346
|
{% highlight sh %}
|
250
347
|
$ buildr subModule:cobertura:html
|
251
348
|
{% endhighlight %}
|
252
|
-
</notextile>
|
253
349
|
|
254
350
|
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:
|
255
351
|
|
256
|
-
<notextile>
|
257
352
|
{% highlight ruby %}
|
258
353
|
define 'someModule' do
|
259
354
|
cobertura.include 'some.package.==*=='
|
@@ -262,42 +357,47 @@ define 'someModule' do
|
|
262
357
|
cobertura.exclude /==*==.Const(ants)?/i
|
263
358
|
end
|
264
359
|
{% endhighlight %}
|
265
|
-
</notextile>
|
266
360
|
|
267
361
|
Emma has @include@ and @exclude@ methods too, but they take glob patterns instead of regexps.
|
268
362
|
|
363
|
+
Cobertura also provides a @cobertura:check@ task. This task is intended to be used as a dependency for other tasks (such as @deploy@) which might wish to fail if coverage is unacceptable. The respective thresholds for task failure may be defined using the @cobertura.check@ configuration namespace. For example:
|
364
|
+
|
365
|
+
{% highlight ruby %}
|
366
|
+
define 'someModule' do
|
367
|
+
cobertura.check.branch_rate = 75
|
368
|
+
cobertura.check.line_rate = 100
|
369
|
+
cobertura.check.total_line_rate = 98
|
370
|
+
|
371
|
+
task(:deploy).enhance 'cobertura:check'
|
372
|
+
end
|
373
|
+
{% endhighlight %}
|
374
|
+
|
375
|
+
The @cobertura:check@ task supports all of the configuration parameters allowed by the @cobertura-check@ Ant task (as "documented here":http://cobertura.sourceforge.net/anttaskreference.html). Configuration parameters are "Ruby-ized" (as demonstrated in the example above).
|
376
|
+
|
269
377
|
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
378
|
|
271
|
-
<notextile>
|
272
379
|
{% highlight sh %}
|
273
380
|
$ buildr jdepend:swing
|
274
381
|
{% endhighlight %}
|
275
|
-
</notextile>
|
276
382
|
|
277
383
|
The other two tasks are @jdepend:text@ and @jdepend:xml@.
|
278
384
|
|
279
385
|
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
386
|
|
281
|
-
<notextile>
|
282
387
|
{% highlight ruby %}
|
283
388
|
require 'buildr/java/cobertura'
|
284
389
|
require 'buildr/java/emma'
|
285
390
|
require 'buildr/jdepend'
|
286
391
|
{% endhighlight %}
|
287
|
-
</notextile>
|
288
392
|
|
289
393
|
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
394
|
|
291
395
|
Another option is to require it from the command line (@--require@ or @-r@), for example:
|
292
396
|
|
293
|
-
<notextile>
|
294
|
-
<notextile>
|
295
397
|
{% highlight sh %}
|
296
398
|
$ buildr --require buildr/jdepend jdepend:swing
|
297
399
|
$ buildr -rbuildr/java/cobertura cobertura:html
|
298
400
|
{% endhighlight %}
|
299
|
-
</notextile>
|
300
|
-
</notextile>
|
301
401
|
|
302
402
|
|
303
403
|
h2(#anything_ruby). Anything Ruby Can Do
|
@@ -308,7 +408,6 @@ We already showed you one example where Ruby could help. You can use Ruby to ma
|
|
308
408
|
|
309
409
|
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:
|
310
410
|
|
311
|
-
<notextile>
|
312
411
|
{% highlight ruby %}
|
313
412
|
bins = file('target/bin'=>FileList[_('src/main/dist/bin/==*==')]) do |task|
|
314
413
|
mkpath task.name
|
@@ -316,11 +415,9 @@ bins = file('target/bin'=>FileList[_('src/main/dist/bin/==*==')]) do |task|
|
|
316
415
|
chmod 0755, FileList[task.name + '/==*==.sh'], :verbose=>false
|
317
416
|
end
|
318
417
|
{% endhighlight %}
|
319
|
-
</notextile>
|
320
418
|
|
321
419
|
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:
|
322
420
|
|
323
|
-
<notextile>
|
324
421
|
{% highlight ruby %}
|
325
422
|
def distro(project, id)
|
326
423
|
project.package(:zip, :id=>id).path("#{id}-#{version}").tap do |zip|
|
@@ -338,22 +435,18 @@ def distro(project, id)
|
|
338
435
|
end
|
339
436
|
end
|
340
437
|
{% endhighlight %}
|
341
|
-
</notextile>
|
342
438
|
|
343
439
|
And then use it in the project definition:
|
344
440
|
|
345
|
-
<notextile>
|
346
441
|
{% highlight ruby %}
|
347
442
|
define 'distro-axis2' do
|
348
443
|
parent.distro(self, "#{parent.id}-war") { |zip|
|
349
444
|
zip.include project('ode:axis2-war').package(:war), :as=>'ode.war' }
|
350
445
|
end
|
351
446
|
{% endhighlight %}
|
352
|
-
</notextile>
|
353
447
|
|
354
448
|
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:
|
355
449
|
|
356
|
-
<notextile>
|
357
450
|
{% highlight ruby %}
|
358
451
|
sources = projects.map { |prj| prj.compile.sources.
|
359
452
|
map { |src| FileList["#{src}/**/*.java"] } }.flatten
|
@@ -361,5 +454,4 @@ puts "There are #{source.size} source files"
|
|
361
454
|
lines = sources.inject(0) { |lines, src| lines += File.readlines(src).size }
|
362
455
|
puts "That contain #{lines} lines"
|
363
456
|
{% endhighlight %}
|
364
|
-
</notextile>
|
365
457
|
|
data/doc/packaging.textile
CHANGED
@@ -5,29 +5,23 @@ title: Packaging
|
|
5
5
|
|
6
6
|
For our next trick, we're going to try and create an artifact ourselves. We're going to start with:
|
7
7
|
|
8
|
-
<notextile>
|
9
8
|
{% highlight ruby %}
|
10
9
|
package :jar
|
11
10
|
{% endhighlight %}
|
12
|
-
</notextile>
|
13
11
|
|
14
12
|
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:
|
15
13
|
|
16
|
-
<notextile>
|
17
14
|
{% highlight ruby %}
|
18
15
|
package :war
|
19
16
|
{% endhighlight %}
|
20
|
-
</notextile>
|
21
17
|
|
22
18
|
The easy case is always easy, but sometimes we have more complicated use cases which we'll address through the rest of this section.
|
23
19
|
|
24
20
|
Now let's run the build, test cases and create these packages:
|
25
21
|
|
26
|
-
<notextile>
|
27
22
|
{% highlight sh %}
|
28
23
|
$ buildr package
|
29
24
|
{% endhighlight %}
|
30
|
-
</notextile>
|
31
25
|
|
32
26
|
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.
|
33
27
|
|
@@ -38,12 +32,10 @@ h2(#referencing). Specifying And Referencing Packages
|
|
38
32
|
|
39
33
|
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:
|
40
34
|
|
41
|
-
<notextile>
|
42
35
|
{% highlight ruby %}
|
43
36
|
package :jar
|
44
37
|
package :type=>:jar
|
45
38
|
{% endhighlight %}
|
46
|
-
</notextile>
|
47
39
|
|
48
40
|
If you do not specify a package type, Buildr will attempt to infer one.
|
49
41
|
|
@@ -51,11 +43,9 @@ In the documentation you will find a number of tasks dealing with specific packa
|
|
51
43
|
|
52
44
|
To package a particular file, use the @:file@ argument, for example:
|
53
45
|
|
54
|
-
<notextile>
|
55
46
|
{% highlight ruby %}
|
56
47
|
package :zip, :file=>_('target/interesting.zip')
|
57
48
|
{% endhighlight %}
|
58
|
-
</notextile>
|
59
49
|
|
60
50
|
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.
|
61
51
|
|
@@ -65,7 +55,6 @@ Most often you will want to use the second form to generate packages that are al
|
|
65
55
|
|
66
56
|
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:
|
67
57
|
|
68
|
-
<notextile>
|
69
58
|
{% highlight ruby %}
|
70
59
|
define 'killer-app', :version=>'1.0' do
|
71
60
|
# Generates silly-1.0.jar
|
@@ -82,7 +71,6 @@ define 'killer-app', :version=>'1.0' do
|
|
82
71
|
end
|
83
72
|
end
|
84
73
|
{% endhighlight %}
|
85
|
-
</notextile>
|
86
74
|
|
87
75
|
The file name is determined from the identifier, version number, classifier and extension associated with that packaging type.
|
88
76
|
|
@@ -92,12 +80,10 @@ A single project can create multiple packages. For example, a Java project may
|
|
92
80
|
|
93
81
|
You can use the @packages@ method to obtain a list of all packages defined in the project, for example:
|
94
82
|
|
95
|
-
<notextile>
|
96
83
|
{% highlight ruby %}
|
97
84
|
project('killer-app:teh-impl').packages.first
|
98
85
|
project('killer-app:teh-impl').packages.select { |pkg| pkg.type == :zip }
|
99
86
|
{% endhighlight %}
|
100
|
-
</notextile>
|
101
87
|
|
102
88
|
|
103
89
|
h2(#zip). Packaging ZIPs
|
@@ -106,41 +92,33 @@ ZIP is the most common form of packaging, used by default when no other packagin
|
|
106
92
|
|
107
93
|
Let's start by including additional files in the ZIP package. We're going to include the @target/docs@ directory and @README@ file:
|
108
94
|
|
109
|
-
<notextile>
|
110
95
|
{% highlight ruby %}
|
111
96
|
package(:zip).include _('target/docs'), 'README'
|
112
97
|
{% endhighlight %}
|
113
|
-
</notextile>
|
114
98
|
|
115
99
|
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.
|
116
100
|
|
117
101
|
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:
|
118
102
|
|
119
|
-
<notextile>
|
120
103
|
{% highlight ruby %}
|
121
104
|
package(:zip).include('target/docs').
|
122
105
|
exclude('target/docs/**/*.{draft,raw}')
|
123
106
|
{% endhighlight %}
|
124
|
-
</notextile>
|
125
107
|
|
126
108
|
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:
|
127
109
|
|
128
|
-
<notextile>
|
129
110
|
{% highlight ruby %}
|
130
111
|
package(:zip).include 'target/docs', :path=>"#{id}-#{version}"
|
131
112
|
{% endhighlight %}
|
132
|
-
</notextile>
|
133
113
|
|
134
114
|
If you need to use the @:path@ option repeatedly, consider using the @tap@ method instead. For example:
|
135
115
|
|
136
|
-
<notextile>
|
137
116
|
{% highlight ruby %}
|
138
117
|
package(:zip).path("#{id}-#{version}").tap do |path|
|
139
118
|
path.include 'target/docs'
|
140
119
|
path.include 'README'
|
141
120
|
end
|
142
121
|
{% endhighlight %}
|
143
|
-
</notextile>
|
144
122
|
|
145
123
|
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.
|
146
124
|
|
@@ -148,20 +126,16 @@ p(note). To allow you to spread files across different paths, the include/exclud
|
|
148
126
|
|
149
127
|
If you need to include a file or directory under a different name, use the @:as@ option. For example:
|
150
128
|
|
151
|
-
<notextile>
|
152
129
|
{% highlight ruby %}
|
153
130
|
package(:zip).include('corporate-logo-350x240.png', :as=>'logo.png')
|
154
131
|
{% endhighlight %}
|
155
|
-
</notextile>
|
156
132
|
|
157
133
|
You can also use @:as=>'.'@ to include all files from the given directory. For example:
|
158
134
|
|
159
|
-
<notextile>
|
160
135
|
{% highlight ruby %}
|
161
136
|
package(:zip).include 'target/docs/*'
|
162
137
|
package(:zip).include 'target/docs', :as=>'.'
|
163
138
|
{% endhighlight %}
|
164
|
-
</notextile>
|
165
139
|
|
166
140
|
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.
|
167
141
|
|
@@ -171,20 +145,16 @@ If you need to get rid of all the included files, call the @clean@ method. Some
|
|
171
145
|
|
172
146
|
You can also merge two ZIP files together, expanding the content of one ZIP into the other. For example:
|
173
147
|
|
174
|
-
<notextile>
|
175
148
|
{% highlight ruby %}
|
176
149
|
package(:zip).merge 'part1.zip', 'part2.zip'
|
177
150
|
{% endhighlight %}
|
178
|
-
</notextile>
|
179
151
|
|
180
152
|
If you need to be more selective, you can apply the include/exclude pattern to the expanded ZIP. For example:
|
181
153
|
|
182
|
-
<notextile>
|
183
154
|
{% highlight ruby %}
|
184
155
|
# Everything but the libs
|
185
156
|
package(:zip).merge('bigbad.war').exclude('libs/**/*')
|
186
157
|
{% endhighlight %}
|
187
|
-
</notextile>
|
188
158
|
|
189
159
|
|
190
160
|
h2(#jar). Packaging JARs
|
@@ -193,19 +163,15 @@ JAR packages extend ZIP packages with support for Manifest files and the META-IN
|
|
193
163
|
|
194
164
|
You can tell the JAR package to include a particular Manifest file:
|
195
165
|
|
196
|
-
<notextile>
|
197
166
|
{% highlight ruby %}
|
198
167
|
package(:jar).with :manifest=>_('src/main/MANIFEST.MF')
|
199
168
|
{% endhighlight %}
|
200
|
-
</notextile>
|
201
169
|
|
202
170
|
Or generate a manifest from a hash:
|
203
171
|
|
204
|
-
<notextile>
|
205
172
|
{% highlight ruby %}
|
206
173
|
package(:jar).with :manifest=>{ 'Copyright'=>'Acme Inc (C) 2007' }
|
207
174
|
{% endhighlight %}
|
208
|
-
</notextile>
|
209
175
|
|
210
176
|
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.
|
211
177
|
|
@@ -213,37 +179,29 @@ In large projects, where all the packages use the same manifest, it's easier to
|
|
213
179
|
|
214
180
|
For example, we can get the same result by specifying this at the top project:
|
215
181
|
|
216
|
-
<notextile>
|
217
182
|
{% highlight ruby %}
|
218
183
|
manifest['Copyright'] = 'Acme Inc (C) 2007'
|
219
184
|
{% endhighlight %}
|
220
|
-
</notextile>
|
221
185
|
|
222
186
|
If you need to mix-in the project's manifest with values that only one package uses, you can do so easily:
|
223
187
|
|
224
|
-
<notextile>
|
225
188
|
{% highlight ruby %}
|
226
189
|
package(:jar).with :manifest=>manifest.merge('Main-Class'=>'com.acme.Main')
|
227
190
|
{% endhighlight %}
|
228
|
-
</notextile>
|
229
191
|
|
230
192
|
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:
|
231
193
|
|
232
|
-
<notextile>
|
233
194
|
{% highlight ruby %}
|
234
195
|
meta_inf << file('DISCLAIMER') << file('NOTICE')
|
235
196
|
{% endhighlight %}
|
236
|
-
</notextile>
|
237
197
|
|
238
198
|
If you have a @LICENSE@ file, it's already included in the @meta_inf@ list of files.
|
239
199
|
|
240
200
|
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:
|
241
201
|
|
242
|
-
<notextile>
|
243
202
|
{% highlight ruby %}
|
244
203
|
package(:jar).clean.include( only_these_files )
|
245
204
|
{% endhighlight %}
|
246
|
-
</notextile>
|
247
205
|
|
248
206
|
|
249
207
|
h2(#war). Packaging WARs
|
@@ -254,25 +212,20 @@ Without much prompting, @package :war@ picks the contents of the @src/main/webap
|
|
254
212
|
|
255
213
|
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:
|
256
214
|
|
257
|
-
<notextile>
|
258
215
|
{% highlight ruby %}
|
259
216
|
package(:war).with :classes=>_('target/additional')
|
260
217
|
{% endhighlight %}
|
261
|
-
</notextile>
|
262
218
|
|
263
219
|
If you want to include a different set of libraries other than the default:
|
264
220
|
|
265
|
-
<notextile>
|
266
221
|
{% highlight ruby %}
|
267
222
|
package(:war).with :libs=>MYSQL_JDBC
|
268
223
|
{% endhighlight %}
|
269
|
-
</notextile>
|
270
224
|
|
271
225
|
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@.
|
272
226
|
|
273
227
|
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:
|
274
228
|
|
275
|
-
<notextile>
|
276
229
|
{% highlight ruby %}
|
277
230
|
# Add an artifact to the existing set:
|
278
231
|
package(:war).libs += artifacts(MYSQL_JDBC)
|
@@ -282,19 +235,16 @@ package(:war).libs -= artifacts(LOG4J)
|
|
282
235
|
puts 'Artifacts included in WAR package:'
|
283
236
|
puts package(:war).libs.map(&:to_spec)
|
284
237
|
{% endhighlight %}
|
285
|
-
</notextile>
|
286
238
|
|
287
239
|
|
288
240
|
h2(#aar). Packaging AARs
|
289
241
|
|
290
242
|
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.
|
291
243
|
|
292
|
-
<notextile>
|
293
244
|
{% highlight ruby %}
|
294
245
|
package(:aar).with(:libs=>'log4j:log4j:jar:1.1')
|
295
246
|
package(:aar).with(:services_xml=>_('target/services.xml'), :wsdls=>_('target/*.wsdl'))
|
296
247
|
{% endhighlight %}
|
297
|
-
</notextile>
|
298
248
|
|
299
249
|
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.
|
300
250
|
|
@@ -304,7 +254,6 @@ The @wsdls@ attribute is a collection of file names or glob patterns for WSDL fi
|
|
304
254
|
|
305
255
|
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:
|
306
256
|
|
307
|
-
<notextile>
|
308
257
|
{% highlight ruby %}
|
309
258
|
# Host name depends on environment.
|
310
259
|
host = ENV['ENV'] == 'test' ? 'test.host' : 'ws.example.com'
|
@@ -313,7 +262,6 @@ filter.from('src/main/axis2').into('target').
|
|
313
262
|
package(:aar).wsdls.clear
|
314
263
|
package(:aar).with(:services_xml=>_('target/services.xml'), :wsdls=>_('target/==*==.wsdl'))
|
315
264
|
{% endhighlight %}
|
316
|
-
</notextile>
|
317
265
|
|
318
266
|
|
319
267
|
h2(#ear). Packaging EARs
|
@@ -330,18 +278,15 @@ EAR packages support four component types:
|
|
330
278
|
|
331
279
|
This example shows two ways for adding components built by other projects:
|
332
280
|
|
333
|
-
<notextile>
|
334
281
|
{% highlight ruby %}
|
335
282
|
package(:ear) << project('coolWebService').package(:war)
|
336
283
|
package(:ear).add project('commonLib') # By default, the JAR package
|
337
284
|
{% endhighlight %}
|
338
|
-
</notextile>
|
339
285
|
|
340
286
|
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.
|
341
287
|
|
342
288
|
Here are three examples:
|
343
289
|
|
344
|
-
<notextile>
|
345
290
|
{% highlight ruby %}
|
346
291
|
# Assumed to be a shared library.
|
347
292
|
package(:ear).add 'org.springframework:spring:jar:2.6'
|
@@ -350,13 +295,11 @@ package(:ear).add :ejb=>project('beanery')
|
|
350
295
|
# Adding component with specific package type.
|
351
296
|
package(:ear).add project('client'), :type=>:jar
|
352
297
|
{% endhighlight %}
|
353
|
-
</notextile>
|
354
298
|
|
355
299
|
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@.
|
356
300
|
|
357
301
|
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:
|
358
302
|
|
359
|
-
<notextile>
|
360
303
|
{% highlight ruby %}
|
361
304
|
# Specify once per component.
|
362
305
|
package(:ear).add project('coolWebService').package(:war), :path=>'coolServices'
|
@@ -364,7 +307,6 @@ package(:ear).add project('coolWebService').package(:war), :path=>'coolServices'
|
|
364
307
|
package(:ear).dirs[:war] = 'coolServices'
|
365
308
|
package(:ear) << project('coolWebService').package(:war)
|
366
309
|
{% endhighlight %}
|
367
|
-
</notextile>
|
368
310
|
|
369
311
|
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.
|
370
312
|
|
@@ -374,12 +316,10 @@ EAR packages include an @application.xml@ file in the @META-INF@ directory that
|
|
374
316
|
|
375
317
|
Again, by example:
|
376
318
|
|
377
|
-
<notextile>
|
378
319
|
{% highlight ruby %}
|
379
320
|
package(:ear).display_name = 'MyCoolWebService'
|
380
321
|
package(:ear).add project('coolWebService').package(:war), :context-root=>'coolness'
|
381
322
|
{% endhighlight %}
|
382
|
-
</notextile>
|
383
323
|
|
384
324
|
If you need to disable the context root (e.g. for Portlets), set @context_root@ to @false@.
|
385
325
|
|
@@ -388,12 +328,10 @@ h2(#tar). Packaging Tars and GZipped Tars
|
|
388
328
|
|
389
329
|
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.
|
390
330
|
|
391
|
-
<notextile>
|
392
331
|
{% highlight ruby %}
|
393
332
|
package(:tar).include _('target/docs'), 'README'
|
394
333
|
package(:tgz).include _('target/docs'), 'README'
|
395
334
|
{% endhighlight %}
|
396
|
-
</notextile>
|
397
335
|
|
398
336
|
The first line creates a Tar archive with the extension @.tar@, the second creates a GZipped Tar archive with the extension @.tgz@.
|
399
337
|
|
@@ -406,35 +344,27 @@ You can bring in the artifacts you need from remote repositories and install the
|
|
406
344
|
|
407
345
|
So let's create these packages and install them in the local repository where other projects can access them:
|
408
346
|
|
409
|
-
<notextile>
|
410
347
|
{% highlight sh %}
|
411
348
|
$ buildr install
|
412
349
|
{% endhighlight %}
|
413
|
-
</notextile>
|
414
350
|
|
415
351
|
If you changes your mind you can always:
|
416
352
|
|
417
|
-
<notextile>
|
418
353
|
{% highlight sh %}
|
419
354
|
$ buildr uninstall
|
420
355
|
{% endhighlight %}
|
421
|
-
</notextile>
|
422
356
|
|
423
357
|
That works between projects you build on the same machine. Now let's share these artifacts with other developers through a remote repository:
|
424
358
|
|
425
|
-
<notextile>
|
426
359
|
{% highlight sh %}
|
427
360
|
$ buildr upload
|
428
361
|
{% endhighlight %}
|
429
|
-
</notextile>
|
430
362
|
|
431
363
|
Of course, you'll need to tell Buildr about the release server:
|
432
364
|
|
433
|
-
<notextile>
|
434
365
|
{% highlight ruby %}
|
435
366
|
repositories.release_to = 'sftp://john:secret@release/usr/share/repo'
|
436
367
|
{% endhighlight %}
|
437
|
-
</notextile>
|
438
368
|
|
439
369
|
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.
|
440
370
|
|
@@ -442,7 +372,6 @@ The URL in this example contains the release server ("release"), path to reposit
|
|
442
372
|
|
443
373
|
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:
|
444
374
|
|
445
|
-
<notextile>
|
446
375
|
{% highlight ruby %}
|
447
376
|
# build.rb, loaded first
|
448
377
|
repositories.release_to[:username] = 'john'
|
@@ -451,13 +380,11 @@ repositories.release_to[:password] = 'secret'
|
|
451
380
|
# Buildfile, loaded next
|
452
381
|
repositories.release_to[:url] = 'sftp://release/usr/share/repo'
|
453
382
|
{% endhighlight %}
|
454
|
-
</notextile>
|
455
383
|
|
456
384
|
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).
|
457
385
|
|
458
386
|
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:
|
459
387
|
|
460
|
-
<notextile>
|
461
388
|
{% highlight ruby %}
|
462
389
|
# We'll let some other task decide how to create 'docs'
|
463
390
|
task 'upload'=>'docs' do
|
@@ -465,48 +392,39 @@ task 'upload'=>'docs' do
|
|
465
392
|
uri.upload file('docs')
|
466
393
|
end
|
467
394
|
{% endhighlight %}
|
468
|
-
</notextile>
|
469
395
|
|
470
396
|
|
471
397
|
h2(#source_javadoc). Packaging Sources and JavaDocs
|
472
398
|
|
473
399
|
IDEs can take advantage of source packages to help you debug and trace through compiled code. We'll start with a simple example:
|
474
400
|
|
475
|
-
<notextile>
|
476
401
|
{% highlight ruby %}
|
477
402
|
package :sources
|
478
403
|
{% endhighlight %}
|
479
|
-
</notextile>
|
480
404
|
|
481
405
|
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.
|
482
406
|
|
483
407
|
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:
|
484
408
|
|
485
|
-
<notextile>
|
486
409
|
{% highlight ruby %}
|
487
410
|
package :javadoc
|
488
411
|
javadoc :windowtitle=>'Buggy but Works'
|
489
412
|
{% endhighlight %}
|
490
|
-
</notextile>
|
491
413
|
|
492
414
|
By default Buildr picks the project's description for the window title.
|
493
415
|
|
494
416
|
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:
|
495
417
|
|
496
|
-
<notextile>
|
497
418
|
{% highlight ruby %}
|
498
419
|
package_with_sources
|
499
420
|
package_with_javadoc
|
500
421
|
{% endhighlight %}
|
501
|
-
</notextile>
|
502
422
|
|
503
423
|
You can also tell it to be selective using the @:only@ and @:except@ options.
|
504
424
|
For example:
|
505
425
|
|
506
|
-
<notextile>
|
507
426
|
{% highlight ruby %}
|
508
427
|
package_with_javadoc :except=>'la-web'
|
509
428
|
{% endhighlight %}
|
510
|
-
</notextile>
|
511
429
|
|
512
430
|
We packaged the code, but will it actually work? Let's see "what the tests say":testing.html.
|