You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base.xml 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?xml version="1.0"?>
  2. <project name="test" basedir=".">
  3. <property file="deploy.properties" />
  4. <property name="lock" value="deploy/lock.file" />
  5. <property name="deployDir" value="deploy/${server}" />
  6. <property name="serverPort" value="8080" />
  7. <property name="war" value="demo.war" />
  8. <property name="startupSpawn" value="false" />
  9. <property name="JAVA_HOME" value="/usr/lib/jvm/default-java" />
  10. <property name="waitMinutes" value="3" />
  11. <property name="waitUrl"
  12. value="http://localhost:${serverPort}/demo/VAADIN/themes/reindeer/styles.css" />
  13. <property name="shutdownWait" value="10" />
  14. <target name="afterDeploy">
  15. <!-- Empty default -->
  16. </target>
  17. <target name="beforeDeploy">
  18. <!-- Empty default -->
  19. </target>
  20. <target name="deploy">
  21. <antcall target="beforeDeploy" />
  22. <echo
  23. message="${server}: Deploying ${war} to ${deployDir}/${autodeployDir}" />
  24. <copy file="${war}" todir="${deployDir}/${autodeployDir}" />
  25. <antcall target="afterDeploy" />
  26. </target>
  27. <target name="deployStatic">
  28. <unzip src="${war}" dest="${staticDeployDir}/tmp-unpack-jar/">
  29. <patternset>
  30. <include name="WEB-INF/lib/*.jar" />
  31. </patternset>
  32. </unzip>
  33. <unzip dest="${staticDeployDir}">
  34. <fileset dir="${staticDeployDir}/tmp-unpack-jar/WEB-INF/lib"
  35. includes="*.jar" />
  36. <patternset>
  37. <include name="VAADIN/**" />
  38. </patternset>
  39. </unzip>
  40. <delete dir="${staticDeployDir}/tmp-unpack-jar/" />
  41. <unzip src="${war}" dest="${staticDeployDir}">
  42. <patternset>
  43. <include name="VAADIN/**" />
  44. </patternset>
  45. </unzip>
  46. </target>
  47. <target name="unpack-server">
  48. <echo message="${server}: Unpacking ${server}.tar.gz" />
  49. <delete dir="${server}" />
  50. <exec executable="tar">
  51. <arg value="-xf" />
  52. <arg value="${server}.tar.gz" />
  53. </exec>
  54. <move file="${server}" tofile="${deployDir}" />
  55. <echo message="Done." />
  56. </target>
  57. <target name="doStartup">
  58. <exec executable="./run.sh" spawn="${startupSpawn}">
  59. <env key="JAVA_HOME" value="${JAVA_HOME}" />
  60. </exec>
  61. </target>
  62. <target name="startup">
  63. <antcall target="doStartup" />
  64. <echo message="${server}: Waiting for ${waitUrl} to become available." />
  65. <waitfor maxwait="${waitMinutes}" maxwaitunit="minute"
  66. checkevery="10000" timeoutproperty="timeout">
  67. <http url="${waitUrl}" />
  68. </waitfor>
  69. <!-- Print load averages to get an indicator on whether the server
  70. still attempts to start up -->
  71. <exec executable="uptime" />
  72. <fail if="timeout" message="${server} failed to deploy" />
  73. <echo message="${server}: Demo deployed successfully." />
  74. </target>
  75. <target name="shutdown">
  76. <exec executable="./stop.sh">
  77. <env key="JAVA_HOME" value="${JAVA_HOME}" />
  78. </exec>
  79. <sleep seconds="${shutdownWait}" />
  80. </target>
  81. <target name="force-shutdown">
  82. <exec executable="./cleanup.sh" />
  83. </target>
  84. <target name="check-port">
  85. <fail
  86. message="${server}: Something is still listening on port ${serverPort}">
  87. <condition>
  88. <socket server="localhost" port="${serverPort}" />
  89. </condition>
  90. </fail>
  91. </target>
  92. <target name="check-lock">
  93. <available file="${lock}" property="lockAvailable" />
  94. <fail unless="lockAvailable" message="Instance is not locked!" />
  95. </target>
  96. <target name="get-lock">
  97. <mkdir dir="deploy" />
  98. <echo>${server}: Getting the lock</echo>
  99. <exec executable="lockfile" failonerror="true">
  100. <!-- Check every 10 seconds -->
  101. <arg value="-10" />
  102. <!-- Retry for 55 minutes (build server gives up after 60 minutes) -->
  103. <arg value="-r330" />
  104. <arg value="${lock}" />
  105. </exec>
  106. <echo>${server}: Got the lock</echo>
  107. </target>
  108. <target name="clean">
  109. <delete dir="${deployDir}" failonerror="false" />
  110. </target>
  111. <target name="release-lock">
  112. <!-- <exec executable="rm"> <arg value="-f" /> <arg value="${lock}"
  113. /> </exec> -->
  114. <delete>
  115. <fileset dir="." includes="${lock}" />
  116. </delete>
  117. <echo>${server}: Released the lock</echo>
  118. </target>
  119. <target name="startup-and-deploy"
  120. depends="check-lock,check-port,unpack-server,deploy,startup" />
  121. <target name="shutdown-and-cleanup" depends="shutdown,clean,release-lock,force-shutdown" />
  122. </project>