<< User Status Plugin for Openfire | Home | java.lang.OutOfMemoryError: PermGen space >>

Maven vs Buildr

Is Buildr a drop-in replacement for Maven?

Jim Alateras talks about how Buildr could replace Maven in a blog entry titled "From Maven to buildr".

Buildr claims to be a drop-in replacement of Maven as it uses the same file layout, artifact specifications, local and remote repositories.
For sure the best practices built into Maven are great and the central repository is a place where you'll find almost every relevant open source java library but Maven is much more. Maven's big advantage over ant is a declarative approach describing projects instead of describing (or programming) the build process. Buildr drops the Maven POM (project object model) and returns to coding the build process — this time not in XML as in ant but in Ruby. Apache ODE’s Rakefile may serve as an example.

Jim notes that Buildr seems to be faster than Maven and continues

All extension tasks (ala maven plugins) are written in Ruby so you get all the power and benefits of a turing complete language as opposed to the constraints of maven plugins.

Well since Maven 2 all its plugins are written in plain Java — seems like the author really should have invested some time to actually look at Maven's design.

Can we learn from efforts like Buildr?

Well, the POM used by Maven to describe the projects is a bit verbose in some cases, this should be addressed in future versions. Besides that some performance optimizations might be a good thing tough I don't think they are so badly needed. Maven already reduces the time to build by making it very easy to reuse pre-built snapshots of depentant modules.

Besides this it will remain a religious issue on whether you prefer a declarative or a procedural approach for your build process. If you prefer the later have a look at Buildr but don't buy it as a drop-in replacement but as a different solution that reuses some of Maven's achievements.

Tags :


Re: Maven vs Buildr

the problem with a declarative model is that it is limited to only what the designers of the model thought of (otherwise, why do we have languages at all?). this is very nice as long as you do standard things. but the minute you don't, it is very hard to "declare" what you want to be done. ask anyone that tried to use the 'assembly' plugin for an existing assembly structure (that is, didn't follow maven's).

also, what is 'declerative' anyway? in buildr, to define a project, i write:
define 'foo' do
  compile.with :log4j
  package :jar
end

is this not declerative? would writing it as:
<define name="foo">
   <compile>
       <dependency>log4j</dependency>
   </compile>
   <package type="jar/>
</define>

make it suddanly into declerative definition?

the point is that using a real language you can create declerative constructs (meaning no definition of methods, objects, loops, conditions), but still, when you need the power of a real language, you have it at your fingertips.

and a complex build requires the constructs of a real language as much as any other software module. there's no escaping it.

maven plugins are indeed written in java, but their configuration is created in xml. and it is hard to access the configuration of other plugins, or of the container. in buildr, you simply call methods with arguments and since ruby is such a great language for fluent api, all works well.

i have tried creating a build for a multi module project using maven. it was very hard. since i wanted standartization, i needed to inherit from parent poms. but if i wanted some modifications for child projects, then this became very tricky (trying to override an inherited list). also the lack of true variables, not to mention lists or hashes was a nightmare. lack of 'if' was another horror story (in maven, if you want to slightly change behavior based on a cli argument then if it is a change in a single place you need to force the user to use a property name and if it requires changing several places it means making the user use profiles. both options not intuitive for the user, not easy to code, and cannot be added to 'help').

switching to buildr was a blessing, i could abstract any complex information structure into a method/class, use a real language and create an intuitive usage for users. also, buildr, being built on rake means things are done via tasks dependencies and not hardcoded lifecycle, which means you do only what is needed.

Re: Maven vs Buildr

Thanks for your elaborate comment.

You are right that there are situations where the standard model defined by Maven does not match your projects and that some parts of Maven are not yet in the shape they should be (thinking of assemblies of multi module projects).

What I like with a declarative approach is that you can use the meta data for a wide range of tasks outside build management and that becomes harder if you use a full programming language to define your build instead of a limited set of configuration properties.

I am in no way against using Buildr instead of Maven but I think it's a different approach to building projects that might sometimes be more appropriate than Maven and sometimes less. The bold statement that it is a drop-in replace just doesn't hold true as the new freedom makes it hard to use the declared project metadata for other tasks.

Re: Maven vs Buildr

