我应该将 WEB-INF 提交到版本控制中,还是使用 Ant 构建它?
Ant“war”任务就是这样做的 - 创建 WEB-INF 以及META-INF,取决于任务属性。
什么被认为是最佳实践? 将我的所有库保留在其他地方以供重复使用,例如 log4j,然后使用“war”任务构建它们? 或者将所有内容(包括 jars)签入 WEB-INF 下? 我有多个应用程序可以重复使用相同的库、图像、html 等。我们的开发人员使用 RAD7/Eclipse。
如果有任何开源 Java Web Apps 存储库布局的示例,我将不胜感激。
The Ant "war" task does just that - creates WEB-INF along with META-INF, depending on task attributes.
What is considered a best practice?
Keeping all my libs elsewhere for re-use, like log4j and then build them with "war" task?
Or have everything (including jars) checked-in under WEB-INF?
I have multiple apps that could re-use same libs, images, htmls, etc. Our developers use RAD7/Eclipse.
I'd appreciate any examples with opensource Java Web Apps repo layouts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您可以可靠地、动态地创建它,就不要签入它。这会引起混乱。在这种情况下,它类似于签入 .class 文件。
相反,签入构建文件和用于创建它的工件,然后让构建来处理它。
If you can reliably, dynamically create it, the don't check it in. That's going to cause confusion. In this situation it's analogous to checking in .class files.
Rather, check in the build file and the artifacts you use to create it, and let the build take care of it.
这是一个使用经典 Maven 目录布局的 Web 应用程序示例:
hifaces20-demo-messageboard-0.1.0-project.zip
Here's an example of web application which is using a classic Maven directory layout:
hifaces20-demo-messageboard-0.1.0-project.zip
我们使用 Eclipse。我发现签入 Eclipse 不隐藏的文件对我们来说效果很好。您检查了该项目,然后就可以开始了。没有更多的蚂蚁东西要运行或记得运行。
如果您始终使用 ant 进行构建(例如,如果您来自 Netbeans 商店),则仅签入那些原始文件。所有从其他地方复制的内容都不应明确签入。
We work with Eclipse. I have found that having the files that Eclipse do not hide checked in work well for us. You check out the project, and you are ready to go. No further ant stuff to run or remember to run.
If you build with ant always (e.g. if you come from a Netbeans shop) then check in only those files which are original. All those that are copied from elsewhere, should explicitly be not checked in.
我通常会检查 WEB-INF 文件夹,但排除 lib 和 classes 文件夹。当我需要这些库时,我使用 Maven 或 Ivy(ant 任务)检索它们。似乎工作得很好,我只在极端情况下检查库,我可能不会有 Ivy 缓存,或者库是“特殊的”并且在其他地方不存在。
I generally do check in the WEB-INF folder but exclude the lib and classes folder. When I need the libs I retrieve them using Maven or Ivy (ant tasks). Seems to work well, I only check in the libs if it's an extreme case where it's likely I wont have an Ivy cache or the lib is 'special' and doesn't exist anywhere else.