ittayd-buildr 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +915 -0
- data/DISCLAIMER +7 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +146 -0
- data/Rakefile +64 -0
- data/_buildr +28 -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/path.rb +136 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +58 -0
- data/doc/css/default.css +228 -0
- data/doc/css/print.css +100 -0
- data/doc/css/syntax.css +52 -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/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.tif +0 -0
- data/doc/pages/artifacts.textile +207 -0
- data/doc/pages/building.textile +240 -0
- data/doc/pages/contributing.textile +208 -0
- data/doc/pages/download.textile +62 -0
- data/doc/pages/extending.textile +175 -0
- data/doc/pages/getting_started.textile +273 -0
- data/doc/pages/index.textile +42 -0
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +314 -0
- data/doc/pages/packaging.textile +427 -0
- data/doc/pages/projects.textile +274 -0
- data/doc/pages/recipes.textile +103 -0
- data/doc/pages/settings_profiles.textile +274 -0
- data/doc/pages/testing.textile +212 -0
- data/doc/pages/troubleshooting.textile +103 -0
- data/doc/pages/whats_new.textile +323 -0
- data/doc/print.haml +51 -0
- data/doc/print.toc.yaml +29 -0
- data/doc/scripts/buildr-git.rb +412 -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 +56 -0
- data/doc/site.toc.yaml +47 -0
- data/etc/KEYS +151 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr/core/application.rb +665 -0
- data/lib/buildr/core/build.rb +311 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +590 -0
- data/lib/buildr/core/environment.rb +117 -0
- data/lib/buildr/core/filter.rb +366 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +49 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +923 -0
- data/lib/buildr/core/test.rb +715 -0
- data/lib/buildr/core/transports.rb +560 -0
- data/lib/buildr/core/util.rb +294 -0
- data/lib/buildr/core.rb +29 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/ide/eclipse.rb +222 -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/ide.rb +19 -0
- data/lib/buildr/java/ant.rb +92 -0
- data/lib/buildr/java/bdd.rb +451 -0
- data/lib/buildr/java/cobertura.rb +236 -0
- data/lib/buildr/java/commands.rb +211 -0
- data/lib/buildr/java/compiler.rb +348 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +238 -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 +119 -0
- data/lib/buildr/java/packaging.rb +717 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +307 -0
- data/lib/buildr/java/tests.rb +329 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +759 -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 +233 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +64 -0
- data/lib/buildr/packaging/ziptask.rb +313 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr.rb +33 -0
- data/rakelib/apache.rake +191 -0
- data/rakelib/changelog.rake +57 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +76 -0
- data/rakelib/release.rake +65 -0
- data/rakelib/rspec.rake +83 -0
- data/rakelib/rubyforge.rake +56 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +81 -0
- data/rakelib/stage.rake +48 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +419 -0
- data/spec/core/build_spec.rb +423 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +582 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +776 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +500 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +239 -0
- data/spec/ide/eclipse_spec.rb +311 -0
- data/spec/java/ant.rb +33 -0
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/java/cobertura_spec.rb +77 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +120 -0
- data/spec/java/java_spec.rb +96 -0
- data/spec/java/packaging_spec.rb +1120 -0
- data/spec/java/test_coverage_spec.rb +255 -0
- data/spec/java/tests_spec.rb +471 -0
- data/spec/packaging/archive_spec.rb +503 -0
- data/spec/packaging/artifact_namespace_spec.rb +646 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +589 -0
- data/spec/sandbox.rb +139 -0
- data/spec/scala/compiler_spec.rb +228 -0
- data/spec/scala/tests_spec.rb +215 -0
- data/spec/spec_helpers.rb +327 -0
- data/spec/version_requirement_spec.rb +123 -0
- metadata +377 -0
@@ -0,0 +1,175 @@
|
|
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 your own Rake tasks is a very powerful feature. But if you find yourself doing the same thing over and over, you might also want to consider functions. They give you a lot more power and easy abstractions.
|
6
|
+
|
7
|
+
For example, we use OpenJPA in several projects. It's a very short task, but each time I have to go back to the OpenJPA documentation to figure out how to set the Ant MappingTool task, tell Ant how to define it. After the second time, you're recognizing a pattern and it's just easier to write a function that does all that for you.
|
8
|
+
|
9
|
+
Compare this:
|
10
|
+
|
11
|
+
{{{!ruby
|
12
|
+
file('derby.sql') do
|
13
|
+
REQUIRES = [
|
14
|
+
'org.apache.openjpa:openjpa-all:jar:0.9.7-incubating',
|
15
|
+
'commons-collections:commons-collections:jar:3.1',
|
16
|
+
. . .
|
17
|
+
'net.sourceforge.serp:serp:jar:1.11.0' ]
|
18
|
+
ant('openjpa') do |ant|
|
19
|
+
ant.taskdef :name=>'mapping',
|
20
|
+
:classname=>'org.apache.openjpa.jdbc.ant.MappingToolTask',
|
21
|
+
:classpath=>REQUIRES.join(File::PATH_SEPARATOR)
|
22
|
+
ant.mapping :schemaAction=>'build', :sqlFile=>task.name,
|
23
|
+
:ignoreErrors=>true do
|
24
|
+
ant.config :propertiesFile=>_('src/main/sql/derby.xml')
|
25
|
+
ant.classpath :path=>projects('store', 'utils' ).
|
26
|
+
flatten.map(&:to_s).join(File::PATH_SEPARATOR)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
}}}
|
31
|
+
|
32
|
+
To this:
|
33
|
+
|
34
|
+
{{{!ruby
|
35
|
+
file('derby.sql') do
|
36
|
+
mapping_tool :action=>'build', :sql=>task.name,
|
37
|
+
:properties=>_('src/main/sql/derby.xml'),
|
38
|
+
:classpath=>projects('store', 'utils')
|
39
|
+
end
|
40
|
+
}}}
|
41
|
+
|
42
|
+
I prefer the second. It's easier to look at the Buildfile and understand what it does. It's easier to maintain when you only have to look at the important information.
|
43
|
+
|
44
|
+
But just using functions is not always enough. You end up with a Buildfile containing a lot of code that clearly doesn't belong there. For starters, I recommend putting it in the @tasks@ directory. Write it into a file with a @.rake@ extension and place that in the @tasks@ directory next to the Buildfile. Buildr will automatically pick it up and load it for you.
|
45
|
+
|
46
|
+
If you want to share these pre-canned definitions between projects, you have a few more options. You can share the @tasks@ directory using SVN externals. Another mechanism with better version control is to package all these tasks, functions and modules into a "Gem":http://rubygems.org/ and require it from your Buildfile. You can run your own internal Gem server for that.
|
47
|
+
|
48
|
+
For individual task files, you can also use "Sake":http://errtheblog.com/post/6069 for system-wide Rake tasks deployment.
|
49
|
+
|
50
|
+
|
51
|
+
h2. Creating Extensions
|
52
|
+
|
53
|
+
The basic mechanism for extending projects in Buildr are Ruby modules. In fact, base features like compiling and testing are all developed in the form of modules, and then added to the core Project class.
|
54
|
+
|
55
|
+
A module defines instance methods that are then mixed into the project and become instance methods of the project. There are two general ways for extending projects. You can extend all projects by including the module in Project:
|
56
|
+
|
57
|
+
{{{!ruby
|
58
|
+
class Project
|
59
|
+
include MyExtension
|
60
|
+
end
|
61
|
+
}}}
|
62
|
+
|
63
|
+
You can also extend a given project instance and only that instance by extending it with the module:
|
64
|
+
|
65
|
+
{{{!ruby
|
66
|
+
define 'foo' do
|
67
|
+
extend MyExtension
|
68
|
+
end
|
69
|
+
}}}
|
70
|
+
|
71
|
+
Some extensions require tighter integration with the project, specifically for setting up tasks and properties, or for configuring tasks based on the project definition. You can do that by adding callbacks to the process.
|
72
|
+
|
73
|
+
The easiest way to add callbacks is by incorporating the Extension module in your own extension, and using the various class methods to define callback behavior.
|
74
|
+
|
75
|
+
|_. Method |_. Usage |
|
76
|
+
| @first_time@ | This block will be called once for any particular extension. You can use this to setup top-level and local tasks. |
|
77
|
+
| @before_define@ | This block is called once for the project with the project instance, right before running the project definition. You can use this to add tasks and set properties that will be used in the project definition. |
|
78
|
+
| @after_define@ | This block is called once for the project with the project instance, right after running the project definition. You can use this to do any post-processing that depends on the project definition. |
|
79
|
+
|
80
|
+
This example illustrates how to write a simple extension:
|
81
|
+
|
82
|
+
{{{!ruby
|
83
|
+
module LinesOfCode
|
84
|
+
include Extension
|
85
|
+
|
86
|
+
first_time do
|
87
|
+
# Define task not specific to any projet.
|
88
|
+
desc 'Count lines of code in current project'
|
89
|
+
Project.local_task('loc')
|
90
|
+
end
|
91
|
+
|
92
|
+
before_define do |project|
|
93
|
+
# Define the loc task for this particular project.
|
94
|
+
define_task 'loc' do |task|
|
95
|
+
lines = task.prerequisites.map { |path| Dir["#{path}/**/*"] }.flatten.uniq.
|
96
|
+
inject(0) { |total, file| total + File.readlines(file).count }
|
97
|
+
puts "Project #{project.name} has #{lines} lines of code"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
after_define do |project|
|
102
|
+
# Now that we know all the source directories, add them.
|
103
|
+
task('loc'=>compile.sources + compile.test.sources)
|
104
|
+
end
|
105
|
+
|
106
|
+
# To use this method in your project:
|
107
|
+
# loc path_1, path_2
|
108
|
+
def loc(*paths)
|
109
|
+
task('loc'=>paths)
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
class Buildr::Project
|
115
|
+
include LinesOfCode
|
116
|
+
end
|
117
|
+
}}}
|
118
|
+
|
119
|
+
|
120
|
+
h2. Using Alternative Layouts
|
121
|
+
|
122
|
+
Buildr follows a common convention for project layouts: Java source files appear in @src/main/java@ and compile to @target/classes@, resources are copied over from @src/main/resources@ and so forth. Not all projects follow this convention, so it's now possible to specify an alternative project layout.
|
123
|
+
|
124
|
+
The default layout is available in @Layout.default@, and all projects inherit it. You can set @Layout.default@ to your own layout, or define a project with a given layout (recommended) by setting the @:layout@ property. Projects inherit the layout from their parent projects. For example:
|
125
|
+
|
126
|
+
{{{!ruby
|
127
|
+
define 'foo', :layout=>my_layout do
|
128
|
+
...
|
129
|
+
end
|
130
|
+
}}}
|
131
|
+
|
132
|
+
A layout is an object that implements the @expand@ method. The easiest way to define a custom layout is to create a new @Layout@ object and specify mapping between names used by Buildr and actual paths within the project. For example:
|
133
|
+
|
134
|
+
{{{!ruby
|
135
|
+
my_layout = Layout.new
|
136
|
+
my_layout[:source, :main, :java] = 'java'
|
137
|
+
my_layout[:source, :main, :resources] = 'resources'
|
138
|
+
}}}
|
139
|
+
|
140
|
+
Partial expansion also works, so you can specify the above layout using:
|
141
|
+
|
142
|
+
{{{!ruby
|
143
|
+
my_layout = Layout.new
|
144
|
+
my_layout[:source, :main] = ''
|
145
|
+
}}}
|
146
|
+
|
147
|
+
If you need anything more complex, you can always subclass @Layout@ and add special handling in the @expand@ method, you'll find one such example in the API documentation.
|
148
|
+
|
149
|
+
The built-in tasks expand lists of symbols into relative paths, using the following convention:
|
150
|
+
|
151
|
+
|_. Path |_. Expands to |
|
152
|
+
| @:source, :main, <lang/usage>@ | Directory containing source files for a given language or usage, for example, @:java@, @:resources@, @:webapp@. |
|
153
|
+
| @:source, :test, <lang/usage>@ | Directory containing test files for a given language or usage, for example, @:java@, @:resources@. |
|
154
|
+
| @:target, :generated@ | Target directory for generated code (typically source code). |
|
155
|
+
| @:target, :main, <lang/usage>@ | Target directory for compiled code, for example, @:classes@, @:resources@. |
|
156
|
+
| @:target, :test, <lang/usage>@ | Target directory for compile test cases, for example, @:classes@, @:resources@. |
|
157
|
+
| @:reports, <framework/usage>@ | Target directory for generated reports, for example, @:junit@, @:coverage@. |
|
158
|
+
|
159
|
+
All tasks are encouraged to use the same convention, and whenever possible, we recommend using the project's @path_to@ method to expand a list of symbols into a path, or use the appropriate path when available. For example:
|
160
|
+
|
161
|
+
{{{!ruby
|
162
|
+
define 'bad' do
|
163
|
+
# This may not be the real target.
|
164
|
+
puts 'Compiling to ' + path_to('target/classes')
|
165
|
+
# This will break with different layouts.
|
166
|
+
package(:jar).include 'src/main/etc/*'
|
167
|
+
end
|
168
|
+
|
169
|
+
define 'good' do
|
170
|
+
# This is always the compiler's target.
|
171
|
+
puts 'Compiling to ' + compile.target.to_s
|
172
|
+
# This will work with different layouts.
|
173
|
+
package(:jar).include path_to(:source, :main, :etc, '*')
|
174
|
+
end
|
175
|
+
}}}
|
@@ -0,0 +1,273 @@
|
|
1
|
+
h1. Getting Started
|
2
|
+
|
3
|
+
h2. Installing Buildr
|
4
|
+
|
5
|
+
The installation instructions are slightly different for each operating system. Pick the one that best matches your operating system and target platform.
|
6
|
+
|
7
|
+
The @gem install@ and @gem update@ commands install Buildr from a binary distribution provided through "RubyForge":http://rubyforge.org/projects/buildr. This distribution is maintained by contributors to this project, but is *not* an official Apache distribution. You can obtain the official Apache distribution files from the "download page":download.html.
|
8
|
+
|
9
|
+
The current release of Buildr for Ruby may not work well with Java 6, only Java 1.5 or earlier. If you need to use Java 6, consider "Buildr for JRuby":#jruby.
|
10
|
+
|
11
|
+
|
12
|
+
h3. Linux
|
13
|
+
|
14
|
+
To get started you will need a recent version of Ruby, Ruby Gems and build tools for compiling native libraries (@make@, @gcc@ and standard headers).
|
15
|
+
|
16
|
+
On *RedHat/Fedora* you can use yum to install Ruby and RubyGems, and then upgrade to the most recent version of RubyGems:
|
17
|
+
|
18
|
+
{{{!sh
|
19
|
+
$ sudo yum install ruby rubygems ruby-devel gcc
|
20
|
+
$ sudo gem update --system
|
21
|
+
}}}
|
22
|
+
|
23
|
+
On *Ubuntu* you have to install several packages:
|
24
|
+
|
25
|
+
{{{!sh
|
26
|
+
$ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
|
27
|
+
}}}
|
28
|
+
|
29
|
+
The Debian package for @rubygems@ will not allow you to install Buildr, so you need to install RubyGems from source:
|
30
|
+
|
31
|
+
{{{!sh
|
32
|
+
$ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
|
33
|
+
$ tar xzf rubygems-1.2.0.tgz
|
34
|
+
$ cd rubygems-1.2.0
|
35
|
+
$ sudo ruby setup.rb
|
36
|
+
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
|
37
|
+
}}}
|
38
|
+
|
39
|
+
Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution. Next, use Ruby Gem to install Buildr:
|
40
|
+
|
41
|
+
{{{!sh
|
42
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
|
43
|
+
}}}
|
44
|
+
|
45
|
+
To upgrade to a new version or install a specific version:
|
46
|
+
|
47
|
+
{{{!sh
|
48
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
|
49
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
|
50
|
+
}}}
|
51
|
+
|
52
|
+
You can also use this script "to install Buildr on Linux":scripts/install-linux.sh. This script will install Buildr or if already installed, upgrade to a more recent version. It will also install Ruby 1.8.6 if not already installed (using @yum@ or @apt-get@) and upgrage RubyGems to 1.0.1.
|
53
|
+
|
54
|
+
|
55
|
+
h3. OS X
|
56
|
+
|
57
|
+
OS X 10.5 (Leopard) comes with a recent version of Ruby 1.8.6. OS X 10.4 (Tiger) includes an older version of Ruby, we recommend you first install Ruby 1.8.6 using MacPorts (@sudo port install ruby rb-rubygems@), Fink or the "Ruby One-Click Installer for OS X":http://rubyosx.rubyforge.org/.
|
58
|
+
|
59
|
+
We recommend you first upgrade to the latest version of Ruby gems:
|
60
|
+
|
61
|
+
{{{!sh
|
62
|
+
$ sudo gem update --system
|
63
|
+
}}}
|
64
|
+
|
65
|
+
Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution:
|
66
|
+
|
67
|
+
{{{!sh
|
68
|
+
$ export JAVA_HOME=/Library/Java/Home
|
69
|
+
}}}
|
70
|
+
|
71
|
+
To install Buildr:
|
72
|
+
|
73
|
+
{{{!sh
|
74
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
|
75
|
+
}}}
|
76
|
+
|
77
|
+
To upgrade to a new version or install a specific version:
|
78
|
+
|
79
|
+
{{{!sh
|
80
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
|
81
|
+
$ sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.4
|
82
|
+
}}}
|
83
|
+
|
84
|
+
You can also use this script "to install Buildr on OS X":scripts/install-osx.sh. This script will install Buildr or if already installed, upgrade to a more recent version. It will also install Ruby 1.8.6 if not already installed (using MacPorts) and upgrage RubyGems to 1.0.1.
|
85
|
+
|
86
|
+
|
87
|
+
h3. Windows
|
88
|
+
|
89
|
+
If you don't already have Ruby installed, now is the time to do it. The easiest way to install Ruby is using the "one-click installer":http://rubyinstaller.rubyforge.org/.
|
90
|
+
|
91
|
+
We recommend you first upgrade to the latest version of Ruby gems:
|
92
|
+
|
93
|
+
{{{!sh
|
94
|
+
> gem update --system
|
95
|
+
}}}
|
96
|
+
|
97
|
+
Before installing Buildr, please set the @JAVA_HOME@ environment variable to point to your JDK distribution. Next, use Ruby Gem to install Buildr:
|
98
|
+
|
99
|
+
{{{!sh
|
100
|
+
> gem install buildr
|
101
|
+
}}}
|
102
|
+
|
103
|
+
Buildr uses several libraries that include native extensions. During installation it will ask you to pick a platform for these libraries. By selecting @mswin32@ it will download and install pre-compiled DLLs for these extensions.
|
104
|
+
|
105
|
+
To upgrade to a new version or install a specific version:
|
106
|
+
|
107
|
+
{{{!sh
|
108
|
+
> gem update buildr
|
109
|
+
> gem install buildr -v 1.3.4
|
110
|
+
}}}
|
111
|
+
|
112
|
+
|
113
|
+
h3. JRuby
|
114
|
+
|
115
|
+
If you don't already have JRuby 1.1 or later installed, you can download it from the "JRuby site":http://dist.codehaus.org/jruby/.
|
116
|
+
|
117
|
+
After uncompressing JRuby, update your @PATH@ to include both @java@ and @jruby@ executables.
|
118
|
+
|
119
|
+
For Linux and OS X:
|
120
|
+
|
121
|
+
{{{!sh
|
122
|
+
$ export PATH=$PATH:[path to JRuby]/bin:$JAVA_HOME/bin
|
123
|
+
$ jruby -S gem install buildr
|
124
|
+
}}}
|
125
|
+
|
126
|
+
For Windows:
|
127
|
+
|
128
|
+
{{{!sh
|
129
|
+
> set PATH=%PATH%;[path to JRuby]/bin;%JAVA_HOME%/bin
|
130
|
+
> jruby -S gem install buildr
|
131
|
+
}}}
|
132
|
+
|
133
|
+
To upgrade to a new version or install a specific version:
|
134
|
+
|
135
|
+
{{{!sh
|
136
|
+
$ jruby -S gem update buildr
|
137
|
+
$ jruby -S gem install buildr -v 1.3.4
|
138
|
+
}}}
|
139
|
+
|
140
|
+
You can also use this script "to install Buildr on JRuby":scripts/install-jruby.sh. This script will install Buildr or if already installed, upgrade to a more recent version. If necessary, it will also install JRuby 1.1 in @/opt/jruby@ and update the @PATH@ variable in @~/.bash_profile@ or @~/.profile@.
|
141
|
+
|
142
|
+
*Important: Running JRuby and Ruby side by side*
|
143
|
+
|
144
|
+
Ruby and JRuby maintain separate Gem repositories, and in fact install slightly different versions of the Buildr Gem (same functionality, different dependencies). Installing Buildr for Ruby does not install it for JRuby and vice versa.
|
145
|
+
|
146
|
+
If you have JRuby installed but not Ruby, the @gem@ and @buildr@ commands will use JRuby. If you have both JRuby and Ruby installed, follow the instructions below. To find out if you have Ruby installed (some operating systems include it by default), run @ruby --version@ from the command line.
|
147
|
+
|
148
|
+
To work exclusively with JRuby, make sure it shows first on the path, for example, by setting @PATH=/opt/jruby/bin:$PATH@.
|
149
|
+
|
150
|
+
You can use JRuby and Ruby side by side, by running scripts with the @-S@ command line argument. For example:
|
151
|
+
|
152
|
+
{{{!
|
153
|
+
$ # with Ruby
|
154
|
+
$ ruby -S gem install buildr
|
155
|
+
$ ruby -S buildr
|
156
|
+
$ # with JRuby
|
157
|
+
$ jruby -S gem install buildr
|
158
|
+
$ jruby -S buildr
|
159
|
+
}}}
|
160
|
+
|
161
|
+
Run @buildr --version@ from the command line to find which version of Buildr you are using by default. If you see @(JRuby ...)@, Buildr is running on that version of JRuby.
|
162
|
+
|
163
|
+
|
164
|
+
h2. Document Conventions
|
165
|
+
|
166
|
+
Lines that start with @$@ are command lines, for example:
|
167
|
+
|
168
|
+
{{{!sh
|
169
|
+
$ # Run Buildr
|
170
|
+
$ buildr
|
171
|
+
}}}
|
172
|
+
|
173
|
+
Lines that start with @=>@ show output from the console or the result of a method, for example:
|
174
|
+
|
175
|
+
{{{!sh
|
176
|
+
puts 'Hello world'
|
177
|
+
=> "Hello world"
|
178
|
+
}}}
|
179
|
+
|
180
|
+
And as you guessed, everything else is Buildfile Ruby or Java code. You can figure out which language is which.
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
h2. Running Buildr
|
185
|
+
|
186
|
+
You need a *Buildfile*, a build script that tells Buildr all about the projects it's building, what they contain, what to produce, and so on. The Buildfile resides in the root directory of your project. We'll talk more about it in "the next chapter":projects.html. If you don't already have one, ask Buildr to create it:
|
187
|
+
|
188
|
+
{{{!sh
|
189
|
+
$ buildr
|
190
|
+
}}}
|
191
|
+
|
192
|
+
p(tip). You'll notice that Buildr creates a file called @buildfile@. It's case sensitive, but Buildr will look for either @buildfile@ or @Buildfile@.
|
193
|
+
|
194
|
+
You use Buildr by running the @buildr@ command:
|
195
|
+
|
196
|
+
{{{!sh
|
197
|
+
$ buildr [options] [tasks] [name=value]
|
198
|
+
}}}
|
199
|
+
|
200
|
+
There are several options you can use, for a full list of options type:
|
201
|
+
|
202
|
+
{{{!sh
|
203
|
+
$ buildr --help
|
204
|
+
}}}
|
205
|
+
|
206
|
+
|_. Option |_. Usage |
|
207
|
+
| @-f/--buildfile [file]@ | Specify the buildfile. |
|
208
|
+
| @-e/--environment [name]@ | Environment name (e.g. development, test, production). |
|
209
|
+
| @-h/--help@ | Display this help message. |
|
210
|
+
| @-n/--nosearch@ | Do not search parent directories for the buildfile. |
|
211
|
+
| @-q/--quiet@ | Do not log messages to standard output. |
|
212
|
+
| @-r/--require [file]@ | Require MODULE before executing buildfile. |
|
213
|
+
| @-t/--trace@ | Turn on invoke/execute tracing, enable full backtrace. |
|
214
|
+
| @-v/--version@ | Display the program version. |
|
215
|
+
| @-P/--prereqs@ | Display tasks and dependencies, then exit. |
|
216
|
+
|
217
|
+
You can tell Buildr to run specific tasks and the order to run them. For example:
|
218
|
+
|
219
|
+
{{{!sh
|
220
|
+
# Clean and rebuild
|
221
|
+
buildr clean build
|
222
|
+
# Package and install
|
223
|
+
buildr install
|
224
|
+
}}}
|
225
|
+
|
226
|
+
If you don't specify a task, Buildr will run the "@build@ task":building.html, compiling source code and running test cases. Running a task may run other tasks as well, for example, running the @install@ task will also run @package@.
|
227
|
+
|
228
|
+
There are several "environment variables":settings_profiles.html#environment_variables that let you control how Buildr works, for example, to skip test cases during a build, or specify options for the JVM. Depending on the variable, you may want to set it once in your environment, or set a different value each time you run Buildr.
|
229
|
+
|
230
|
+
For example:
|
231
|
+
|
232
|
+
{{{!sh
|
233
|
+
$ export JAVA_OPTS='-Xms1g -Xmx1g'
|
234
|
+
$ buildr TEST=no
|
235
|
+
}}}
|
236
|
+
|
237
|
+
|
238
|
+
h2. Help Tasks
|
239
|
+
|
240
|
+
Buildr includes a number of informative tasks. Currently that number stands at two, but we'll be adding more tasks in future releases. These tasks report information from the Buildfile, so you need one to run them. For more general help (version number, command line arguments, etc) use @buildr --help@.
|
241
|
+
|
242
|
+
To start with, type:
|
243
|
+
|
244
|
+
{{{!sh
|
245
|
+
$ buildr help
|
246
|
+
}}}
|
247
|
+
|
248
|
+
You can list the name and description of all your projects using the @help:projects@ task. For example:
|
249
|
+
|
250
|
+
{{{!sh
|
251
|
+
$ buildr help:projects
|
252
|
+
killer-app # Code. Build. ??? Profit!
|
253
|
+
killer-app:teh-api # Abstract classes and interfaces
|
254
|
+
killer-app:teh-impl # All those implementation details
|
255
|
+
killer-app:la-web # What our users see
|
256
|
+
}}}
|
257
|
+
|
258
|
+
You are, of course, describing your projects for the sake of those who will maintain your code, right? To describe a project, or a task, call the @desc@ method before the project or task definition.
|
259
|
+
|
260
|
+
So next let's talk about "projects":projects.html.
|
261
|
+
|
262
|
+
|
263
|
+
h2. Learning More
|
264
|
+
|
265
|
+
*Ruby* It pays to pick up Ruby as a second (or first) programming language. It's fun, powerful and slightly addictive. If you're interested in learning Ruby the language, a good place to start is "Programming Ruby: The Pragmatic Programmer's Guide":http://www.pragprog.com/titles/ruby/programming-ruby, fondly known as the _Pickaxe book_.
|
266
|
+
|
267
|
+
For a quicker read (and much more humor), "Why’s (Poignant) Guide to Ruby":http://poignantguide.net/ruby/ is available online. More resources are listed on the "ruby-lang web site":http://www.ruby-lang.org/en/documentation/.
|
268
|
+
|
269
|
+
*Rake* Buildr is based on Rake, a Ruby build system that handles tasks and dependencies. Check out the "Rake documentation":http://docs.rubyrake.org/ for more information.
|
270
|
+
|
271
|
+
*AntWrap* Buildr uses AntWrap, for configuring and running Ant tasks. You can learn more from the "Antwrap documentation":http://antwrap.rubyforge.org/.
|
272
|
+
|
273
|
+
*YAML* Buildr uses YAML for its profiles. You can "learn more about YAML here":http://www.yaml.org, and use this handy "YAML quick reference":http://www.yaml.org/refcard.html.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
h1. Welcome
|
2
|
+
|
3
|
+
h2. What is Buildr?
|
4
|
+
|
5
|
+
Buildr is a build system for Java applications. We wanted something that's simple and intuitive to use, so we only need to tell it what to do, and it takes care of the rest. But also something we can easily extend for those one-off tasks, with a language that's a joy to use. And of course, we wanted it to be fast, reliable and have outstanding dependency management.
|
6
|
+
|
7
|
+
Here's what we got:
|
8
|
+
|
9
|
+
* A simple way to specify projects, and build large projects out of smaller sub-projects.
|
10
|
+
* Pre-canned tasks that require the least amount of configuration, keeping the build script DRY and simple.
|
11
|
+
* Compiling, copying and filtering resources, JUnit/TestNG test cases, APT source code generation, Javadoc and more.
|
12
|
+
* A dependency mechanism that only builds what has changed since the last release.
|
13
|
+
* A drop-in replacement for Maven 2.0, Buildr uses the same file layout, artifact specifications, local and remote repositories.
|
14
|
+
* All your Ant tasks belong to us! Anything you can do with Ant, you can do with Buildr.
|
15
|
+
* No overhead for building "plugins" or configuration. Just write new tasks or functions.
|
16
|
+
* Buildr is Ruby all the way down. No one-off task is too demanding when you write code using variables, functions and objects.
|
17
|
+
* Simple way to upgrade to new versions.
|
18
|
+
* Did we mention fast?
|
19
|
+
|
20
|
+
So let's get started. You can "read the documentation online":getting_started.html, or "download the PDF":buildr.pdf.
|
21
|
+
|
22
|
+
|
23
|
+
h2. News
|
24
|
+
|
25
|
+
Check out "all that's new in Buildr 1.3.3":whats_new.html.
|
26
|
+
|
27
|
+
* Buildr 1.3 now runs on JRuby 1.1 and Ruby 1.8.6.
|
28
|
+
* Support for building Scala and Groovy projects.
|
29
|
+
* Behavior-Driven Development frameworks (RSpec, JBehave, etc).
|
30
|
+
* Profiles and build.yml settings file.
|
31
|
+
* New API for accessing Java libraries.
|
32
|
+
* More documentation.
|
33
|
+
* Other features and bug fixes.
|
34
|
+
|
35
|
+
|
36
|
+
h2. Notices
|
37
|
+
|
38
|
+
The Apache Software Foundation is a non-profit organization, consider "sponsoring":http://www.apache.org/foundation/sponsorship.html and check the "thanks":http://www.apache.org/foundation/thanks.html page.
|
39
|
+
|
40
|
+
Apache Buildr is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
|
41
|
+
|
42
|
+
"ColorCons":http://www.mouserunner.com/Spheres_ColoCons1_Free_Icons.html, copyright of Ken Saunders. "DejaVu fonts":http://dejavu.sourceforge.net, copyright of Bitstream, Inc.
|