buildr 1.2.10 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +566 -268
- data/DISCLAIMER +7 -1
- data/KEYS +151 -0
- data/NOTICE +23 -8
- data/README +122 -22
- data/Rakefile +49 -229
- data/{lib → addon}/buildr/antlr.rb +23 -10
- data/addon/buildr/cobertura.rb +232 -0
- data/{lib → addon}/buildr/hibernate.rb +20 -4
- data/{lib → addon}/buildr/javacc.rb +27 -12
- data/addon/buildr/jdepend.rb +60 -0
- data/{lib → addon}/buildr/jetty.rb +34 -18
- data/addon/buildr/nailgun.rb +892 -0
- data/{lib → addon}/buildr/openjpa.rb +23 -6
- 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/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
- data/{lib → addon}/buildr/xmlbeans.rb +39 -14
- data/bin/buildr +21 -7
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +28 -45
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/{core → buildr/core}/build.rb +91 -77
- data/lib/{core → buildr/core}/checks.rb +116 -95
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/{core → buildr/core}/generate.rb +22 -5
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/{core → buildr/core}/project.rb +468 -213
- data/lib/buildr/core/test.rb +690 -0
- data/lib/{core → buildr/core}/transports.rb +107 -127
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/{java → buildr/ide}/eclipse.rb +86 -60
- data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/{java → buildr/java}/pom.rb +20 -4
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/{java → buildr/packaging}/artifact.rb +170 -179
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
- data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +188 -77
- data/lib/buildr/cobertura.rb +0 -89
- data/lib/buildr/jdepend.rb +0 -40
- data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/scala.rb +0 -368
- data/lib/core/application.rb +0 -188
- data/lib/core/common.rb +0 -562
- data/lib/core/help.rb +0 -72
- data/lib/core/rake_ext.rb +0 -81
- data/lib/java/ant.rb +0 -71
- data/lib/java/compile.rb +0 -589
- data/lib/java/idea.rb +0 -159
- data/lib/java/java.rb +0 -432
- data/lib/java/packaging.rb +0 -581
- data/lib/java/test.rb +0 -795
- data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,178 @@
|
|
1
|
+
h1. Contributing
|
2
|
+
|
3
|
+
Buildr is a community effort, and we welcome all contributors. Here's your
|
4
|
+
chance to get involved and help your fellow developers.
|
5
|
+
|
6
|
+
|
7
|
+
h2. Mailing Lists
|
8
|
+
|
9
|
+
We run two mailing lists, the
|
10
|
+
"buildr-user":http://mail-archives.apache.org/mod_mbox/incubator-buildr-user/
|
11
|
+
mailing list for developers working with Buildr, that would be you if you're
|
12
|
+
using Buildr or interested in using it. There's the
|
13
|
+
"buildr-dev":http://mail-archives.apache.org/mod_mbox/incubator-buildr-dev/
|
14
|
+
mailing list for talking about development of Buildr itself, and
|
15
|
+
"commits":http://mail-archives.apache.org/mod_mbox/incubator-buildr-commits/
|
16
|
+
mailing list for following SVN commits and JIRA issues.
|
17
|
+
|
18
|
+
Check the "mailing lists":mailing_lists.html page for more information on
|
19
|
+
subscribing, searching and posting to the mailing list.
|
20
|
+
|
21
|
+
|
22
|
+
h2. Bugs (aka Issues)
|
23
|
+
|
24
|
+
We really do try to keep bugs to a minimum, and anticipate everything you'll
|
25
|
+
ever want to do with Buildr. We're also, not perfect. So you may have found a
|
26
|
+
bug, or have an enhancement in mind, or better yet, a patch to contribute.
|
27
|
+
Here's what you can do.
|
28
|
+
|
29
|
+
If it's a bug, enhancement or patch, add it to
|
30
|
+
"JIRA":http://issues.apache.org/jira/browse/Buildr. For trivial stuff, that's
|
31
|
+
good enough.
|
32
|
+
|
33
|
+
If it needs more attention, start a discussion over on the mailing list. We
|
34
|
+
will still use JIRA to log the progress, but the mailing list is a better place
|
35
|
+
for talking things through.
|
36
|
+
|
37
|
+
When reporting a bug, please tell us which version of Ruby, Buildr and Java you
|
38
|
+
are using, and also which operating system you are on:
|
39
|
+
|
40
|
+
{{{!sh
|
41
|
+
$ ruby --version
|
42
|
+
$ buildr --version
|
43
|
+
$ java --version
|
44
|
+
}}}
|
45
|
+
|
46
|
+
If you have a patch to submit, do it through
|
47
|
+
"JIRA":http://issues.apache.org/jira/browse/Buildr. We want to make sure
|
48
|
+
Apache gets the right to use your contribution, and the JIRA upload form
|
49
|
+
includes a simple contribution agreement. Lawyer not included.
|
50
|
+
|
51
|
+
|
52
|
+
h2. Source Code
|
53
|
+
|
54
|
+
Did we mention Buildr is an open source project? In fact, when you install
|
55
|
+
Buildr you get all the source code, documentation, test case and everything you
|
56
|
+
need to use it, extend it and patch it. Have a look in your Gem directory.
|
57
|
+
|
58
|
+
But if you want to work with the latest and greatest, you'll want to check out
|
59
|
+
"Buildr from SVN":http://svn.apache.org/repos/asf/incubator/buildr:
|
60
|
+
|
61
|
+
{{{!sh
|
62
|
+
$ svn co http://svn.apache.org/repos/asf/incubator/buildr/trunk buildr
|
63
|
+
}}}
|
64
|
+
|
65
|
+
You can also browse the "Buildr
|
66
|
+
repository":http://svn.apache.org/repos/asf/incubator/buildr.
|
67
|
+
|
68
|
+
Not a fan SVN? We understand. You can also grab a copy of "Buildr from
|
69
|
+
Github":http://github.com/vic/buildr/tree/master:
|
70
|
+
|
71
|
+
{{{!sh
|
72
|
+
$ git clone git://github.com/vic/buildr.git
|
73
|
+
}}}
|
74
|
+
|
75
|
+
To install Buildr from the source directory:
|
76
|
+
|
77
|
+
{{{!sh
|
78
|
+
$ cd buildr
|
79
|
+
$ rake setup install
|
80
|
+
}}}
|
81
|
+
|
82
|
+
When using Buildr for JRuby:
|
83
|
+
|
84
|
+
{{{!sh
|
85
|
+
$ cd buildr
|
86
|
+
$ jruby -S rake setup install
|
87
|
+
}}}
|
88
|
+
|
89
|
+
|
90
|
+
h2. Testing/Specs
|
91
|
+
|
92
|
+
Obviously we won't turn down patches, but we'll love you even more if you
|
93
|
+
include a test case. One that will fail without the patch, and run
|
94
|
+
successfully with it. If not for our love, then think of the benefit to you:
|
95
|
+
once we add that test case, we won't accidentally break that feature in the
|
96
|
+
next release.
|
97
|
+
|
98
|
+
We test using "RSpec":http://rspec.info/, a Behavior-Driven Development test
|
99
|
+
framework. The main difference between RSpec and xUnit is that RSpec helps you
|
100
|
+
formulate test cases in terms of specifications: you describe how the code
|
101
|
+
should behave, and run RSpec to make sure it matches that specification.
|
102
|
+
|
103
|
+
You can run an individual specifications using the @spec@ command, for example:
|
104
|
+
|
105
|
+
{{{!sh
|
106
|
+
$ spec spec/compiler_spec.rb -l 409
|
107
|
+
}}}
|
108
|
+
|
109
|
+
To make sure your change did not break anything else, you can run all the
|
110
|
+
specifications (be patient, we have a lot of these):
|
111
|
+
|
112
|
+
{{{!sh
|
113
|
+
$ rake spec
|
114
|
+
}}}
|
115
|
+
|
116
|
+
We always @rake spec@ before making a release.
|
117
|
+
|
118
|
+
You can also check out the "RSpec report":report.html and "test coverage
|
119
|
+
report":coverage/index.html for the current version of Buildr. And if you want to help us on the journey to 100% test coverage, we'll be ever so grateful!
|
120
|
+
|
121
|
+
|
122
|
+
h2. Documentation
|
123
|
+
|
124
|
+
Yes, we do make typos, spelling errors and sometimes we write things that don't
|
125
|
+
make sense, so if you find a documentation bug, or want to help make the
|
126
|
+
documentation even better, here's the way to do it.
|
127
|
+
|
128
|
+
For simple typos and quick fixes, just send a message to the mailing list or
|
129
|
+
log an issue in JIRA.
|
130
|
+
|
131
|
+
If you end up rewriting a significant piece of text, or add new documentation
|
132
|
+
(your rock!), send a patch. Making documentation patches is fairly easy. All
|
133
|
+
the documentation is generated from text files in the @doc/pages@ directory, so
|
134
|
+
all you need to do is check it out from SVN, edit, and @svn diff@ to create a
|
135
|
+
patch.
|
136
|
+
|
137
|
+
We use "Textile":http://www.textism.com/tools/textile/ as the markup language,
|
138
|
+
it takes all of a few minutes to learn, it's intuitive to use, and produces
|
139
|
+
clean HTML. Also check out the "Textile Quick
|
140
|
+
Reference":http://hobix.com/textile/quick.html.
|
141
|
+
|
142
|
+
You can always check the documentation to see which conventions we use, and
|
143
|
+
also a couple of extensions we have for styling source code (with syntax
|
144
|
+
highlighting!) and handling footnotes. The table of contents is auto-generated
|
145
|
+
form H1/H2 headers.
|
146
|
+
|
147
|
+
The tool we use for this is called Docter, which we developed specifically for
|
148
|
+
Buildr, and use to create the Web site and printable PDF. If you want to try
|
149
|
+
it out you'll need to first @gem install docter@. To generate a copy of the
|
150
|
+
Web site, simple run @rake html@ .
|
151
|
+
|
152
|
+
If you're thinking of editing the docs, and using @rake html@ to see what the
|
153
|
+
HTML looks like, you may want to try something simpler. Start by running the
|
154
|
+
Docter Web server with @rake docter@ and then point your browser at
|
155
|
+
@http://localhost:3000@. To see your edits, simply refresh the page.
|
156
|
+
|
157
|
+
Generating the PDF is a bit more tricky, we use the HTML in combination with
|
158
|
+
print media CSS stylesheets and run them through the wonderful
|
159
|
+
"PrinceXML":http://www.princexml.com/, so you'll need to install PrinceXML
|
160
|
+
first before you can @rake pdf@.
|
161
|
+
|
162
|
+
|
163
|
+
h2. Contributors
|
164
|
+
|
165
|
+
Here is the list of people who are actively working and committing on Buildr:
|
166
|
+
|
167
|
+
*"Assaf Arkin":http://labnotes.org* (assaf at apache.org)
|
168
|
+
|
169
|
+
*Alex Boisvert*
|
170
|
+
|
171
|
+
*"Matthieu Riou":http://offthelip.org*
|
172
|
+
|
173
|
+
*Victor Hugo Borja* (vborja at apache.org)
|
174
|
+
|
175
|
+
Currently a Java Developer at
|
176
|
+
"http://jwmsolutions.com":http://jwmsolutions.com, Victor has been enjoying and
|
177
|
+
using Apache's software since 1999 when he started with Java, now he prefers
|
178
|
+
programming Ruby and is happy to help on Apache's first ruby project.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
h1. Download
|
2
|
+
|
3
|
+
|
4
|
+
h2. Installing Buildr
|
5
|
+
|
6
|
+
The easiest way to install Buildr is using the fabulous RubyGems package
|
7
|
+
manager. Of course, you will need either Ruby or JRuby, and we recommend a
|
8
|
+
recent version of RubyGems and if this sounds foreign to you, don't worry.
|
9
|
+
We'll show you how to install Buildr on Linux, OS/X, Windows and JRuby in the
|
10
|
+
"Getting Started guide":getting_started.html, we even provide automated
|
11
|
+
installation scripts.
|
12
|
+
|
13
|
+
|
14
|
+
h2. Binaries and Source Code
|
15
|
+
|
16
|
+
|
17
|
+
p(note). When downloading from files please check the
|
18
|
+
"md5sum":http://www.apache.org/dev/release-signing#md5 and verify the
|
19
|
+
"OpenPGP":http://www.apache.org/dev/release-signing#openpgp compatible
|
20
|
+
signature from the main Apache site. This
|
21
|
+
"KEYS":http://www.apache.org/dist/incubator/buildr/KEYS file contains the
|
22
|
+
public keys used for signing releases. It is recommended that (when possible) a
|
23
|
+
web of trust is used to confirm the identity of these keys. For more
|
24
|
+
information, please see the "Apache Release
|
25
|
+
FAQ":http://www.apache.org/dev/release.html.
|
@@ -0,0 +1,229 @@
|
|
1
|
+
h1. Extending Buildr
|
2
|
+
|
3
|
+
h2. Organizing Tasks
|
4
|
+
|
5
|
+
A couple of things we learned while working on Buildr. Being able to write
|
6
|
+
your own Rake tasks is a very powerful feature. But if you find yourself
|
7
|
+
doing the same thing over and over, you might also want to consider functions.
|
8
|
+
They give you a lot more power and easy abstractions.
|
9
|
+
|
10
|
+
For example, we use OpenJPA in several projects. It's a very short task, but
|
11
|
+
each time I have to go back to the OpenJPA documentation to figure out how to
|
12
|
+
set the Ant MappingTool task, tell Ant how to define it. After the second
|
13
|
+
time, you're recognizing a pattern and it's just easier to write a function
|
14
|
+
that does all that for you.
|
15
|
+
|
16
|
+
Compare this:
|
17
|
+
|
18
|
+
{{{!ruby
|
19
|
+
file('derby.sql') do
|
20
|
+
REQUIRES = [
|
21
|
+
'org.apache.openjpa:openjpa-all:jar:0.9.7-incubating',
|
22
|
+
'commons-collections:commons-collections:jar:3.1',
|
23
|
+
. . .
|
24
|
+
'net.sourceforge.serp:serp:jar:1.11.0' ]
|
25
|
+
ant('openjpa') do |ant|
|
26
|
+
ant.taskdef :name=>'mapping',
|
27
|
+
:classname=>'org.apache.openjpa.jdbc.ant.MappingToolTask',
|
28
|
+
:classpath=>REQUIRES.join(File::PATH_SEPARATOR)
|
29
|
+
ant.mapping :schemaAction=>'build', :sqlFile=>task.name,
|
30
|
+
:ignoreErrors=>true do
|
31
|
+
ant.config :propertiesFile=>_(:source, :main, :sql, 'derby.xml')
|
32
|
+
ant.classpath :path=>projects('store', 'utils' ).
|
33
|
+
flatten.map(&:to_s).join(File::PATH_SEPARATOR)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
}}}
|
38
|
+
|
39
|
+
To this:
|
40
|
+
|
41
|
+
{{{!ruby
|
42
|
+
file('derby.sql') do
|
43
|
+
mapping_tool :action=>'build', :sql=>task.name,
|
44
|
+
:properties=>_(:source, :main, :sql, 'derby.xml'),
|
45
|
+
:classpath=>projects('store', 'utils')
|
46
|
+
end
|
47
|
+
}}}
|
48
|
+
|
49
|
+
I prefer the second. It's easier to look at the Buildfile and understand what
|
50
|
+
it does. It's easier to maintain when you only have to look at the important
|
51
|
+
information.
|
52
|
+
|
53
|
+
But just using functions is not always enough. You end up with a Buildfile
|
54
|
+
containing a lot of code that clearly doesn't belong there. For starters, I
|
55
|
+
recommend putting it in the @tasks@ directory. Write it into a file with a
|
56
|
+
@.rake@ extension and place that in the @tasks@ directory next to the
|
57
|
+
Buildfile. Buildr will automatically pick it up and load it for you.
|
58
|
+
|
59
|
+
If you want to share these pre-canned definitions between projects, you have a
|
60
|
+
few more options. You can share the @tasks@ directory using SVN externals.
|
61
|
+
Another mechanism with better version control is to package all these tasks,
|
62
|
+
functions and modules into a "Gem":http://rubygems.org/ and require it from
|
63
|
+
your Buildfile. You can run your own internal Gem server for that.
|
64
|
+
|
65
|
+
For individual task files, you can also use
|
66
|
+
"Sake":http://errtheblog.com/post/6069 for system-wide Rake tasks deployment.
|
67
|
+
|
68
|
+
|
69
|
+
h2. Creating Extensions
|
70
|
+
|
71
|
+
The basic mechanism for extending projects in Buildr are Ruby modules. In
|
72
|
+
fact, base features like compiling and testing are all developed in the form
|
73
|
+
of modules, and then added to the core Project class.
|
74
|
+
|
75
|
+
A module defines instance methods that are then mixed into the project and
|
76
|
+
become instance methods of the project. There are two general ways for
|
77
|
+
extending projects. You can extend all projects by including the module in
|
78
|
+
Project:
|
79
|
+
|
80
|
+
{{{!ruby
|
81
|
+
class Project
|
82
|
+
include MyExtension
|
83
|
+
end
|
84
|
+
}}}
|
85
|
+
|
86
|
+
You can also extend a given project instance and only that instance by
|
87
|
+
extending it with the module:
|
88
|
+
|
89
|
+
{{{!ruby
|
90
|
+
define 'foo' do
|
91
|
+
extend MyExtension
|
92
|
+
end
|
93
|
+
}}}
|
94
|
+
|
95
|
+
Some extensions require tighter integration with the project, specifically for
|
96
|
+
setting up tasks and properties, or for configuring tasks based on the project
|
97
|
+
definition. You can do that by adding callbacks to the process.
|
98
|
+
|
99
|
+
The easiest way to add callbacks is by incorporating the Extension module in
|
100
|
+
your own extension, and using the various class methods to define callback
|
101
|
+
behavior.
|
102
|
+
|
103
|
+
|_. Method |_. Usage |
|
104
|
+
| @first_time@ | This block will be called once for any particular
|
105
|
+
extension. You can use this to setup top-level and local tasks. |
|
106
|
+
| @before_define@ | This block is called once for the project with the project
|
107
|
+
instance, right before running the project definition. You can use this to add
|
108
|
+
tasks and set properties that will be used in the project definition. |
|
109
|
+
| @after_define@ | This block is called once for the project with the project
|
110
|
+
instance, right after running the project definition. You can use this to do
|
111
|
+
any post-processing that depends on the project definition. |
|
112
|
+
|
113
|
+
This example illustrates how to write a simple extension:
|
114
|
+
|
115
|
+
{{{!ruby
|
116
|
+
module LinesOfCode
|
117
|
+
include Extension
|
118
|
+
|
119
|
+
first_time do
|
120
|
+
# Define task not specific to any projet.
|
121
|
+
desc 'Count lines of code in current project'
|
122
|
+
Project.local_task('loc')
|
123
|
+
end
|
124
|
+
|
125
|
+
before_define do |project|
|
126
|
+
# Define the loc task for this particular project.
|
127
|
+
define_task 'loc' do |task|
|
128
|
+
lines = task.prerequisites.map { |path| Dir["#{path}/**/*"] }.flatten.uniq.
|
129
|
+
inject(0) { |total, file| total + File.readlines(file).count }
|
130
|
+
puts "Project #{project.name} has #{lines} lines of code"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
after_define do |project|
|
135
|
+
# Now that we know all the source directories, add them.
|
136
|
+
task('loc'=>compile.sources + compile.test.sources)
|
137
|
+
end
|
138
|
+
|
139
|
+
# To use this method in your project:
|
140
|
+
# loc path_1, path_2
|
141
|
+
def loc(*paths)
|
142
|
+
task('loc'=>paths)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
class Buildr::Project
|
148
|
+
include LinesOfCode
|
149
|
+
end
|
150
|
+
}}}
|
151
|
+
|
152
|
+
|
153
|
+
h2. Using Alternative Layouts
|
154
|
+
|
155
|
+
Buildr follows a common convention for project layouts: Java source files
|
156
|
+
appear in @src/main/java@ and compile to @target/classes@, resources are
|
157
|
+
copied over from @src/main/resources@ and so forth. Not all projects follow
|
158
|
+
this convention, so it's now possible to specify an alternative project
|
159
|
+
layout.
|
160
|
+
|
161
|
+
The default layout is available in @Layout.default@, and all projects inherit
|
162
|
+
it. You can set @Layout.default@ to your own layout, or define a project with
|
163
|
+
a given layout (recommended) by setting the @:layout@ property. Projects
|
164
|
+
inherit the layout from their parent projects. For example:
|
165
|
+
|
166
|
+
{{{!ruby
|
167
|
+
define 'foo', :layout=>my_layout do
|
168
|
+
...
|
169
|
+
end
|
170
|
+
}}}
|
171
|
+
|
172
|
+
A layout is an object that implements the @expand@ method. The easiest way to
|
173
|
+
define a custom layout is to create a new @Layout@ object and specify mapping
|
174
|
+
between names used by Buildr and actual paths within the project. For
|
175
|
+
example:
|
176
|
+
|
177
|
+
{{{!ruby
|
178
|
+
my_layout = Layout.new
|
179
|
+
my_layout[:source, :main, :java] = 'java'
|
180
|
+
my_layout[:source, :main, :resources] = 'resources'
|
181
|
+
}}}
|
182
|
+
|
183
|
+
Partial expansion also works, so you can specify the above layout using:
|
184
|
+
|
185
|
+
{{{!ruby
|
186
|
+
my_layout = Layout.new
|
187
|
+
my_layout[:source, :main] = ''
|
188
|
+
}}}
|
189
|
+
|
190
|
+
If you need anything more complex, you can always subclass @Layout@ and add
|
191
|
+
special handling in the @expand@ method, you'll find one such example in the
|
192
|
+
API documentation.
|
193
|
+
|
194
|
+
The built-in tasks expand lists of symbols into relative paths, using the
|
195
|
+
following convention:
|
196
|
+
|
197
|
+
|_. Path |_. Expands to |
|
198
|
+
| @:source, :main, <lang/usage>@ | Directory containing source files for a
|
199
|
+
given language or usage, for example, @:java@, @:resources@, @:webapp@. |
|
200
|
+
| @:source, :test, <lang/usage>@ | Directory containing test files for a given
|
201
|
+
language or usage, for example, @:java@, @:resources@. |
|
202
|
+
| @:target, :generated@ | Target directory for generated code
|
203
|
+
(typically source code). |
|
204
|
+
| @:target, :main, <lang/usage>@ | Target directory for compiled code, for
|
205
|
+
example, @:classes@, @:resources@. |
|
206
|
+
| @:target, :test, <lang/usage>@ | Target directory for compile test cases,
|
207
|
+
for example, @:classes@, @:resources@. |
|
208
|
+
| @:reports, <framework/usage>@ | Target directory for generated reports, for
|
209
|
+
example, @:junit@, @:coverage@. |
|
210
|
+
|
211
|
+
All tasks are encouraged to use the same convention, and whenever possible, we
|
212
|
+
recommend using the project's @path_to@ method to expand a list of symbols
|
213
|
+
into a path, or use the appropriate path when available. For example:
|
214
|
+
|
215
|
+
{{{!ruby
|
216
|
+
define 'bad' do
|
217
|
+
# This may not be the real target.
|
218
|
+
puts 'Compiling to ' + path_to('target/classes')
|
219
|
+
# This will break with different layouts.
|
220
|
+
package(:jar).include 'src/main/etc/*'
|
221
|
+
end
|
222
|
+
|
223
|
+
define 'good' do
|
224
|
+
# This is always the compiler's target.
|
225
|
+
puts 'Compiling to ' + compile.target.to_s
|
226
|
+
# This will work with different layouts.
|
227
|
+
package(:jar).include path_to(:source, :main, :etc, '*')
|
228
|
+
end
|
229
|
+
}}}
|
@@ -0,0 +1,337 @@
|
|
1
|
+
h1. Getting Started
|
2
|
+
|
3
|
+
h2. Installing Buildr
|
4
|
+
|
5
|
+
The installation instructions are slightly different for each operating system.
|
6
|
+
If you are using Ruby, pick the one that best matches your operating system and
|
7
|
+
target platform.
|
8
|
+
|
9
|
+
p(note). The current release of Buildr for Ruby does not work with Java 6 and
|
10
|
+
can only be used with Java 1.5 or earlier. "Buildr for JRuby":#jruby works
|
11
|
+
nicely with Java 6, consider using that instead.
|
12
|
+
|
13
|
+
|
14
|
+
h3. Linux
|
15
|
+
|
16
|
+
To get started you will need a recent version of Ruby, Ruby Gems and build
|
17
|
+
tools for compiling native libraries (@make@, @gcc@ and standard headers).
|
18
|
+
|
19
|
+
On *RedHat/Fedora* you can use yum to install Ruby and RubyGems, and then
|
20
|
+
upgrade to the most recent version of RubyGems:
|
21
|
+
|
22
|
+
{{{!sh
|
23
|
+
$ sudo yum install ruby rubygems ruby-devel gcc
|
24
|
+
$ sudo gem update --system
|
25
|
+
}}}
|
26
|
+
|
27
|
+
On *Ubuntu* you have to install several packages:
|
28
|
+
|
29
|
+
{{{!sh
|
30
|
+
$ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
|
31
|
+
}}}
|
32
|
+
|
33
|
+
The Debian package for @rubygems@ will not allow you to install Buildr, so you
|
34
|
+
need to install RubyGems from source:
|
35
|
+
|
36
|
+
{{{!sh
|
37
|
+
$ curl -OL http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
|
38
|
+
$ tar xzf rubygems-1.0.1.tgz
|
39
|
+
$ cd rubygems-1.0.1
|
40
|
+
$ sudo ruby setup.rb
|
41
|
+
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
|
42
|
+
}}}
|
43
|
+
|
44
|
+
Before installing Buildr, please set the @JAVA_HOME@ environment variable to
|
45
|
+
point to your JDK distribution. Next, use Ruby Gem to install Buildr:
|
46
|
+
|
47
|
+
{{{!sh
|
48
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
|
49
|
+
}}}
|
50
|
+
|
51
|
+
To upgrade to a new version or install a specific version:
|
52
|
+
|
53
|
+
{{{!sh
|
54
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
|
55
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.0
|
56
|
+
}}}
|
57
|
+
|
58
|
+
You can also use this script "to install Buildr on
|
59
|
+
Linux":scripts/install-linux.sh. This script will install Buildr or if already
|
60
|
+
installed, upgrade to a more recent version. It will also install Ruby 1.8.6
|
61
|
+
if not already installed (using @yum@ or @apt-get@) and upgrage RubyGems to
|
62
|
+
1.0.1.
|
63
|
+
|
64
|
+
|
65
|
+
h3. OS/X
|
66
|
+
|
67
|
+
OS/X 10.5 (Leopard) comes with a recent version of Ruby 1.8.6. OS/X 10.4
|
68
|
+
(Tiger) includes an older version of Ruby, we recommend you first install Ruby
|
69
|
+
1.8.6 using MacPorts (@sudo port install ruby rb-rubygems@), Fink or the
|
70
|
+
"Ruby One-Click Installer for OS/X":http://rubyosx.rubyforge.org/.
|
71
|
+
|
72
|
+
We recommend you first upgrade to the latest version of Ruby gems:
|
73
|
+
|
74
|
+
{{{!sh
|
75
|
+
$ sudo gem update --system
|
76
|
+
}}}
|
77
|
+
|
78
|
+
Before installing Buildr, please set the @JAVA_HOME@ environment variable to
|
79
|
+
point to your JDK distribution:
|
80
|
+
|
81
|
+
{{{!sh
|
82
|
+
$ export JAVA_HOME=/Library/Java/Home
|
83
|
+
}}}
|
84
|
+
|
85
|
+
To install Buildr:
|
86
|
+
|
87
|
+
{{{!sh
|
88
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
|
89
|
+
}}}
|
90
|
+
|
91
|
+
To upgrade to a new version or install a specific version:
|
92
|
+
|
93
|
+
{{{!sh
|
94
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
|
95
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.0
|
96
|
+
}}}
|
97
|
+
|
98
|
+
You can also use this script "to install Buildr on
|
99
|
+
OS/X":scripts/install-osx.sh. This script will install Buildr or if already
|
100
|
+
installed, upgrade to a more recent version. It will also install Ruby 1.8.6
|
101
|
+
if not already installed (using MacPorts) and upgrage RubyGems to 1.0.1.
|
102
|
+
|
103
|
+
|
104
|
+
h3. Windows
|
105
|
+
|
106
|
+
If you don't already have Ruby installed, now is the time to do it. The
|
107
|
+
easiest way to install Ruby is using the "one-click
|
108
|
+
installer":http://rubyinstaller.rubyforge.org/.
|
109
|
+
|
110
|
+
We recommend you first upgrade to the latest version of Ruby gems:
|
111
|
+
|
112
|
+
{{{!sh
|
113
|
+
> gem update --system
|
114
|
+
}}}
|
115
|
+
|
116
|
+
Before installing Buildr, please set the @JAVA_HOME@ environment variable to
|
117
|
+
point to your JDK distribution. Next, use Ruby Gem to install Buildr:
|
118
|
+
|
119
|
+
{{{!sh
|
120
|
+
> gem install buildr
|
121
|
+
}}}
|
122
|
+
|
123
|
+
Buildr uses several libraries that include native extensions. During
|
124
|
+
installation it will ask you to pick a platform for these libraries. By
|
125
|
+
selecting @mswin32@ it will download and install pre-compiled DLLs for these
|
126
|
+
extensions.
|
127
|
+
|
128
|
+
To upgrade to a new version or install a specific version:
|
129
|
+
|
130
|
+
{{{!sh
|
131
|
+
> gem update buildr
|
132
|
+
> gem install buildr -v 1.3.0
|
133
|
+
}}}
|
134
|
+
|
135
|
+
|
136
|
+
h3. JRuby
|
137
|
+
|
138
|
+
If you don't already have JRuby 1.1 or later installed, you can download it
|
139
|
+
from the "JRuby site":http://dist.codehaus.org/jruby/.
|
140
|
+
|
141
|
+
After uncompressing JRuby, update your @PATH@ to include both @java@ and @jruby@
|
142
|
+
executables.
|
143
|
+
|
144
|
+
For Linux and OS/X:
|
145
|
+
|
146
|
+
{{{!sh
|
147
|
+
$ export PATH=$PATH:[path to JRuby]/bin:$JAVA_HOME/bin
|
148
|
+
$ gem install buildr
|
149
|
+
}}}
|
150
|
+
|
151
|
+
For Windows:
|
152
|
+
|
153
|
+
{{{!sh
|
154
|
+
> set PATH=%PATH%;[path to JRuby]/bin;%JAVA_HOME%/bin
|
155
|
+
> gem install buildr
|
156
|
+
}}}
|
157
|
+
|
158
|
+
To upgrade to a new version or install a specific version:
|
159
|
+
|
160
|
+
{{{!sh
|
161
|
+
$ sudo gem update buildr
|
162
|
+
$ sudo gem install buildr -v 1.3.0
|
163
|
+
}}}
|
164
|
+
|
165
|
+
You can also use this script "to install Buildr on
|
166
|
+
JRuby":scripts/install-jruby.sh. This script will install Buildr or if already
|
167
|
+
installed, upgrade to a more recent version. If necessary, it will also
|
168
|
+
install JRuby 1.1 in @/opt/jruby@ and update the @PATH@ variable in
|
169
|
+
@~/.bash_profile@ or @~/.profile@.
|
170
|
+
|
171
|
+
*Important: Running JRuby and Ruby side by side*
|
172
|
+
|
173
|
+
Ruby and JRuby maintain separate Gem repositories, and in fact install
|
174
|
+
slightly different versions of the Buildr Gem (same functionality, different
|
175
|
+
dependencies). Installing Buildr for Ruby does not install it for JRuby and
|
176
|
+
vice versa.
|
177
|
+
|
178
|
+
If you have JRuby installed but not Ruby, the @gem@ and @buildr@ commands will
|
179
|
+
use JRuby. If you have both JRuby and Ruby installed, follow the instructions
|
180
|
+
below. To find out if you have Ruby installed (some operating systems include
|
181
|
+
it by default), run @ruby --version@ from the command line.
|
182
|
+
|
183
|
+
To work exclusively with JRuby, make sure it shows first on the path, for example,
|
184
|
+
by setting @PATH=/opt/jruby/bin:$PATH@.
|
185
|
+
|
186
|
+
You can use JRuby and Ruby side by side, by running scripts with the @-S@
|
187
|
+
command line argument. For example:
|
188
|
+
|
189
|
+
{{{!
|
190
|
+
$ # with Ruby
|
191
|
+
$ ruby -S gem install buildr
|
192
|
+
$ ruby -S buildr
|
193
|
+
$ # with JRuby
|
194
|
+
$ jruby -S gem install buildr
|
195
|
+
$ jruby -S buildr
|
196
|
+
}}}
|
197
|
+
|
198
|
+
Run @buildr --version@ from the command line to find which version of Buildr
|
199
|
+
you are using by default. If you see @(JRuby ...)@, Buildr is running on that
|
200
|
+
version of JRuby.
|
201
|
+
|
202
|
+
|
203
|
+
h2. Conventions
|
204
|
+
|
205
|
+
Lines that start with @$@ are command lines, for example:
|
206
|
+
|
207
|
+
{{{!sh
|
208
|
+
$ # Run Buildr
|
209
|
+
$ buildr
|
210
|
+
}}}
|
211
|
+
|
212
|
+
Lines that start with @=>@ show output from the console or the result of a
|
213
|
+
method, for example:
|
214
|
+
|
215
|
+
{{{!sh
|
216
|
+
puts 'Hello world'
|
217
|
+
=> "Hello world"
|
218
|
+
}}}
|
219
|
+
|
220
|
+
And as you guessed, everything else is Buildfile Ruby or Java code. You can
|
221
|
+
figure out which language is which.
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
h2. Running Buildr
|
226
|
+
|
227
|
+
You need a *Buildfile*, a build script that tells Buildr all about the projects
|
228
|
+
it's building, what they contain, what to produce, and so on. The Buildfile
|
229
|
+
resides in the root directory of your project. We'll talk more about it in
|
230
|
+
"the next chapter":projects.html. If you don't already have one, ask Buildr to
|
231
|
+
create it:
|
232
|
+
|
233
|
+
{{{!sh
|
234
|
+
$ buildr
|
235
|
+
}}}
|
236
|
+
|
237
|
+
p(tip). You'll notice that Buildr creates a file called @buildfile@. It's
|
238
|
+
case sensitive, but Buildr will look for either @buildfile@ or @Buildfile@.
|
239
|
+
You can also use @Rakefile@ or @rakefile@ for compatibility with previous
|
240
|
+
versions of Buildr.
|
241
|
+
|
242
|
+
You use Buildr by running the @buildr@ command:
|
243
|
+
|
244
|
+
{{{!sh
|
245
|
+
$ buildr [options] [tasks] [name=value]
|
246
|
+
}}}
|
247
|
+
|
248
|
+
There are several options you can use, for a full list of options type:
|
249
|
+
|
250
|
+
{{{!sh
|
251
|
+
$ buildr --help
|
252
|
+
}}}
|
253
|
+
|
254
|
+
|_. Option |_. Usage |
|
255
|
+
| @-f/--buildfile [file]@ | Specify the buildfile. |
|
256
|
+
| @-e/--environment [name]@ | Environment name (e.g. development, test, production). |
|
257
|
+
| @-h/--help@ | Display this help message. |
|
258
|
+
| @-n/--nosearch@ | Do not search parent directories for the buildfile. |
|
259
|
+
| @-q/--quiet@ | Do not log messages to standard output. |
|
260
|
+
| @-r/--require [file]@ | Require MODULE before executing buildfile. |
|
261
|
+
| @-t/--trace@ | Turn on invoke/execute tracing, enable full backtrace. |
|
262
|
+
| @-v/--version@ | Display the program version. |
|
263
|
+
|
264
|
+
You can tell Buildr to run specific tasks and the order to run them. For
|
265
|
+
example:
|
266
|
+
|
267
|
+
{{{!sh
|
268
|
+
# Clean and rebuild
|
269
|
+
buildr clean build
|
270
|
+
# Package and install
|
271
|
+
buildr install
|
272
|
+
}}}
|
273
|
+
|
274
|
+
If you don't specify a task, Buildr will run the "@build@ task":building.html,
|
275
|
+
compiling source code and running test cases. Running a task may run other
|
276
|
+
tasks as well, for example, running the @install@ task will also run @package@.
|
277
|
+
|
278
|
+
There are several "environment
|
279
|
+
variables":settings_profiles.html#environment_variables that let you control
|
280
|
+
how Buildr works, for example, to skip test cases during a build, or specify
|
281
|
+
options for the JVM. Depending on the variable, you may want to set it once in
|
282
|
+
your environment, or set a different value each time you run Buildr.
|
283
|
+
|
284
|
+
For example:
|
285
|
+
|
286
|
+
{{{!sh
|
287
|
+
$ export JAVA_OPTS='-Xms1g -Xmx1g'
|
288
|
+
$ buildr TEST=no
|
289
|
+
}}}
|
290
|
+
|
291
|
+
|
292
|
+
h2. Help Tasks
|
293
|
+
|
294
|
+
Buildr includes a number of informative tasks. Currently that number stands at
|
295
|
+
two, but we'll be adding more tasks in future releases. These tasks report
|
296
|
+
information from the Buildfile, so you need one to run them. For more general
|
297
|
+
help (version number, command line arguments, etc) use @buildr --help@.
|
298
|
+
|
299
|
+
To start with, type:
|
300
|
+
|
301
|
+
{{{!sh
|
302
|
+
$ buildr help
|
303
|
+
}}}
|
304
|
+
|
305
|
+
You can list the name and description of all your projects using the
|
306
|
+
@help:projects@ task. For example:
|
307
|
+
|
308
|
+
{{{!sh
|
309
|
+
$ buildr help:projects
|
310
|
+
killer-app # Code. Build. ??? Profit!
|
311
|
+
killer-app:teh-api # Abstract classes and interfaces
|
312
|
+
killer-app:teh-impl # All those implementation details
|
313
|
+
killer-app:la-web # What our users see
|
314
|
+
}}}
|
315
|
+
|
316
|
+
You are, of course, describing your projects for the sake of those who will
|
317
|
+
maintain your code, right? To describe a project, or a task, call the @desc@
|
318
|
+
method before the project or task definition.
|
319
|
+
|
320
|
+
So next let's talk about "projects":projects.html.
|
321
|
+
|
322
|
+
|
323
|
+
h2. More Info
|
324
|
+
|
325
|
+
*API* The "Buildr API":http://incubator.apache.org/buildr/rdoc/index.html
|
326
|
+
documentation.
|
327
|
+
|
328
|
+
*Rake* Buildr is based on Rake, a Ruby build system that handles tasks and
|
329
|
+
dependencies. Check out the "Rake documentation":http://docs.rubyrake.org/ for
|
330
|
+
more information.
|
331
|
+
|
332
|
+
*AntWrap* Buildr uses AntWrap, for configuring and running Ant tasks. You can
|
333
|
+
learn more from the "Antwrap documentation":http://antwrap.rubyforge.org/.
|
334
|
+
|
335
|
+
*YAML* Buildr uses YAML for its profiles. You can "learn more about YAML
|
336
|
+
here":http://www.yaml.org, and use this handy "YAML quick
|
337
|
+
reference":http://www.yaml.org/refcard.html.
|