1. Start Here
    1. Welcome
    2. Download
    3. User Guide (PDF)
    4. What’s New
    5. Community Wiki
  2. Using Buildr
    1. Getting Started
    2. Projects
    3. Building
    4. Artifacts
    5. Packaging
    6. Testing
    7. Settings/Profiles
    8. Languages
    9. More Stuff
    10. Extending Buildr
    11. Recipes
  3. Reference
    1. API
    2. Rake
    3. Antwrap
    4. Troubleshooting
  4. Get Involved
    1. Mailing Lists
    2. Issues/Bugs
    3. Contributing
  5. Project Status
    1. License
    2. Changelog
    3. Specs
    4. Coverage
Google Custom Search

What’s New

  1. Buildr 1.3.3
  2. Buildr 1.3.2
  3. Buildr 1.3.1
  4. Buildr 1.3
    1. Multiple Languages
    2. Scala Support
    3. Groovy Support
    4. Packaging Files
    5. Packaging EARs
    6. JRuby Support
    7. Behaviour-Driven Development
    8. Profiles
    9. Settings and build YAML files
    10. Using Gems for extensions and 3rd party libraries
    11. New API for accessing Java libraries
    12. Creating Extensions
    13. Using Alternative Layouts
    14. Other
    15. Documentation

Buildr 1.3.3

Buildr 1.3.2

Buildr 1.3.1

Buildr 1.3

Multiple Languages

The main focus of this release is supporting multiple languages for compiling and testing.

For each project, Buildr will attempt to infer which compiler to use based on the source files it finds, for example, if it finds .java files in the src/main/java directory, it will switch to the javac compiler, if it finds .scala files in the src/main/scala directory, to the scalac compiler and so forth.

Different compilers may use different target directory, target/classes is picked for JVM compilers (Java, Scala, Groovy, etc), so resources are not copied to their own directory, target/resources. The prepare task has been removed.

Not all languages have classpaths, so compile.classpath is now known as compile.dependencies, but the old attribute still exists for backward compatibility.

Also, for consistency, the test target directories have changed to target/test/classes and target/test/resources, respectively.

Speaking of tests, you can compile code in one language and use a different language to test it, say, if you’re interested in compiling Java code and testing it with Ruby, or compiling Flash and running a Java test suite.

As before, you can pick the test framework by calling test.using(<framework>). Buildr will attempt to pick one by default, for example, if the tests are written in Java, it will default to JUnit.

And, since not all languages package to JARs, the default packaging is either inferred from the compiler (so :jar when compiling Java code), otherwise to :zip. All this defaulting means that package() with no arguments does the right thing in more cases, and most probably won’t break anyone’s buildfiles.

I’ve tried to keep the compiler API as simple as possible, making it easy to add new compilers; however, I had to change the test framework API to accommodate the new features, so old test frameworks will not work on 1.3.

Scala Support

Buildr now supports Scala, using both native and fast Scala compiler.

Read more about using Scala.

Groovy Support

Buildr now supports Groovy, using the Groovyc Ant task.

Read more about using Groovy.

Packaging Files

The package method is convenient enough that you can now use it to generate artifacts, an in addition to generate regular file tasks, specifying the file name using the :file attribute. For example:

package :zip, :file=>_('target/interesting.zip')

Since this package is not an artifact and does not have a specification, it will not automatically install itself in the local repository or upload to a remote repository. For these, use the package method as before.

Read more about the package method.

Packaging EARs

EAR packages support four component types:

Argument Component
:war J2EE Web Application (WAR).
:ejb Enterprise Java Bean (JAR).
:jar J2EE Application Client (JAR).
:lib Shared library (JAR).

This example shows two ways for adding components built by other projects:

package(:ear) << project('coolWebService').package(:war)
package(:ear).add project('commonLib') # By default, the JAR package

EAR packages include an application.xml file in the META-INF directory that describes the application and its component. 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.

Read more …

JRuby Support

We now offer two versions of Buildr, one for Ruby and one for JRuby. They’re exactly the same, except the Ruby version will also install RJB (Ruby Java Bridge), the JRuby version obviously can do well without it.

Read more …

Buildr provides a Nailgun server when running on JRuby. Using the integrated BuildrServer allows for faster task execution and avoid frequent JVM startup overhead.

Read more …

Behaviour-Driven Development

Given that many languages are now supported by Buildr, the same is true for testing, the convention is to store BDD files under the src/spec/{lang} directory. The following table shows the framework’s name you can use to select them for your projects. Buildr follows each framework’s naming convention.

