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.

ant-deploy.xml 8.5KB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  4. Copyright (c) 2008, 2016 Oracle and/or its affiliates. All rights reserved.
  5. Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  6. Other names may be trademarks of their respective owners.
  7. The contents of this file are subject to the terms of either the GNU
  8. General Public License Version 2 only ("GPL") or the Common
  9. Development and Distribution License("CDDL") (collectively, the
  10. "License"). You may not use this file except in compliance with the
  11. License. You can obtain a copy of the License at
  12. http://www.netbeans.org/cddl-gplv2.html
  13. or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  14. specific language governing permissions and limitations under the
  15. License. When distributing the software, include this License Header
  16. Notice in each file and include the License file at
  17. nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
  18. particular file as subject to the "Classpath" exception as provided
  19. by Oracle in the GPL Version 2 section of the License file that
  20. accompanied this code. If applicable, add the following below the
  21. License Header, with the fields enclosed by brackets [] replaced by
  22. your own identifying information:
  23. "Portions Copyrighted [year] [name of copyright owner]"
  24. If you wish your version of this file to be governed by only the CDDL
  25. or only the GPL Version 2, indicate your decision by adding
  26. "[Contributor] elects to include this software in this distribution
  27. under the [CDDL or GPL Version 2] license." If you do not indicate a
  28. single choice of license, a recipient has the option to distribute
  29. your version of this file under either the CDDL, the GPL Version 2 or
  30. to extend the choice of license to its licensees as provided above.
  31. However, if you add GPL Version 2 code and therefore, elected the GPL
  32. Version 2 license, then the option applies only if the new code is
  33. made subject to such option by the copyright holder.
  34. Contributor(s):
  35. -->
  36. <project default="-deploy-ant" basedir=".">
  37. <target name="-init-cl-deployment-env" if="deploy.ant.enabled">
  38. <property file="${deploy.ant.properties.file}" />
  39. <available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>
  40. <available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/>
  41. <available file="${deploy.ant.resource.dir}" property="has.setup"/>
  42. <tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
  43. <echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
  44. </target>
  45. <target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
  46. <tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
  47. <copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
  48. <!-- The doctype triggers resolution which can fail -->
  49. <replace file="${temp.sun.web}">
  50. <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
  51. <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
  52. </replace>
  53. <replace file="${temp.sun.web}">
  54. <replacetoken><![CDATA[<sun-web-app]]></replacetoken>
  55. <replacevalue><![CDATA[--> <sun-web-app]]></replacevalue>
  56. </replace>
  57. <xmlproperty file="${temp.sun.web}" validate="false">
  58. </xmlproperty>
  59. <delete file="${temp.sun.web}"/>
  60. <condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
  61. <isset property="sun-web-app.context-root"/>
  62. </condition>
  63. <condition property="deploy.context.root.argument" value="&amp;contextroot=${sun-web-app.context-root}" else="/${ant.project.name}">
  64. <isset property="sun-web-app.context-root"/>
  65. </condition>
  66. </target>
  67. <target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present">
  68. <tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/>
  69. <copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/>
  70. <!-- The doctype triggers resolution which can fail -->
  71. <replace file="${temp.gf.web}">
  72. <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
  73. <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
  74. </replace>
  75. <replace file="${temp.gf.web}">
  76. <replacetoken><![CDATA[<glassfish-web-app]]></replacetoken>
  77. <replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue>
  78. </replace>
  79. <xmlproperty file="${temp.gf.web}" validate="false">
  80. </xmlproperty>
  81. <delete file="${temp.gf.web}"/>
  82. <condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
  83. <isset property="glassfish-web-app.context-root"/>
  84. </condition>
  85. <condition property="deploy.context.root.argument" value="&amp;contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}">
  86. <isset property="glassfish-web-app.context-root"/>
  87. </condition>
  88. </target>
  89. <target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present">
  90. <property name="deploy.context.root.argument" value=""/>
  91. </target>
  92. <target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup">
  93. <tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/>
  94. <mkdir dir="${gfv3.resources.dir}"/>
  95. <mkdir dir="${gfv3.resources.dir}/META-INF"/>
  96. <copy todir="${gfv3.resources.dir}/META-INF">
  97. <fileset dir="${deploy.ant.resource.dir}"/>
  98. </copy>
  99. <jar destfile="${deploy.ant.archive}" update="true">
  100. <fileset dir="${gfv3.resources.dir}"/>
  101. </jar>
  102. <delete dir="${gfv3.resources.dir}"/>
  103. </target>
  104. <target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled">
  105. <antcall target="-deploy-without-pw"/>
  106. <antcall target="-deploy-with-pw"/>
  107. </target>
  108. <target name="-deploy-without-pw" unless="gfv3.password">
  109. <echo message="Deploying ${deploy.ant.archive}"/>
  110. <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
  111. <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
  112. <get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
  113. dest="${gfv3.results.file}"/>
  114. <delete file="${gfv3.results.file}"/>
  115. </target>
  116. <target name="-deploy-with-pw" if="gfv3.password">
  117. <echo message="Deploying ${deploy.ant.archive}"/>
  118. <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
  119. <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
  120. <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
  121. dest="${gfv3.results.file}"/>
  122. <delete file="${gfv3.results.file}"/>
  123. </target>
  124. <target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled">
  125. <antcall target="-undeploy-without-pw"/>
  126. <antcall target="-undeploy-with-pw"/>
  127. </target>
  128. <target name="-undeploy-without-pw" unless="gfv3.password">
  129. <echo message="Undeploying ${deploy.ant.archive}"/>
  130. <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
  131. <get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
  132. dest="${gfv3.results.file}"/>
  133. <delete file="${gfv3.results.file}"/>
  134. </target>
  135. <target name="-undeploy-with-pw" if="gfv3.password">
  136. <echo message="Undeploying ${deploy.ant.archive}"/>
  137. <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
  138. <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
  139. dest="${gfv3.results.file}"/>
  140. <delete file="${gfv3.results.file}"/>
  141. </target>
  142. </project>