views:

3903

answers:

10

What does another build tool targeted at Java really get me?

Is it so hard to write a plugin using Java versus writing it in Ruby?

If you use Buildr over another tool, why?

Side question: How many build systems does the Apache foundation need targeted at Java?

A: 

<subjective opinion> Java is WAYYYYY overtooled and frameworked to death </subjective opinion>

Jason Watts
It only has so many *options* because it is so widely used.
geowa4
You just said you don't like having the appropriate tool to do the job.
Jim Barrows
+7  A: 

Well first there was ANT, and that was too procedural and XML based instead of a real scripting language.

Then there was Maven. That was too complex.

Then Ruby got popular, so this is an attempt to make a better build process that is as powerful as Maven as using a DSL based on Ruby to not make it complicated. It's all the latest rage (DSL's in Ruby) in some circles.

You didn't mention Ivy, which brings some more Maven functionality to ANT.

The nice thing about Java is there are so many options. The bad thing about Java is there are so many options ...

But anyway, the core answer is that Buildr attempts to solve the build challenge with a different technology approach (a DSL in Ruby) something that doesn't exist in another Apache project.

Yishai
I didn't mention Ivy, as it is a plugin for Ant. Even though it extends the functionality into the realm of Maven, it just proves my point that any of these systems are extensible to suit a purpose/need.
Scott Markwell
i agree what said about there being so many options in Java. well said.
the0ther
+6  A: 

I haven't used Buildr. It does looks like an improvement over Ant for people who do not need or want Maven's project structure and/or dislike XML.

I can see Buildr being useful for developers using JRuby with legacy Java code; assuming it can use also invoke rake and Capistrano tasks.

sal
Bringing a clean deployment environment for JRuby/Java/Groovy hybrid environments makes sense.Just another interesting tool to keep an eye on as it grows.
Scott Markwell
There are also a pair of Groovy builders, Gradle and Gant.
sal
+24  A: 

I use Buildr partially because it has the best Scala support of any build tool, but also because it has all of the dependency-managing goodness of Maven and then some. For example, Buildr makes it almost trivial to use artifacts which aren't in a repository. You can specify the URL of a zip or tarball to download, out of which Buildr will extract the relevant JAR file and install it into your local repository. For libraries which are in a Maven repository, Buildr is by far the easiest way to install them on your project's classpath. For example:

repositories.remote << 'http://repo1.maven.org/maven2'

define 'my-project' do
  compile.with 'commons-cli:commons-cli:jar:1.0'
end

After installing that in your buildfile and placing your sources in src/main/java, just run:

$ buildr

Buildr will take care of downloading the Commons CLI dependency, compiling your sources and running all tests (if any). As an extra bonus, it will perform all of these tasks quite a bit faster than Maven would have (really, Buildr performs exceptionally well).

What really puts the icing on the cake is how easy it is to define ad hoc tasks. Buildr is built on top of Rake, which means that anything you can do with Rake, you can do in exactly the same way with Buildr. For example, let's say that I wanted to define a task to generate documentation for my project using ReStructured Text. Buildr doesn't have a built-in task for that, but I can easily define one of my own:

define 'my-project' do
  task :rst do
    system 'rst2html', _('README.rst'), _('README.html') \
      or fail 'Unable to invoke rst2html.'
  end
end

With this, I can invoke the following from any subdirectory of the project:

$ buildr my-project:rst

Buildr takes care of canonicalizing the paths (that's what the mysterious _ method handles). I could even change things up a bit using Rake file task magic so that the rst task only runs if the README.rst file has changed since the last rebuild:

define 'my-project' do
  file _('README.html') => _('README.rst') do
    system 'rst2html', _('README.rst'), _('README.html') \
      or fail 'Unable to invoke rst2html.'
  end

  task :rst => [ file _('README.html') ]
end

It's hard to overstate just how powerful and useful this is in practice. I used to be a die-hard Ant user, not because I liked the tool, but because it was standard and I had yet to see anything better. Maven was (and is) too complicated and too restrictive. Imagine trying something like the above in Maven. You would have to write an entire plugin, just for that!

The only problem with Buildr is the fact that it isn't very widely used, and so a) not a lot of people have it installed, and b) not a lot of people know how to use it. It's not a difficult tool, but it's harder than Ant if that's what your dev team already knows. Fortunately, both of these problems are easily remedied given enough time and exposure.

If you think about it, the question isn't "Why use Buildr?", it's really "Why use anything else?" The advantages afforded by Buildr are so substantial, I really can't see myself going with any other tool, at least not when I have a choice.

Daniel Spiewak
+1 for a knowledgeable answer. Personally though, it's still unclear whether/why a team using Ant extensively (but not Maven!) should migrate to Buildr. For one thing, the syntax, while less verbose than that of Ant, seems less straight-forward to understand. But perhaps it is just a matter of getting used to it...
Jonik
+8  A: 

I've used Buildr for quite some time and believe me, it's an order of magnitude or two less painful than Maven. Copying a file is cp, not 20 lines of XML you have to spend 4 hours to get right. We're using it on a fairly big and complex build, in Apache ODE. Check it out for yourself (that's the whole thing):

