buildobjects provides a number of java classes that allow you to code your build process in a truly object oriented fashion. It is not forcing you into a certain way of structuring your code and projects. Instead it aims at providing useful building blocks.
The rationale for using java was the availability of the full tool support to th build script. So when using buildobjects you get completetion, search for usage, and a fully featured debugger.
Getting Started
Download and install buildobjects
- Get the buildobjects-dep.jar from the downnloads section.
- Put the file into the local file system and create and an alias or a script to run it:
alias bo="java -jar /pathtobuildobjects/buildobjects-dep.jar"
Make sure that you are using java 6.
Getting the project set up
The project to be built looks somewhat like this:
|-- build
| +-- Build.java
|-- lib
| |-- some.jar
| +-- more_dependencies
|-- src
| +-- Sources go here...
+-- test
+-- Test srouces go here...The build older contains the actual build script. A minimal build script looks like this:
import org.buildobjects.BuildBase;
import org.buildobjects.artifacts.Classes;
import org.buildobjects.artifacts.FileLocation;
import org.buildobjects.artifacts.Location;
import org.buildobjects.projectmodel.JavaModule;
public class Build extends BuildBase {
private JavaModule module;
public Build() {
Location location = new FileLocation(".");
Classes libraries = location.jarDir("lib");
module = new JavaModule(tasks, location, libraries);
}
public void build() {
build.publish(module.publishable());
}
public static void main(String[] args) {
new Build().build();
}It is a good practice to have a separate project in your IDE setup for the builds. This includes the buildobjects-dep.jar on the classpath.
How to run?
To trigger your build form the IDE you can just execute the main method in the buildfile. To run a build from the command line the buildfile has to be compiled. Fortunately the buildobjects Tasklets do the job for you:
bo -source build Build
After running the build you will see a new directory appearing:
|-- target | |-- 20081106-145511-build.1 | | |-- SUCCEEDED | | |-- index.html | | +-- testproject-simple | | |-- test-results.txt | | +-- testproject-simple.jar | |-- environment.json | +-- index.html
The target folder is associated with the build environment in which the builds happen. It has an index.html listing all the builds (as well as a json keeping things like the last buildnumber. For each build a new folder is created, that has all the buildresults.
To see what this build actually published have a look at the JavaModule class. It is expected that projects will define their own JavaModule class. If it is put in the build folder it will be compiled when the build is run.
The example use here is available via svn: http://buildobjects.googlecode.com/svn/trunk/example/testproject-simple.