configuration can be done via objects as well. in buildr, 'compile.sources' will return the list of sources to be compiled, 'compile.dependencies' will return the list of dependencies, etc. (it is just a matter of writing the proper accessors, very easy in ruby)

now consider a case where a module has some common sources and then a directory for jdk14 sources and a directory for jdk15 sources. in maven you can either use profiles to add the right directory, which is very verbose and not modular (the change is not local to where the sources are defined) or you need to split the module to 3 (and then run into the same issue to decide which module to choose for compilation dependencies).

in buildr, it's a simple condition. 

Re: Maven vs Buildr

Buildr drops the Maven pom.xml in favor of more flexible Ruby objects populated and modified by custom Ruby code.

We are using poms to answer questions like "Which module depends on artifact x?", "Does one closed source projects depends on GPL licensed artifacts?". These can be answered by parsing Maven poms (in any language) while with Buildr it would involve running Ruby code.

The big pro I see in Maven when used in large scale development shops is that it makes it easy to enforce standards. Of course this comes with limited flexibility which is welcome in these cases.

Maven and Buildr both have their valid use cases they just take a different approach. That's why I dislike the "drop-in replacement" statement.

Re: Maven vs Buildr

<pre>what needs to occur is the configuration of a build system needs to be 100% independent of the build system. the configuration should in turn be represented as a model that can be extended, along with methods to operate on that model. with this approach, whether it be  build system X, or any other process that needs access to this model can easily access and modify it.

now, should configuration (that which the human uses to describe the build configuration) be done in XML, or should it be a DSL that provides the ability to describe the configuration using a combination of declarative statements and full featured language, as in Ruby or Scala.

personally after setting up build environments since the mid-80's. i believe the best answer is using a combination of declarative statements and full featured language, as in Ruby or Scala.

why? for me, because the limitations the authors of build solutions , especially maven are much to restrictive, lack intuitiveness and consistency, and lastly convention is fine, but policy is not. for example, the convention of how a project is organized is fine (as long as it can be modified), only policies a build system should have are the policies the person deploying the build system defines.

implicit versus explicit build systems. this is another design/implementation consideration. i'm neither a fan of ant or maven, but there is one big difference between the 2. ant is explicit and maven is implicit. with ant a person can understand the basic workings of a build with little or no documentation. with maven, even after reading 'maven definitive quide' a couple times, most people will still struggle with maven... because it does very few things naturally. developer tools, especially build tools need to be explicit, and they need to be reasonably intuitive such that when a person that seldom works on the build system, has to get something done, they can rely on their intuition.

lots of people expressed their frustration with ant, but what I've seen in a number of companies is much more frustration with maven.

i started off this message stating the configuration of a build system should be 100% independent of the build system, at the same time, so should all the tasks. Another words a build system should work as a hub to work from a build model and apply actions that are not bound to the build systems api. Tasks and Plugins... Plugins should be to only extend the build system, not to define tasks. Tasks should be 100% independent of the build system. What we want is a loosely coupled design and implementation.

i think the next really good build system will not show up as a tool that pops up in open source, but instead a discussion on what the build system eco-system should look like, and from that a discussion on design and implementation.

ant and maven feel like they were streams-of-thought translated into code.
</pre>

Re: Maven vs Buildr

<pre>
This is a typical issue with maven, embedding policy and inconsistency, from the online documentation: <i>

Now that we've talked about where to specify profiles, and how to activate them, it will be useful to talk about what you can specify in a profile. As with the other aspects of profile configuration, this answer is not straightforward.

Depending on where you choose to configure your profile, you will have access to varying POM configuration options.</i>

Why not have the pom and settings be the same thing? Elements in the pom and settings are not apples-to-apples. This results in an unintuitive pattern... Maven is full of this type of behavior. I just spent some time reading about Maven 3... Something that is pretty simple sure has been made very complex. I've read a bit about Buildr and Simple Build Tool (sbt) they are a step in what I think is the right direction, but still have some issues as they could take it a step further  in making the pieces of the build system completely independent. Google GYP is trying to at one level solve this problem http://code.google.com/p/gyp/  but they too decided not to utilize a DSL and instead are using JSON instead of XML (this too will result in overly complex build configuration)

 



Add a comment Send a TrackBack