test.using Test file name convention
:jbehave src/spec/java/**/*Behaviour.java
:rspec src/spec/ruby/**/*_spec.rb
:easyb src/spec/groovy/**/*{Story,Behavior}.groovy

Read more …

Profiles

Different environments may require different configurations, some you will want to control with code, others you will want to specify in the profiles file.

The profiles file is a YAML file called profiles.yaml that you place in the same directory as the Buildfile. We selected YAML because it’s easier to read and edit than XML.

For example, to support three different database configurations, we could write:

# HSQL, don't bother storing to disk.
development:
  db: hsql
  jdbc: hsqldb:mem:devdb

# Make sure we're not messing with bigstrong.
test:
  db: oracle
  jdbc: oracle:thin:@localhost:1521:test

# The real deal.
production:
  db: oracle
  jdbc: oracle:thin:@bigstrong:1521:mighty

You can also use profiles to specify default filters for the resources task.

Read more …

Settings and build YAML files

In addition to profiles, we also allow you to specify personal and build settings using two YAML files.

Personal settings are placed in the .buildr/settings.yaml file under your home directory. Settings stored there will be applied the same across all builds.

For example:

# The repositories hash is read automatically by buildr.
repositories:

  # customize user local maven2 repository location
  local: some/path/to/my_repo

  relase_to:
    url: http://intra.net/maven2
    username: john
    password: secret

# You can place settings of your own, and reference them 
# on buildfiles. 
im:
  server: jabber.company.com
  usr: notifier@company-jabber.com
  pwd: secret

Read more …

Build settings are placed in the build.yaml file located in the same directory that the buildfile. Normally this file would be managed by the project revision control system, so settings here are shared between developers.

For example:

# This project requires the following ruby gems, buildr addons
gems: 
  # Suppose we want to notify developers when testcases fail.
  - buildr-twitter-notifier-addon >=1
  # we test with ruby mock objects
  - mocha
  - ci_reporter

# The artifact declarations will be automatically loaded by buildr, so that
# you can reference artifacts by name (a ruby-symbol) on your buildfile.
artifacts:
  spring: org.springframework:spring:jar:2.0
  log4j: log4j:log4j:jar:1.0
  j2ee: geronimo-spec:geronimo-spec:j2ee:jar:1.4-rc4

# Of course project settings can be defined here
jira: 
  uri: https://jira.corp.org

Read more …

Using Gems for extensions and 3rd party libraries

RubyGems provides the gem command line tool that you can use to search, install, upgrade, package and distribute gems. It installs all gems into a local repository that is shared across your builds and all other Ruby applications you may have running. You can install a gem from a local file, or download and install it from any number of remote repositories.

If your build depends on other gems, you will want to specify these dependencies as part of your build and check that configuration into source control. That way you can have a specific environment that will guarantee repeatable builds, whether you’re building a particular version, moving between branches, or joining an existing project. Buildr will take care of installing all the necessary dependencies, which you can then manage with the gem command.

Use the build.yaml file to specify these dependencies (see Build Settings for more information), for example:

# This project requires the following gems
gems: 
  # Suppose we want to notify developers when testcases fail.
  - buildr-twitter-notifier-addon >=1
  # we test with ruby mock objects
  - mocha
  - ci_reporter

Read more …

New API for accessing Java libraries

Java classes are accessed as static methods on the Java module, for example:

str = Java.java.lang.String.new('hai!')
str.toUpperCase
=> 'HAI!'
Java.java.lang.String.isInstance(str)
=> true
Java.com.sun.tools.javac.Main.compile(args)

The classpath attribute allows Buildr to add JARs and directories to the classpath, for example, we use it to load Ant and various Ant tasks, code generators, test frameworks, and so forth.

For example, Ant is loaded as follows:

Java.classpath << 'org.apache.ant:ant:jar:1.7.0'

Artifacts can only be downloaded after the Buildfile has loaded, giving it a chance to specify which remote repositories to use, so adding to classpath does not by itself load any libraries. You must call Java.load before accessing any Java classes to give Buildr a chance to load the libraries specified in the classpath.

Read more …

Creating Extensions

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:

class Project
  include MyExtension
end

You can also extend a given project instance and only that instance by extending it with the module:

define 'foo' do
  extend MyExtension
end

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.

Read more …

Using Alternative Layouts

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.

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.

Read more …

Other

Documentation