我应该如何布局我的存储库?
我正在将一个应用程序从它与一堆其他东西共享的 svn 存储库中移出到它自己的全新存储库中。所以,我有机会重新开始布局。
该应用程序本身有两个组件 - 一个相当标准的 Java Web 应用程序,它与数据库通信;以及一个后端组件,也是 Java,它轮询数据库,并根据它发现的内容启动长时间运行的处理任务 - 本质上是数据库被用作队列。代码分为三个包:
org.blah.common
- 在 Web 应用程序和后端之间共享的代码,例如 DAOorg.blah.webapp
-网络应用程序;这取决于org.blah.common
,并构建为.war
文件。org.blah.backend
- 后端进程;这取决于 org.blah.common,并构建为包含 jar 和一些脚本的 tar 文件。
我还想将 tomcat 和 apache 配置的其他部分也放入 svn 中。
现在,所有三个包都位于 svn 中的 src
目录下,并且有一个具有不同目标的 ant 脚本来构建不同的部分。这一切都有点杂乱 - svn:ignore 属性已经变得相当大,并且一个目录中的脚本与 src
下某个包中的代码相关,而另一个目录中的脚本与另一个目录中的代码相关并不明显用于启动和停止 tomcat。
我被 maven 标准目录布局所吸引,但我以前没用过它。我想出了这个:
common/
src/
main/
java/
resources/
test/
java/
resources/
target/ # Not checked in
common.jar
webapp/
src/
main/
java/
resources/
webapp/
test/
java/
resources/
target/ # Not checked in
webapp.war
backend/
src/
main/
java/
perl/
resources/
test/
java/
resources/
target/ # Not checked in
backend.tar
infra/
tomcat/
bin/
conf/
apache/
bin/
conf/
db/
tables/
procs/
triggers/
请注意,现在,我不打算迁移到 maven - 我将调整现有的 ant 脚本,因为它们可以工作。不过,我想保留在未来某个时候迁移到 Maven(或类似 buildr 的东西,使用 Maven 布局)的选择。
那么:
- 这看起来是一种合理的存储库布局方式吗?有什么事情会让我进一步陷入困境吗?
- 这对于刚接触该应用程序的人来说是显而易见的吗?
- 这与 Maven 兼容吗?我应该决定使用它吗? (我知道理论上,你可以让 Maven 使用任何布局,但我相信他们推荐一个标准是有原因的。)
- IDE 会遇到任何问题吗? (根据我使用的计算机,我使用 intellij 或 eclipse。我团队中的其他人 - 他们对此没有意见 - 使用 netbeans。)
I'm moving an application out of an svn repository it shares with a bunch of other stuff into its own, brand new one. So, I have a chance to make a fresh start with layout.
The app itself has two components - a reasonably standard Java webapp, that talks to a database, and a backend component, also Java, that polls the db, and kicks off long-running processing tasks based on what it finds - essentially, the DB is being used as a queue. The code is broken up into three packages:
org.blah.common
- code, such as DAOs, that is shared between web app and back endorg.blah.webapp
- The web app; this depends onorg.blah.common
, and builds out to a.war
file.org.blah.backend
- The back end process; this depends onorg.blah.common
, and builds out to a tar file containing a jar and some scripts.
I'd also like to get other bits of tomcat and apache config into svn as well.
Right now, all three packages are in svn under a src
dir, and there's an ant script with different targets that build the different parts. It's all a bit scrappy - the svn:ignore property has gotten quite big, and it's not immediately apparent that the scripts in one dir are related to the code in some package down under src
, while those in another are for starting and stopping tomcat.
I'm drawn to the maven standard directory layout, but I've not used it before. I've come up with this:
common/
src/
main/
java/
resources/
test/
java/
resources/
target/ # Not checked in
common.jar
webapp/
src/
main/
java/
resources/
webapp/
test/
java/
resources/
target/ # Not checked in
webapp.war
backend/
src/
main/
java/
perl/
resources/
test/
java/
resources/
target/ # Not checked in
backend.tar
infra/
tomcat/
bin/
conf/
apache/
bin/
conf/
db/
tables/
procs/
triggers/
Note that right now, I don't intend to migrate to maven - I'll adapt the existing ant scripts, since they work. I'd like to keep the option of moving to maven (or something like buildr, that uses the maven layout) at some point in the future though.
So:
- Does this seem like a reasonable way of laying out the repository? Is there anything that will trip me up further down the line?
- Is this going to be obvious to people new to the app?
- Would this be compatible with maven, should I decide to use it? (I know that theoretically, you can make maven work with any layout, but I believe they recommend a standard for a reason.)
- Are IDEs going to have any problems with this? (Depending on which computer I'm on, I use intellij or eclipse. Other people on my team - who helpfully don't have opinions on this - use netbeans.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,Maven 捕获了行业最佳实践,包括布局,因此即使您现在没有使用 Maven,这似乎也是一个非常好的选择。实际上,这是从其他技术迁移到 Maven 时推荐的迁移策略:首先迁移到 Maven 布局并更新现有的构建脚本,然后引入 Maven。在你的情况下,如果所有项目都有相同的生命周期(如果它们都一起发布),我没有任何特别的评论,除了可能无法使用 Maven 以这种方式管理的基础项目,但现在没有任何阻碍。
我发现这很清楚,老实说,如果有些人有问题并且无法适应,也许是他们需要修复:)
它似乎几乎与 Maven 完全兼容(除了我所说的基础部分,但这实际上不是问题) 。是的,如果您不必修改 Maven 的配置并使用默认约定,这显然会更简单。请注意,您可以与 Ant 构建并行设置 Maven 构建,以实现无缝移动。
我已经很长时间没有导入 Ant 项目了进入这些 IDE 之一,但我认为它们都应该能够处理这种布局(使用 Maven 时 100% 确定)。回答这个问题的最好方法当然是做一些测试:)
Well, Maven captures industry best practices, including the layout, so this seems a very good choice even if you're not using Maven right now. Actually, this is the recommended migration strategy when moving from another technology to Maven: first, move to Maven layout and update the existing build scripts and then, introduce Maven. In your case, if all projects have the same lifecycle (if they are all released together), I don't have any particular remarks except maybe about the infra project that may not be managed this way with Maven but, nothing blocking right now.
I find it pretty clear and, honestly, if some people have a problem with it and if they can't adapt, maybe it's them that need to be fixed :)
It seems almost entirely compatible with Maven (except the infra part as I said but this is really not an issue). And yes, it's obviously simpler if you don't have to modify Maven's configuration and use the default conventions. Note that you could setup a Maven build in parallel of the Ant build to move seamlessly.
It's been a long time since I didn't import an Ant project into one of these IDE but I think that they should all be able to deal with this layout (100% sure when using Maven). The best way to answer this question would be to do some testing of course :)
我遇到的唯一问题是我希望 src 目录直接包含源代码,而不是上面的布局。然而我认为这是一种我可以很快克服的思维方式,尤其是在 Eclipse 中。
The only issue I would have is that I expect
src
directories to directly have source code inside, rather than how the above layout is. However I think it is a way of thinking that I could overcome quite quickly, especially within Eclipse.为什么目标目录在存储库中?我喜欢不检查构建结果,因为它们可以很容易地重现。如果它们不能轻松重现,那么这就是应该解决的问题,而不是签入二进制文件。
除此之外,我没有发现此布局有任何问题。除了tomcat目录之外,它是标准的maven布局。
Why are the target directories in the repository? I am a fan of not checking in build results, as they can be reproduced easily. If they can't be reproduced easily, then that is the issue that should be solved instead of checking in binaries.
Other than that I don't see any issues with this layout. Except for the tomcat directory it is the standard maven layout.