摘要:我会投入一些时间来设置构建和部署方案。这是一项前期工作,但是一个通用的解决方案可以在安装后根据需要进行增长。
您可以使用Ant脚本完成第1步。您首先安装Ant,然后编写一个简短的build.xml以包含this example之类的内容。在Ant正确安装的情况下,您只需切换到build.xml所在的目录并运行'ant'。
对于步骤2到6,由于您需要清理目标,管理服务等,我会考虑生成MSI安装程序或可执行文件。我的第一个MSI工具选择是Advanced Installer。您会在the list of features下看到免费版本允许您在安装和卸载时控制(启动,停止,安装,卸载)Windows服务。
(旁注:我们使用高级安装企业四年来它的不断完善,以及一个非常高品质的产品,您一定不会失望。)
您可以控制MSI创建直通蚂蚁以及。下面是从我的build.xml剪断调用几个宏来编译和部署产品之一,我保持:
<target name="myproduct-installer" depends="unzip-myproductdocs">
<build-ai-installer product.name="MyProduct" installer.path="setup/installs/MyProduct" project.file="MyProduct.aip" />
</target>
<target name="release-myproduct-installer">
<release-AI-installer product.name="MyProduct" installer.path="setup/installs/MyProduct" product.path="${some-predefined-target}" />
</target>
下面是上面使用的宏:
<macrodef name="build-ai-installer">
<attribute name="product.name" />
<attribute name="installer.path" />
<attribute name="project.file" />
<sequential>
<echo message="Making installer at @{installer.path}" />
<mkdir dir="@{installer.path}/newInstall" />
<exec dir="@{installer.path}" executable="${env.ADVANCEDINSTALLER}" failonerror="true">
<arg line="/edit @{project.file} /SetVersion ${product.version}" />
</exec>
<exec dir="@{installer.path}" executable="${env.ADVANCEDINSTALLER}" failonerror="true">
<arg line="/build @{project.file}" />
</exec>
</sequential>
</macrodef>
<macrodef name="release-AI-installer">
<attribute name="product.name" />
<attribute name="installer.path" />
<attribute name="product.path" />
<sequential>
<copy todir="@{product.path}">
<fileset dir="@{installer.path}/newInstall" />
</copy>
</sequential>
</macrodef>
这些宏使用Windows环境变量名为env.ADVANCEDINSTALLER。更简单的构建设置将只设置Ant属性并放弃'env。'前缀:
<property name="ADVANCEDINSTALLER" value="path-to-AdvancedInstaller.com" />
该级别的自动化一旦启动并运行就会支付股息。但如果它比你需要的更多(我不会感到惊讶),this answer可能会有所帮助。
看到这个ANT build.xml http://stackoverflow.com/a/18460429/185565回答。它展示了如何在开发时直接从项目文件夹使用webapp。更容易看到.jsp,.js,.css立即更改。后来建立战争部署在某个地方。部署可能使用ant filecopy或ssh/ftp将.war复制到tomcat/webapps /文件夹。 – Whome 2013-09-08 22:13:06