一步构建 Java Web 应用程序

发布于 2024-08-21 12:44:14 字数 919 浏览 6 评论 0原文

Joel 测试:改善代码的 12 个步骤”的第二步指出“你能做到吗?”一步构建?”。目前我对此的回答是否定的。我的应用程序的结构如下:

+
+-MyApp // this is just a vanilla Java Application
+-MyWebApp // this Dynamic Java Web Application (deployed Tomcat and launches
           // a thread contained in MyApp) 
+-MyCommonStuff // these are common classes shared between MyApp and MyWebApp
                // Ex. Database access code & business classes

为了构建和部署我的软件,我执行以下步骤:
1. 从 svn 签出 MyApp、MyWebApp、MyCommonStuff
2. 构建 MyCommonStuff.jar 并复制到“libs”目录
3.构建MyApp并复制到“libs”目录
4.构建MyWebApp.war(Ant build.xml文件指定MyApp.jar和MyCommonStuff.jar所在位置)
5. build.xml 的部署部分使用 Tomcat 部署任务部署到 tomcat 服务器。

我的问题是上面的乔尔规则是否适用于这种情况。即是否应该有一个“主”构建脚本来执行步骤 1. 到 5.?
该脚本应该只是一个普通的 #/bin/sh 脚本还是有我可以利用的工具。我的偏好是坚持使用 Ant 和 Linux 控制台命令。
谢谢

Step two of "The Joel Test: 12 Steps to Better Code" states "Can you make a build in one step?". My answer to this is currently no. My application is structured as follows:

+
+-MyApp // this is just a vanilla Java Application
+-MyWebApp // this Dynamic Java Web Application (deployed Tomcat and launches
           // a thread contained in MyApp) 
+-MyCommonStuff // these are common classes shared between MyApp and MyWebApp
                // Ex. Database access code & business classes

In order to build and deploy my software I perform the following steps:
1. Checkout MyApp, MyWebApp, MyCommonStuff from svn
2. build MyCommonStuff.jar and copy to a "libs" directory
3. build MyApp and copy to a "libs" directory
4. build MyWebApp.war (Ant build.xml file specifies where MyApp.jar and MyCommonStuff.jar are located)
5. The deploy portion of build.xml used Tomcat deployment tasks to deploy to a tomcat server.

My question is does the Joel rule above apply to this scenario. i.e. should there be a "master" build script which executes steps 1. to 5.?
Should the script just be a normal #/bin/sh script or are there tools I can leverage. My preference would be stick to using Ant and linux console commands.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拥抱没勇气 2024-08-28 12:44:14

您可以(并且应该)使用 maven2。它支持所需的一切(通过插件)。您只需要遵守其目录约定即可。

此外,我建议使用持续集成引擎,它将采用您的 Maven 配置并执行和部署所有内容。 HudsonTeamCity 是不错的选择。

You can (and should) use maven2. It supports everything required (via plugins). You just need to conform to its directory conventions.

In addition I'd suggest a Continous Integration Engine, which will take your maven configuration and execute and deploy everything. Hudson and TeamCity are good options.

看透却不说透 2024-08-28 12:44:14

如果您只想使用 Ant,则 Maven 的替代方案是 Ivy。这只是一个依赖管理器,有点像 Maven,但没有 Maven 所做的所有其他东西。

我建议使用两者之一。如果您有一个具有这样的依赖项的项目,如果您将它们存储在中央存储库中并使用依赖项管理器来包含它们,那么您将使自己变得更加容易!

An alternative to Maven, if you just want to use Ant, is Ivy. This is just a dependency manager, a bit like Maven but without all the other stuff Maven does.

I would suggest using one of the two. If you have a project with dependencies like this, you're going to make it so much easier for yourself if you store them in a central repository and use a dependency manager to include them!

暮年 2024-08-28 12:44:14

您应该编写一个全局 Ant 脚本,通过 Ant< /em> 蚂蚁任务

阅读其他答案后编辑:您还应该使用 maven。但如果 Maven 实在是太过分了,并且您只想一步启动整个构建,请使用全局 build.xml

You should do a global Ant script, calling all little ant parts through the Ant ant task.

Edit after reading other answers : you should also use maven. But if Maven is really overkill, and you just want to launch the whole build in one step, use a global build.xml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文