Recommended Source Control Directory Structure?

a 夏天 提交于 2019-12-17 23:45:04

问题


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?


回答1:


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.

EDIT: This is the structure for a single working checkout of the project. It will be duplicated for each branch/tag in your revision control system (remember, in most SVN system, copies are cheap). The above example under Subversion would look like:

/project
    /trunk
        /src
        /doc
        /...
    /branches
        /feature1
            /src
            /doc
            /...
        /feature2
            /src
            /doc
            /...



回答2:


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

  • Whats a good standard code layout for a php application
    • Contains a link to an article on Scalable and Flexible Directory Structure for Web Applications (focus on PHP, though)
  • How to structure a java application, in other words: where do I put my classes?
  • Structure of Projects in Version Control



回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/41513/recommended-source-control-directory-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!