摘要:我會投入一些時間來設置構建和部署方案。這是一項前期工作,但是一個通用的解決方案可以在安裝後根據需要進行增長。
您可以使用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