buildr 1.3.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +998 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +45 -0
- data/_buildr +29 -0
- data/_jbuildr +29 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +90 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +65 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +88 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +211 -0
- data/doc/building.textile +244 -0
- data/doc/contributing.textile +252 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +79 -0
- data/doc/extending.textile +186 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +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/images/zbuildr.tif +0 -0
- data/doc/index.textile +69 -0
- data/doc/installing.textile +266 -0
- data/doc/languages.textile +459 -0
- data/doc/mailing_lists.textile +25 -0
- data/doc/more_stuff.textile +457 -0
- data/doc/packaging.textile +430 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +271 -0
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +72 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +280 -0
- data/doc/testing.textile +222 -0
- data/etc/KEYS +151 -0
- data/lib/buildr.rb +36 -0
- data/lib/buildr/core.rb +35 -0
- data/lib/buildr/core/application.rb +656 -0
- data/lib/buildr/core/build.rb +452 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +608 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +866 -0
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +723 -0
- data/lib/buildr/core/transports.rb +559 -0
- data/lib/buildr/core/util.rb +449 -0
- data/lib/buildr/groovy.rb +19 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +334 -0
- 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/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +190 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +212 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +459 -0
- data/lib/buildr/java/cobertura.rb +274 -0
- data/lib/buildr/java/commands.rb +213 -0
- data/lib/buildr/java/compiler.rb +349 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/jruby.rb +117 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
- data/lib/buildr/java/packaging.rb +716 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +353 -0
- data/lib/buildr/java/tests.rb +333 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +749 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +238 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +73 -0
- data/lib/buildr/packaging/ziptask.rb +316 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +25 -0
- data/lib/buildr/scala/bdd.rb +109 -0
- data/lib/buildr/scala/compiler.rb +195 -0
- 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 +157 -0
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +92 -0
- data/rakelib/jekylltask.rb +120 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +149 -0
- data/rakelib/rspec.rake +73 -0
- data/rakelib/setup.rake +54 -0
- data/rakelib/stage.rake +213 -0
- data/rakelib/stage.rake~ +213 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +502 -0
- data/spec/core/build_spec.rb +677 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +583 -0
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +762 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +537 -0
- data/spec/core/util_spec.rb +67 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +240 -0
- data/spec/ide/eclipse_spec.rb +501 -0
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant_spec.rb +33 -0
- data/spec/java/bdd_spec.rb +382 -0
- data/spec/java/cobertura_spec.rb +85 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +119 -0
- data/spec/java/java_spec.rb +124 -0
- data/spec/java/packaging_spec.rb +1134 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +493 -0
- data/spec/packaging/archive_spec.rb +527 -0
- data/spec/packaging/artifact_namespace_spec.rb +654 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +684 -0
- data/spec/sandbox.rb +142 -0
- data/spec/scala/bdd_spec.rb +119 -0
- data/spec/scala/compiler_spec.rb +284 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +261 -0
- data/spec/spec_helpers.rb +340 -0
- data/spec/version_requirement_spec.rb +129 -0
- metadata +383 -0
@@ -0,0 +1,430 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Packaging
|
4
|
+
---
|
5
|
+
|
6
|
+
For our next trick, we're going to try and create an artifact ourselves. We're going to start with:
|
7
|
+
|
8
|
+
{% highlight ruby %}
|
9
|
+
package :jar
|
10
|
+
{% endhighlight %}
|
11
|
+
|
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:
|
13
|
+
|
14
|
+
{% highlight ruby %}
|
15
|
+
package :war
|
16
|
+
{% endhighlight %}
|
17
|
+
|
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.
|
19
|
+
|
20
|
+
Now let's run the build, test cases and create these packages:
|
21
|
+
|
22
|
+
{% highlight sh %}
|
23
|
+
$ buildr package
|
24
|
+
{% endhighlight %}
|
25
|
+
|
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.
|
27
|
+
|
28
|
+
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.
|
29
|
+
|
30
|
+
|
31
|
+
h2(#referencing). Specifying And Referencing Packages
|
32
|
+
|
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:
|
34
|
+
|
35
|
+
{% highlight ruby %}
|
36
|
+
package :jar
|
37
|
+
package :type=>:jar
|
38
|
+
{% endhighlight %}
|
39
|
+
|
40
|
+
If you do not specify a package type, Buildr will attempt to infer one.
|
41
|
+
|
42
|
+
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.
|
43
|
+
|
44
|
+
To package a particular file, use the @:file@ argument, for example:
|
45
|
+
|
46
|
+
{% highlight ruby %}
|
47
|
+
package :zip, :file=>_('target/interesting.zip')
|
48
|
+
{% endhighlight %}
|
49
|
+
|
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.
|
51
|
+
|
52
|
+
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.
|
53
|
+
|
54
|
+
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":#install_upload).
|
55
|
+
|
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:
|
57
|
+
|
58
|
+
{% highlight ruby %}
|
59
|
+
define 'killer-app', :version=>'1.0' do
|
60
|
+
# Generates silly-1.0.jar
|
61
|
+
package :jar, :id=>'silly'
|
62
|
+
|
63
|
+
# Generates killer-app-la-web-1.x.war
|
64
|
+
project 'la-web' do
|
65
|
+
package :war, :version=>'1.x'
|
66
|
+
end
|
67
|
+
|
68
|
+
# Generates killer-app-the-api-1.0-sources.zip
|
69
|
+
project 'teh-api' do
|
70
|
+
package :zip, :classifier=>'sources'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
{% endhighlight %}
|
74
|
+
|
75
|
+
The file name is determined from the identifier, version number, classifier and extension associated with that packaging type.
|
76
|
+
|
77
|
+
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.
|
78
|
+
|
79
|
+
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.
|
80
|
+
|
81
|
+
You can use the @packages@ method to obtain a list of all packages defined in the project, for example:
|
82
|
+
|
83
|
+
{% highlight ruby %}
|
84
|
+
project('killer-app:teh-impl').packages.first
|
85
|
+
project('killer-app:teh-impl').packages.select { |pkg| pkg.type == :zip }
|
86
|
+
{% endhighlight %}
|
87
|
+
|
88
|
+
|
89
|
+
h2(#zip). Packaging ZIPs
|
90
|
+
|
91
|
+
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.
|
92
|
+
|
93
|
+
Let's start by including additional files in the ZIP package. We're going to include the @target/docs@ directory and @README@ file:
|
94
|
+
|
95
|
+
{% highlight ruby %}
|
96
|
+
package(:zip).include _('target/docs'), 'README'
|
97
|
+
{% endhighlight %}
|
98
|
+
|
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.
|
100
|
+
|
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:
|
102
|
+
|
103
|
+
{% highlight ruby %}
|
104
|
+
package(:zip).include('target/docs').
|
105
|
+
exclude('target/docs/**/*.{draft,raw}')
|
106
|
+
{% endhighlight %}
|
107
|
+
|
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:
|
109
|
+
|
110
|
+
{% highlight ruby %}
|
111
|
+
package(:zip).include 'target/docs', :path=>"#{id}-#{version}"
|
112
|
+
{% endhighlight %}
|
113
|
+
|
114
|
+
If you need to use the @:path@ option repeatedly, consider using the @tap@ method instead. For example:
|
115
|
+
|
116
|
+
{% highlight ruby %}
|
117
|
+
package(:zip).path("#{id}-#{version}").tap do |path|
|
118
|
+
path.include 'target/docs'
|
119
|
+
path.include 'README'
|
120
|
+
end
|
121
|
+
{% endhighlight %}
|
122
|
+
|
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.
|
124
|
+
|
125
|
+
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.
|
126
|
+
|
127
|
+
If you need to include a file or directory under a different name, use the @:as@ option. For example:
|
128
|
+
|
129
|
+
{% highlight ruby %}
|
130
|
+
package(:zip).include('corporate-logo-350x240.png', :as=>'logo.png')
|
131
|
+
{% endhighlight %}
|
132
|
+
|
133
|
+
You can also use @:as=>'.'@ to include all files from the given directory. For example:
|
134
|
+
|
135
|
+
{% highlight ruby %}
|
136
|
+
package(:zip).include 'target/docs/*'
|
137
|
+
package(:zip).include 'target/docs', :as=>'.'
|
138
|
+
{% endhighlight %}
|
139
|
+
|
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.
|
141
|
+
|
142
|
+
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=>'.'@.
|
143
|
+
|
144
|
+
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.
|
145
|
+
|
146
|
+
You can also merge two ZIP files together, expanding the content of one ZIP into the other. For example:
|
147
|
+
|
148
|
+
{% highlight ruby %}
|
149
|
+
package(:zip).merge 'part1.zip', 'part2.zip'
|
150
|
+
{% endhighlight %}
|
151
|
+
|
152
|
+
If you need to be more selective, you can apply the include/exclude pattern to the expanded ZIP. For example:
|
153
|
+
|
154
|
+
{% highlight ruby %}
|
155
|
+
# Everything but the libs
|
156
|
+
package(:zip).merge('bigbad.war').exclude('libs/**/*')
|
157
|
+
{% endhighlight %}
|
158
|
+
|
159
|
+
|
160
|
+
h2(#jar). Packaging JARs
|
161
|
+
|
162
|
+
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.
|
163
|
+
|
164
|
+
You can tell the JAR package to include a particular Manifest file:
|
165
|
+
|
166
|
+
{% highlight ruby %}
|
167
|
+
package(:jar).with :manifest=>_('src/main/MANIFEST.MF')
|
168
|
+
{% endhighlight %}
|
169
|
+
|
170
|
+
Or generate a manifest from a hash:
|
171
|
+
|
172
|
+
{% highlight ruby %}
|
173
|
+
package(:jar).with :manifest=>{ 'Copyright'=>'Acme Inc (C) 2007' }
|
174
|
+
{% endhighlight %}
|
175
|
+
|
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.
|
177
|
+
|
178
|
+
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.
|
179
|
+
|
180
|
+
For example, we can get the same result by specifying this at the top project:
|
181
|
+
|
182
|
+
{% highlight ruby %}
|
183
|
+
manifest['Copyright'] = 'Acme Inc (C) 2007'
|
184
|
+
{% endhighlight %}
|
185
|
+
|
186
|
+
If you need to mix-in the project's manifest with values that only one package uses, you can do so easily:
|
187
|
+
|
188
|
+
{% highlight ruby %}
|
189
|
+
package(:jar).with :manifest=>manifest.merge('Main-Class'=>'com.acme.Main')
|
190
|
+
{% endhighlight %}
|
191
|
+
|
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:
|
193
|
+
|
194
|
+
{% highlight ruby %}
|
195
|
+
meta_inf << file('DISCLAIMER') << file('NOTICE')
|
196
|
+
{% endhighlight %}
|
197
|
+
|
198
|
+
If you have a @LICENSE@ file, it's already included in the @meta_inf@ list of files.
|
199
|
+
|
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:
|
201
|
+
|
202
|
+
{% highlight ruby %}
|
203
|
+
package(:jar).clean.include( only_these_files )
|
204
|
+
{% endhighlight %}
|
205
|
+
|
206
|
+
|
207
|
+
h2(#war). Packaging WARs
|
208
|
+
|
209
|
+
Pretty much everything you know about JARs works the same way for WARs, so let's just look at the differences.
|
210
|
+
|
211
|
+
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.
|
212
|
+
|
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:
|
214
|
+
|
215
|
+
{% highlight ruby %}
|
216
|
+
package(:war).with :classes=>_('target/additional')
|
217
|
+
{% endhighlight %}
|
218
|
+
|
219
|
+
If you want to include a different set of libraries other than the default:
|
220
|
+
|
221
|
+
{% highlight ruby %}
|
222
|
+
package(:war).with :libs=>MYSQL_JDBC
|
223
|
+
{% endhighlight %}
|
224
|
+
|
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@.
|
226
|
+
|
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:
|
228
|
+
|
229
|
+
{% highlight ruby %}
|
230
|
+
# Add an artifact to the existing set:
|
231
|
+
package(:war).libs += artifacts(MYSQL_JDBC)
|
232
|
+
# Remove an artifact from the existing set:
|
233
|
+
package(:war).libs -= artifacts(LOG4J)
|
234
|
+
# List all the artifacts:
|
235
|
+
puts 'Artifacts included in WAR package:'
|
236
|
+
puts package(:war).libs.map(&:to_spec)
|
237
|
+
{% endhighlight %}
|
238
|
+
|
239
|
+
|
240
|
+
h2(#aar). Packaging AARs
|
241
|
+
|
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.
|
243
|
+
|
244
|
+
{% highlight ruby %}
|
245
|
+
package(:aar).with(:libs=>'log4j:log4j:jar:1.1')
|
246
|
+
package(:aar).with(:services_xml=>_('target/services.xml'), :wsdls=>_('target/*.wsdl'))
|
247
|
+
{% endhighlight %}
|
248
|
+
|
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.
|
250
|
+
|
251
|
+
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.
|
252
|
+
|
253
|
+
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.
|
254
|
+
|
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:
|
256
|
+
|
257
|
+
{% highlight ruby %}
|
258
|
+
# Host name depends on environment.
|
259
|
+
host = ENV['ENV'] == 'test' ? 'test.host' : 'ws.example.com'
|
260
|
+
filter.from('src/main/axis2').into('target').
|
261
|
+
include('services.xml', '==*==.wsdl').using('http_port'=>'8080', 'http_host'=>host)
|
262
|
+
package(:aar).wsdls.clear
|
263
|
+
package(:aar).with(:services_xml=>_('target/services.xml'), :wsdls=>_('target/==*==.wsdl'))
|
264
|
+
{% endhighlight %}
|
265
|
+
|
266
|
+
|
267
|
+
h2(#ear). Packaging EARs
|
268
|
+
|
269
|
+
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.
|
270
|
+
|
271
|
+
EAR packages support four component types:
|
272
|
+
|
273
|
+
|_. Argument |_. Component |
|
274
|
+
| @:war@ | J2EE Web Application (WAR). |
|
275
|
+
| @:ejb@ | Enterprise Java Bean (JAR). |
|
276
|
+
| @:jar@ | J2EE Application Client (JAR). |
|
277
|
+
| @:lib@ | Shared library (JAR). |
|
278
|
+
|
279
|
+
This example shows two ways for adding components built by other projects:
|
280
|
+
|
281
|
+
{% highlight ruby %}
|
282
|
+
package(:ear) << project('coolWebService').package(:war)
|
283
|
+
package(:ear).add project('commonLib') # By default, the JAR package
|
284
|
+
{% endhighlight %}
|
285
|
+
|
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.
|
287
|
+
|
288
|
+
Here are three examples:
|
289
|
+
|
290
|
+
{% highlight ruby %}
|
291
|
+
# Assumed to be a shared library.
|
292
|
+
package(:ear).add 'org.springframework:spring:jar:2.6'
|
293
|
+
# Component type mapped to package.
|
294
|
+
package(:ear).add :ejb=>project('beanery')
|
295
|
+
# Adding component with specific package type.
|
296
|
+
package(:ear).add project('client'), :type=>:jar
|
297
|
+
{% endhighlight %}
|
298
|
+
|
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@.
|
300
|
+
|
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:
|
302
|
+
|
303
|
+
{% highlight ruby %}
|
304
|
+
# Specify once per component.
|
305
|
+
package(:ear).add project('coolWebService').package(:war), :path=>'coolServices'
|
306
|
+
# Configure once and apply to all added components.
|
307
|
+
package(:ear).dirs[:war] = 'coolServices'
|
308
|
+
package(:ear) << project('coolWebService').package(:war)
|
309
|
+
{% endhighlight %}
|
310
|
+
|
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.
|
312
|
+
|
313
|
+
* *display-name* -- The application's display name defaults to the project's identifier. You can change that by setting the @display_name@ attribute.
|
314
|
+
|
315
|
+
* *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.
|
316
|
+
|
317
|
+
Again, by example:
|
318
|
+
|
319
|
+
{% highlight ruby %}
|
320
|
+
package(:ear).display_name = 'MyCoolWebService'
|
321
|
+
package(:ear).add project('coolWebService').package(:war), :context-root=>'coolness'
|
322
|
+
{% endhighlight %}
|
323
|
+
|
324
|
+
If you need to disable the context root (e.g. for Portlets), set @context_root@ to @false@.
|
325
|
+
|
326
|
+
|
327
|
+
h2(#tar). Packaging Tars and GZipped Tars
|
328
|
+
|
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.
|
330
|
+
|
331
|
+
{% highlight ruby %}
|
332
|
+
package(:tar).include _('target/docs'), 'README'
|
333
|
+
package(:tgz).include _('target/docs'), 'README'
|
334
|
+
{% endhighlight %}
|
335
|
+
|
336
|
+
The first line creates a Tar archive with the extension @.tar@, the second creates a GZipped Tar archive with the extension @.tgz@.
|
337
|
+
|
338
|
+
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@.
|
339
|
+
|
340
|
+
|
341
|
+
h2(#install_upload). Installing and Uploading
|
342
|
+
|
343
|
+
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.
|
344
|
+
|
345
|
+
So let's create these packages and install them in the local repository where other projects can access them:
|
346
|
+
|
347
|
+
{% highlight sh %}
|
348
|
+
$ buildr install
|
349
|
+
{% endhighlight %}
|
350
|
+
|
351
|
+
If you changes your mind you can always:
|
352
|
+
|
353
|
+
{% highlight sh %}
|
354
|
+
$ buildr uninstall
|
355
|
+
{% endhighlight %}
|
356
|
+
|
357
|
+
That works between projects you build on the same machine. Now let's share these artifacts with other developers through a remote repository:
|
358
|
+
|
359
|
+
{% highlight sh %}
|
360
|
+
$ buildr upload
|
361
|
+
{% endhighlight %}
|
362
|
+
|
363
|
+
Of course, you'll need to tell Buildr about the release server:
|
364
|
+
|
365
|
+
{% highlight ruby %}
|
366
|
+
repositories.release_to = 'sftp://john:secret@release/usr/share/repo'
|
367
|
+
{% endhighlight %}
|
368
|
+
|
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.
|
370
|
+
|
371
|
+
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.
|
372
|
+
|
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:
|
374
|
+
|
375
|
+
{% highlight ruby %}
|
376
|
+
# build.rb, loaded first
|
377
|
+
repositories.release_to[:username] = 'john'
|
378
|
+
repositories.release_to[:password] = 'secret'
|
379
|
+
|
380
|
+
# Buildfile, loaded next
|
381
|
+
repositories.release_to[:url] = 'sftp://release/usr/share/repo'
|
382
|
+
{% endhighlight %}
|
383
|
+
|
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).
|
385
|
+
|
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:
|
387
|
+
|
388
|
+
{% highlight ruby %}
|
389
|
+
# We'll let some other task decide how to create 'docs'
|
390
|
+
task 'upload'=>'docs' do
|
391
|
+
uri = URI("sftp://#{username}:#{password}@var/www/docs")
|
392
|
+
uri.upload file('docs')
|
393
|
+
end
|
394
|
+
{% endhighlight %}
|
395
|
+
|
396
|
+
|
397
|
+
h2(#source_javadoc). Packaging Sources and JavaDocs
|
398
|
+
|
399
|
+
IDEs can take advantage of source packages to help you debug and trace through compiled code. We'll start with a simple example:
|
400
|
+
|
401
|
+
{% highlight ruby %}
|
402
|
+
package :sources
|
403
|
+
{% endhighlight %}
|
404
|
+
|
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.
|
406
|
+
|
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:
|
408
|
+
|
409
|
+
{% highlight ruby %}
|
410
|
+
package :javadoc
|
411
|
+
javadoc :windowtitle=>'Buggy but Works'
|
412
|
+
{% endhighlight %}
|
413
|
+
|
414
|
+
By default Buildr picks the project's description for the window title.
|
415
|
+
|
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:
|
417
|
+
|
418
|
+
{% highlight ruby %}
|
419
|
+
package_with_sources
|
420
|
+
package_with_javadoc
|
421
|
+
{% endhighlight %}
|
422
|
+
|
423
|
+
You can also tell it to be selective using the @:only@ and @:except@ options.
|
424
|
+
For example:
|
425
|
+
|
426
|
+
{% highlight ruby %}
|
427
|
+
package_with_javadoc :except=>'la-web'
|
428
|
+
{% endhighlight %}
|
429
|
+
|
430
|
+
We packaged the code, but will it actually work? Let's see "what the tests say":testing.html.
|
data/doc/preface.textile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
layout: preface
|
3
|
+
---
|
4
|
+
|
5
|
+
p(title). !images/zbuildr.png!
|
6
|
+
|
7
|
+
<ol class='toc'>
|
8
|
+
<li>"Quick Start":quick_start.html</li>
|
9
|
+
<li>"Installing and Running":installing.html</li>
|
10
|
+
<li>"Projects":projects.html</li>
|
11
|
+
<li>"Building":building.html</li>
|
12
|
+
<li>"Artifacts":artifacts.html</li>
|
13
|
+
<li>"Packaging":packaging.html</li>
|
14
|
+
<li>"Testing":testing.html</li>
|
15
|
+
<li>"Settings & Profiles":settings_profiles.html</li>
|
16
|
+
<li>"Languages":languages.html</li>
|
17
|
+
<li>"More Stuff":more_stuff.html</li>
|
18
|
+
<li>"Extending Buildr":extending.html</li>
|
19
|
+
<li>"Contributing":contributing.html</li>
|
20
|
+
</ol>
|
21
|
+
|
22
|
+
|
23
|
+
p(preface). !images/asf-logo.png!
|
24
|
+
|
25
|
+
Copyright 2007-2009 Apache Buildr
|
26
|
+
|
27
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
28
|
+
|
29
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
30
|
+
|
31
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
<div class='preface quotes'>
|
36
|
+
"Daniel Spiewak":http://www.codecommit.com/blog:
|
37
|
+
|
38
|
+
bq. If you think about it, the question isn’t “Why use Buildr?”, it’s really “Why use anything else?” The advantages afforded by Buildr are so substantial, I really can’t see myself going with any other tool, at least not when I have a choice.
|
39
|
+
|
40
|
+
"Tristan Juricek":http://tristanhunt.com/:
|
41
|
+
|
42
|
+
bq. That’s still the strongest sell: it builds everything I need, and as I’ve needed more, I just got things working without a lot of fuss.
|
43
|
+
|
44
|
+
"Matthieu Riou":http://offthelip.org/:
|
45
|
+
|
46
|
+
bq. We used to rely on Ant, with a fairly extensive set of scripts. It worked but was expensive to maintain. The biggest mistake afterward was to migrate to Maven2. I could write pages of rants explaining all the problems we ran into and we still ended up with thousands of lines of XML.
|
47
|
+
|
48
|
+
"Martin Grotzke":http://www.javakaffee.de/blog/:
|
49
|
+
|
50
|
+
bq. The positive side effect for me as a java user is that I learn a little ruby, and that’s easy but lots of fun… :-)
|
51
|
+
</div>
|
52
|
+
|
53
|
+
|
54
|
+
p(preface).
|