简体   繁体   English

推荐的源代码管理目录结构?

[英]Recommended Source Control Directory Structure?

I am going to be using Subversion for source control on a new J2EE web application. 我将使用Subversion在新的J2EE Web应用程序上进行源代码控制。 What directory structure will you recommend for organizing code, tests and documentation? 您将建议使用哪种目录结构来组织代码,测试和文档?

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. 在使用Visual Studio时,我不确定这在Java世界中是否可以正常使用。 But i usually put stuff in different project folders in src. 但是我通常把东西放在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). 对于版本控制系统中的每个分支/标签,它都将重复(请记住,在大多数SVN系统中,副本很便宜)。 The above example under Subversion would look like: 上面Subversion下的示例如下所示:

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

To expand on what Mendelt Siebenga suggested, I would also add a web directory (for JSP files, WEB-INF, web.xml, etc). 为了扩展Mendelt Siebenga的建议,我还将添加一个web目录(用于JSP文件,WEB-INF,web.xml等)。

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? ). 测试应放在名为test的文件夹中,该文件夹是src主文件夹的同级文件夹-这样,您的单元测试类可以与被测试的源代码具有相同的程序包名称(以缓解您要测试受保护的方法或类的情况) ,例如... 有关此内容 ,请参见JUnit常见问题解答 ,以及有关将测试文件放在哪里的问题。

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. 我本人并没有太多用处,但是Maven项目还将在src文件夹旁边创建一个resources文件夹,用于存储要打包/部署的非源代码以及主要源代码,例如属性文件,资源包等。您的里程可能与此不同。

I use Eclipse for creating J2EE web applications and this will create the following project structure: 我使用Eclipse创建J2EE Web应用程序,这将创建以下项目结构:

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

I would then create an SVN folder on our trunk called WebAppNameProject. 然后,我将在我们的主干上创建一个名为WebAppNameProject的SVN文件夹。 Within this folder I would create folders called WebAppNameSource, Documentation etc. Within the WebAppNameSource folder I would place the project source generated by Eclipse. 在此文件夹中,我将创建名为WebAppNameSource,Documentation等的文件夹。在WebAppNameSource文件夹中,我将放置由Eclipse生成的项目源。 Thus I would have the following folder structure in SVN: 因此,我在SVN中将具有以下文件夹结构:

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

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM