tags:

views:

709

answers:

12

I'm looking for a make utility for building large java programs. I'm aware of ANT already, but want to see what else is available.

Ideally, it should be able to handle the .java->.class package directory weirdness that fouls up GNU Make.

Win32, but cross platform is a plus.

EDIT: I see some cons to using ANT, which is why I wanted to see other options, though I'll probably end up using it anyway, just because it works.

  • requires nontrivial XML makefiles, "HelloWorld" is already 25 lines, and any more reasonable program gets large quickly.
  • solves all the wrong problems for me.
    • ant makes writing jar and javac command lines easier, generating manifests easier, specifying .java source files easier, specifying jvm/java properties easier, writing custom build tools easier.
    • ant does not make java class dependencies easier, and does not seem to have a more powerful variable system, both things usually solved by make utilities.

I'd use gnu make, but it can't figure out where the .class file for a .java file with a package declaration is going to end up.

+4  A: 

If you're starting a new project you may want to look into maven. It's kinda hard intially, but it handles a bunch of stuff for you including dependencies.

If you already have a project which you want to make a build file for, then I don't have any recommendations apart from the aforementioned ant.

SCdF
+2  A: 

This isn't so much an answer as a question. ANT is the standard way of building Java. It works well with Java, the myriad of Java tools out there and with Cruise Control. So why would you want to try anything else?

Unless you have an edge case that ANT doesn't cover, then I'd recommend you stick with ANT.

Of course I'd be happy for a more knowledgeable person to point out why my attitude is stupid and why there is a good case for looking at alternatives ;)

David Arno
ANT is overly heavy weight, the XML is gross, and it's next to impossible to make it avoid rebuilding everything.
wnoise
Ant gives the command to build everything, but that's because javac is smart enough not to. Sure XML is ugly, but I don't have to look at it if I don't want to. I have the option of letting my IDE handle it, or I can customize it if I choose.
Bill the Lizard
So basically the advantage of ant is that you don't have to look at it and it doesn't have to actually build your project intelligently. Frankly, I can do that with a script.
davenpcj
+2  A: 

One alternative is scons if you want something pretty lightweight. I've used it a little and found it to be pretty easy to understand, especially if you already know python syntax. Another option is maven, but it is not simple by any means. However, it does provide a lot of additional facilities such as helping to manage docs. I wouldn't refer to it as a make replacement however;)

AdamC
A: 

Well, obviously, there's the classic make (make, gmake, nmake) utilities, there's also (I think) some build systems written in Ruby, or maybe Python. They aren't Java specific, rather just scriptable build systems.

But ANT has been the leader of the pack pushing 8-9 years now, and in terms of the basics, it's pretty easy to get started with.

Back in the day, make from particularly horrible for compiling java because it was typically invoking the javac compiler for each file individually. ANT doesn't suffer from this, and, perhaps, make could be modified to not do that. But it was one of the elements of ANT that made it so popular. It was simply fast.

I appreciate that ANT may not be the perfect solution, but it sure it practical.

Will Hartung
GNU Make can be told to build multiple files at once, using the + target syntax, which can be built up programmatically. It's also possible to specify a library-like target that only rebuilds the source files that have changed, but all on one command line.
davenpcj
same goes for most other make utilities, fyi
davenpcj
+5  A: 

Forget ANT!!

Apache Maven is the way to go if you ask me.

The feature i like the most is it built in in dependency management. This means you dont have to check 3rd party JARs into your source control project.

You specify your dependencies in the maven POM (Project Object Model - Its basically an XML description of your project) and maven automatically downloads, compiles against them and packages them with your app.

Other really nice features are: Release management and distribution publication - Perform releases using maven console commands. This feature will tag your code base in source control. Checkout a clean copy, build it & package it for deployment. A second command will upload it to your repository for distribution to other end users.

A large and growing repository of libraries already using maven - EVERY Apache project uses maven. LOADS more are on board also. See for yourself, here's the main repo

Ability to host your own repo. - Where you can release your own builds and also upload JARs that dont exist in other public repos (like most SUN jars)

Declan Shanaghy
If you are doing anything worthwhile, you kind of have to host your own repository with Maven, otherwise you have multiple single points of failure (other people's repositories).Also, Maven's documentation is... lacking.
Dan Dyer
It has its rough edges, but in the end I've found maven to be by far the best Java build tool / dependency manager out there. If it weren't for maven, I'd have been driven mad by java some time ago.
Benson
A: 

I converted from Ant to Maven 2 and have not looked back since. Ant and Maven 2 different ways of building.With Ant you are giving instructions on how to build things. Whereas with Maven 2 you tell it what you want built. If you have an existing Ant build,xml you can take a first step in refactoring you build by wrapping that in an Maven 2 pom.xml.

bmatthews68
+5  A: 

Ant and Maven are definitely the two standards. If you're already familiar with Ant and want the dependency management that comes with Maven, you might take a look at Ivy.

One thing both Ant and Maven lack is true control structures in your build scripts. There are plugins you can download for Ant that provide some of this control, but (again, if you're already familiar with Ant) you may take a look at Gant which is a Groovy wrapper for Ant.

Townsfolk
Gant looks pretty good. I'll check it out.
davenpcj
+1  A: 

jmk. It's primitive, but so small that you can embed it in a source .tar.gz file and barely change its size.

finnw
Saw JMK, but can't tell if it is just supposed to replace make, or if it does more intelligent things with java than make typically does. Have any experience with it?
davenpcj
It's pretty much a direct replacement for make and has a similar set of functions. To solve your problem with directories you need something that parses java source code.
finnw
A: 

1) ant + ivy is pretty good if you have existing investment in ant. You don't have to move from ant to maven just for the dependency goodies.

2) gant and ant : how do they compare : http://java.dzone.com/articles/ant-or-gant-part-1

3) http://www.gradle.org/ -- uses groovy!

BR,
~A

anjanb
A: 

Unless Maven has really improved recently, I'd steer well clear of it. Unless you have some kind of monster "multi-project" with a gazillion dependencies of course.

After getting sick of looking at completely useless and unhelpful errors when attempting to do the simplest things (like FTP a war file to a server), Maven was thrown away and Ant dusted off. I haven't looked back since.

oxbow_lakes
A: 

I like to use ant with ant4eclipse. This allows me to set up dependencies in eclipse, do development builds and testing in eclipse, and do continuous builds using ant.

Scott Stanchfield
That's a good solution, but I'd prefer something more standalone.
davenpcj
A: 

I use ANT all the time. This is because i develop web applications using Google Web Toolkit (GWT) which has an extra step of compiling client side java into java script. With ant, all i needed to know is how GWT works and then i orchestrate the build myself. With maven, i have to wait till someone writes a plugin. or i write one myself. There is a possibility that other frameworks and tools that dont follow the usual conventions will come up. i dont have to keep looking for maven plugins all the time. With ant, i can do whatever i want in a transparent manner. I also enjoy writting xml files. (i have to because i have to write several - web.xml, application.xml, persistence.xml, SqlMap.xml, dataset.xml e.t.c. My point _ XML is one thing you have to learn to like)

Joshua Kamau