views:

111

answers:

3

Hello
Step two of "The Joel Test: 12 Steps to Better Code" states "Can you make a build in one step?". My answer to this is currently no. My application is structured as follows:

+
+-MyApp // this is just a vanilla Java Application
+-MyWebApp // this Dynamic Java Web Application (deployed Tomcat and launches
           // a thread contained in MyApp) 
+-MyCommonStuff // these are common classes shared between MyApp and MyWebApp
                // Ex. Database access code & business classes

In order to build and deploy my software I perform the following steps:
1. Checkout MyApp, MyWebApp, MyCommonStuff from svn
2. build MyCommonStuff.jar and copy to a "libs" directory
3. build MyApp and copy to a "libs" directory
4. build MyWebApp.war (Ant build.xml file specifies where MyApp.jar and MyCommonStuff.jar are located)
5. The deploy portion of build.xml used Tomcat deployment tasks to deploy to a tomcat server.

My question is does the Joel rule above apply to this scenario. i.e. should there be a "master" build script which executes steps 1. to 5.?
Should the script just be a normal #/bin/sh script or are there tools I can leverage. My preference would be stick to using Ant and linux console commands.
Thanks

+5  A: 

You can (and should) use maven2. It supports everything required (via plugins). You just need to conform to its directory conventions.

In addition I'd suggest a Continous Integration Engine, which will take your maven configuration and execute and deploy everything. Hudson and TeamCity are good options.

Bozho
I feel using maven would be an overkill for what I'm trying to achieve. The learning curve is too steep for the benefits I get in return - which is why I stated "My preference would be stick to using Ant and linux console command".Thanks.
leftbrainlogic
that's often a wrong train of thoughts. Ant scripts are capable of doing this but you'll end up with a more complex script which is harder to support than if you use maven.
Bozho
even if its for something simple, using a standard tool like maven will probably pay off in the future if you are to maintain/extend the project. However, there are some pain points in maven, especially if there are libraries that have not been mavenized (but you are using). Perhaps ant is a good option after all
Chii
non-mavenized libraries can be used in local repositories, so that's no issue.
Bozho
+2  A: 

An alternative to Maven, if you just want to use Ant, is Ivy. This is just a dependency manager, a bit like Maven but without all the other stuff Maven does.

I would suggest using one of the two. If you have a project with dependencies like this, you're going to make it so much easier for yourself if you store them in a central repository and use a dependency manager to include them!

Phill Sacre
and he needs "all the other things that maven does" :)
Bozho
+1  A: 

You should do a global ant script, calling all little ant parts through the ant ant task.

Edit after reading other answers : you should also use maven. But if Maven is really overkill, and you just want to launch the whole build in one step, use a global build.xml

Valentin Rocher