views:

1778

answers:

5

I am going to be using Subversion for source control on a new J2EE web application. What directory structure will you recommend for organizing code, tests and documentation?

+8  A: 

I usually have

Project Directory
  src - actual source
  doc - documentation
  lib - libraries referenced from source
  dep - installation files for dependencies that don't fit in lib
  db  - database installation script

In work with Visual Studio, I'm not sure if this works the same in the java world. But i usually put stuff in different project folders in src. For each source project there's a separate test project. Build files go in the main project directory. I usually put a README there too documenting how to setup the project if it needs more than just checking out.

Mendelt
+2  A: 

I found some old questions here on SO that might be interesting for you:

onnodb
A: 

I use Eclipse for creating J2EE web applications and this will create the following project structure:

WebAppName\
    \lib
    \src
    \tests
    etc...

I would then create an SVN folder on our trunk called WebAppNameProject. Within this folder I would create folders called WebAppNameSource, Documentation etc. Within the WebAppNameSource folder I would place the project source generated by Eclipse. Thus I would have the following folder structure in SVN:

\svn\trunk\WebAppNameProject
    \WebAppNameSource
        \lib
        \src
        \tests
        etc...
    \Documentation

Hope this helps.

redspike
+2  A: 

To expand on what Mendelt Siebenga suggested, I would also add a web directory (for JSP files, WEB-INF, web.xml, etc).

Tests should go in a folder named test that is a sibling of the main src folder - this way your unit test classes can have the same package name as the source code being tested (to ease with situations where you want to test protected methods or classes, for example... see the JUnit FAQ for this, and this question also on Where should I put my test files?).

I haven't had much use for it myself, but a Maven project will also create a resources folder alongside the src folder for non-source code that you want to package/deploy along with the main source code - things such as properties files, resources bundles, etc. Your mileage may vary on this one.

matt b
+1  A: 

Perhaps not the answer, but related... Another Stack Overflow QA session

Greg Ogle