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.8KB

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