Is there any standard directory layouts for Java projects? What layout do you prefer most?
Java项目是否有任何标准目录布局?你最喜欢什么布局?
I'm asking about more complex layout than just 'src' and 'bin' in project's directory (i.e. where do you put your test classes, build configurations, etc.?).
我问的是比项目目录中的'src'和'bin'更复杂的布局(即你在哪里放置你的测试类,构建配置等?)。
Thanks in advance.
提前致谢。
5 个解决方案
#1
I usually use /src for source code, /test or /tst for test code, /build for class files, /lib or /libs for dependencies, /dist for my JAR and libraries (so I can just compress the directory and distribute it without thinking), and /docs for documentation (including JavaDoc). My Ant build script goes in the directory that the ones I named are subdirectories of.
我通常使用/ src作为源代码,/ test或/ tst作为测试代码,/ build作为类文件,/ lib或/ libs作为依赖项,/ dist作为我的JAR和库(所以我可以只压缩目录并分发它)没有思考)和/ docs文档(包括JavaDoc)。我的Ant构建脚本位于我命名的目录是子目录的目录中。
When I build, I create the JAR from /build and copy /lib and maybe /docs into /dist.
当我构建时,我从/ build和copy / lib创建JAR,并将/ docs创建到/ dist。
#2
Are you using any build tools? Like Maven for example? If not, you probably should - and in that case your directory layout would be predefined for you.
你在使用任何构建工具吗?比如Maven?如果没有,您可能应该 - 并且在这种情况下,您的目录布局将为您预定义。
#3
You could take a look at Sun Developers Network - Project Conventions (Internet Archive)
您可以看看Sun Developers Network - 项目约定(Internet Archive)
#4
I use:
programming
- distro
- java
- lib
- src
- com...
- net...
- org...
- tools
And I compile classes side-by-side with the sources, and package from there to a subdirectory of distro.
我和源代码并排编译类,并从那里打包到发行版的子目录。
#5
For web projects I usually use:
对于我经常使用的Web项目:
<project name>
dev
src
lib
www
build.xml
build
www
bin
www
The www
folder in src is the original. The www
folder in build is where that gets combined with the contents of similar folders to produce what needs to be uploaded. The www
folder outside is where I run a local copy, complete with temporary files and other such garbage. I have an ant script in build.xml
to copy things around.
src中的www文件夹是原始文件夹。构建中的www文件夹与类似文件夹的内容结合在一起,以生成需要上载的内容。外面的www文件夹是我运行本地副本的地方,包含临时文件和其他此类垃圾。我在build.xml中有一个ant脚本来复制东西。
I'd like to know if there is any sort of standard.
我想知道是否有任何标准。
#1
I usually use /src for source code, /test or /tst for test code, /build for class files, /lib or /libs for dependencies, /dist for my JAR and libraries (so I can just compress the directory and distribute it without thinking), and /docs for documentation (including JavaDoc). My Ant build script goes in the directory that the ones I named are subdirectories of.
我通常使用/ src作为源代码,/ test或/ tst作为测试代码,/ build作为类文件,/ lib或/ libs作为依赖项,/ dist作为我的JAR和库(所以我可以只压缩目录并分发它)没有思考)和/ docs文档(包括JavaDoc)。我的Ant构建脚本位于我命名的目录是子目录的目录中。
When I build, I create the JAR from /build and copy /lib and maybe /docs into /dist.
当我构建时,我从/ build和copy / lib创建JAR,并将/ docs创建到/ dist。
#2
Are you using any build tools? Like Maven for example? If not, you probably should - and in that case your directory layout would be predefined for you.
你在使用任何构建工具吗?比如Maven?如果没有,您可能应该 - 并且在这种情况下,您的目录布局将为您预定义。
#3
You could take a look at Sun Developers Network - Project Conventions (Internet Archive)
您可以看看Sun Developers Network - 项目约定(Internet Archive)
#4
I use:
programming
- distro
- java
- lib
- src
- com...
- net...
- org...
- tools
And I compile classes side-by-side with the sources, and package from there to a subdirectory of distro.
我和源代码并排编译类,并从那里打包到发行版的子目录。
#5
For web projects I usually use:
对于我经常使用的Web项目:
<project name>
dev
src
lib
www
build.xml
build
www
bin
www
The www
folder in src is the original. The www
folder in build is where that gets combined with the contents of similar folders to produce what needs to be uploaded. The www
folder outside is where I run a local copy, complete with temporary files and other such garbage. I have an ant script in build.xml
to copy things around.
src中的www文件夹是原始文件夹。构建中的www文件夹与类似文件夹的内容结合在一起,以生成需要上载的内容。外面的www文件夹是我运行本地副本的地方,包含临时文件和其他此类垃圾。我在build.xml中有一个ant脚本来复制东西。
I'd like to know if there is any sort of standard.
我想知道是否有任何标准。