http://github.com/apache/ode/blob/trunk/Buildfile

We used to rely on Ant, with a fairly extensive set of scripts. It worked but was expensive to maintain. The biggest mistake afterward was to migrate to Maven2. I could write pages of rants explaining all the problems we ran into and we still ended up with thousands of lines of XML. Check these two excerpts:

http://github.com/apache/ode/blob/aa9743cd981a4d2f9ea8668c3283cc1cb6b08bcf/pom.xml http://github.com/apache/ode/blob/aa9743cd981a4d2f9ea8668c3283cc1cb6b08bcf/axis2-war/pom.xml

$ ack -g "(build|pom).xml" | xargs wc -l 4652 total

By my count that's 4652 lines against 698 and our build was much simpler back then, so the comparison isn't even completely fair to Buildr.

So which one would you rather write/read/maintain?

Matthieu
The project's buildfile, fwiw, now seems to be here:http://github.com/apache/ode/blob/trunk/RakefilePersonally I prefer the maven poms - they are very verbose and long, but it's mostly just dependency lists, and I feel like they are easier to understand than 750-odd lines of dense Ruby split among 3 files. But of course who knows how complex the Maven version would be by now. Matthieu, what's your opinion on how Buildr has held up over a year or so?
Tim Gilbert
A: 

It's not hard to write a plugin, but it is a lot of overhead to wrap a one-shot action as a plugin. It is also harder to maintain (need to edit the plugin file, build, package, deploy instead of just changing the task code in the buildfile)

With BuildR, your build files are written in a real language (you can use variables, methods, loops, containers), which is needed because building a product requires custom logic (code). The myth that Maven tries to sell is that it is all just declaring what you wants (via properties) and a "maven" creates everything for you. You need your own code.

Because of the fact all the modules are defined in one file, it allows to easily share common data (artifact names/versions, custom methods, layouts etc.) between projects (contrary to mavens inheritance or ant's import)

After using BuildR for some time now I can say it is very well designed (but not over-designed as Maven is)

One more thing, that people may not consider is that because of the openness of Ruby I found I can fix bugs in BuildR by rewriting the buggy method (usually very short) in a file checked out with the project. This means I'm not biting my nails waiting for the next BuildR release. I just submit a bug, fix the bug and go on.

IttayD
+1  A: 

I've moved our code base to buildr, and overall, am much more pleased than the XML-based tools.

Experiences:

  1. It's taken me a while to get the buildr workflow when I need to customize it
  2. Figuring out what part of the API documentation does what is still a little mystifying for someone who doesn't really know Ruby intensely
  3. #1 and #2 didn't matter at all: I was able to customize EJB and Jarjar deployments, change the TestNG workflow, etc, without really feeling strong about the tool or the ruby language.

That's still the strongest sell: it builds everything I need, and as I've needed more, I just got things working without a lot of fuss. Haven't done C-based builds, but we do preprocess markdown into a documentation site, for example. And we just integrated that tool with very little code.

With maven and ant, I always ended up making substantial external scripts. With buildr, it only takes a pretty minor amount of ruby knowledge for you to hack together a pretty workable system. And the more you learn, you will have far, far less code.

I never even got close to creating an ant or maven plugin - it was never worth the time.

Tristan Juricek
A: 

See also this thread on the buildr mailing list on buildr vs ant or maven: http://is.gd/1hjWa

And btw., I'm using buildr since then for my private projects and love it - it really provides best of both worlds (declarative/mvn + imperative/ant).

I'm also just in the process of converting a multi module ant project (using ant script library) to buildr and the build is getting much, much simpler.

The positive side effect for me as a java user is that I learn a little ruby, and that's easy but lots of fun... :-)

Martin Grotzke
A: 

Java is WAYYYYY overtooled and frameworked to death

True.

But look at the bright side. Writing yet another framework to solve every problem from now to eternity has launched many a bright career in IT.

Joe
A: 

@IttayD

I am finding hard time to figure out how to

group artifacts in build.yaml

Like we do in buildfile

JAVAX = struct( :activation =>'javax.activation:activation:jar:1.1', :persistence =>'javax.persistence:persistence-api:jar:1.0', :stream =>'stax:stax-api:jar:1.0.1', )

and use it as compile.with JAVAX.stream

I have my artifacts in build.yaml, and using in buildfile

example artifacts:\n test1: test1:test1:jar:1.1.1

compile.with artifacts(:test1)

buildingagent
Requests for help should be in their own questions, not as Answers to an existing question.
Ed Brannin