ant-deploy.xml 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  4. Copyright (c) 2006, 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" if="deploy.ant.enabled">
  38. <property file="${deploy.ant.properties.file}"/>
  39. <tempfile property="temp.module.folder" prefix="tomcat" destdir="${java.io.tmpdir}"/>
  40. <unwar src="${deploy.ant.archive}" dest="${temp.module.folder}">
  41. <patternset includes="META-INF/context.xml"/>
  42. </unwar>
  43. <xmlproperty file="${temp.module.folder}/META-INF/context.xml"/>
  44. <delete dir="${temp.module.folder}"/>
  45. </target>
  46. <target name="-check-credentials" if="deploy.ant.enabled" depends="-init">
  47. <fail message="Tomcat password has to be passed as tomcat.password property.">
  48. <condition>
  49. <not>
  50. <isset property="tomcat.password"/>
  51. </not>
  52. </condition>
  53. </fail>
  54. </target>
  55. <target name="-deploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
  56. <echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/>
  57. <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
  58. classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
  59. <deploy url="${tomcat.url}/manager" username="${tomcat.username}"
  60. password="${tomcat.password}" path="${Context(path)}"
  61. war="${deploy.ant.archive}"/>
  62. <property name="deploy.ant.client.url" value="${tomcat.url}${Context(path)}"/>
  63. </target>
  64. <target name="-undeploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
  65. <echo message="Undeploying ${Context(path)}"/>
  66. <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
  67. classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
  68. <undeploy url="${tomcat.url}/manager" username="${tomcat.username}"
  69. password="${tomcat.password}" path="${Context(path)}"/>
  70. </target>
  71. </project>