hackdiary

Template for Java projects

Every time I start a new java project, no matter what size, the first thing I do is go hunting through my java directories looking for one to use as a template. Over time I've gathered some pretty useful ant targets and settled on a fairly rational directory structure. Today I got round to building a skeleton set of directories and files that I can reuse in the future. Here's a tarball of the results.

There are some features of the template that are specifically for deploying web apps into Tomcat. They can be easily ignored if you're not doing that. The directory structure goes like this:

Here are the targets in the ant buildfile:

java Posted by Matt Biddulph at January 24, 2003 06:53 PM

→ Lost Boy: Spooky

You should try Maven. It defines a structure and have reusable ant tasks packaged as Maven plugins.

http://jakarta.apache.org/turbine/maven/

It's awesome!

Posted by: Aslak Hellesøy on February 6, 2003 01:44 PM

Hi!

This is great, but I have one objection: tests should not be in its own directory. I think they should be in the src directory, together with the code they are testing.

BTW, I now have working targets for javancss, pmd, checkstyle, cvschangelog, jcsc, jmetra. It is like a drug... can't... stop... adding... cool... targets... :-)

Mats

Posted by: Mats Henricson on February 6, 2003 07:04 PM

When I build a project with this template, I put the tests in their own directory but with an identical hierarchy to the source. Each test also goes in the same java package as the source it's testing, to help with testing protected methods. So com.hackdiary.foo.Bar lives in src/com/hackdiary/foo/Bar.java and its tests go in tests/com/hackdiary/foo/BarTest.java.

The reason for keeping a separate test directory structure (apart from neatness) is to allow for separate compilation, packaging and deployment when I don't want to include the tests.

Posted by: Matt Biddulph on February 6, 2003 08:19 PM

Good idea.
Have you tried maven? or for that matter turbine?

Posted by: Jayson on May 12, 2003 03:28 PM

Looks like quite a good list, when developing Tomcat stuff I like to have a dist target that packages the build in a WAR file. This is really handy for deploying the same app to multiple servers (like I'm doing at the moment) especially with the file upload interface on the manager console.

Posted by: Ben Meadowcroft on September 2, 2003 12:55 PM

it was nice to see a java site which provides good help for the students.

Posted by: Ankit on February 16, 2004 04:45 PM

free java projects

Posted by: peabin on April 19, 2004 10:44 AM