1 <?xml version="1.0" encoding="UTF-8"?>
4 Licensed to the Apache Software Foundation (ASF) under one
5 or more contributor license agreements. See the NOTICE file
6 distributed with this work for additional information
7 regarding copyright ownership. The ASF licenses this file
8 to you under the Apache License, Version 2.0 (the
9 "License"); you may not use this file except in compliance
10 with the License. You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing,
15 software distributed under the License is distributed on an
16 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 KIND, either express or implied. See the License for the
18 specific language governing permissions and limitations
22 <project default="-deploy-ant" basedir=".">
23 <target name="-init-cl-deployment-env" if="deploy.ant.enabled">
24 <property file="${deploy.ant.properties.file}" />
25 <available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>
26 <available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/>
27 <available file="${deploy.ant.resource.dir}" property="has.setup"/>
28 <tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
29 <echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
32 <target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
33 <tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
34 <copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
35 <!-- The doctype triggers resolution which can fail -->
36 <replace file="${temp.sun.web}">
37 <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
38 <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
40 <replace file="${temp.sun.web}">
41 <replacetoken><![CDATA[<sun-web-app]]></replacetoken>
42 <replacevalue><![CDATA[--> <sun-web-app]]></replacevalue>
44 <xmlproperty file="${temp.sun.web}" validate="false">
46 <delete file="${temp.sun.web}"/>
47 <condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
48 <isset property="sun-web-app.context-root"/>
50 <condition property="deploy.context.root.argument" value="&contextroot=${sun-web-app.context-root}" else="/${ant.project.name}">
51 <isset property="sun-web-app.context-root"/>
54 <target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present">
55 <tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/>
56 <copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/>
57 <!-- The doctype triggers resolution which can fail -->
58 <replace file="${temp.gf.web}">
59 <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
60 <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
62 <replace file="${temp.gf.web}">
63 <replacetoken><![CDATA[<glassfish-web-app]]></replacetoken>
64 <replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue>
66 <xmlproperty file="${temp.gf.web}" validate="false">
68 <delete file="${temp.gf.web}"/>
69 <condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
70 <isset property="glassfish-web-app.context-root"/>
72 <condition property="deploy.context.root.argument" value="&contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}">
73 <isset property="glassfish-web-app.context-root"/>
76 <target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present">
77 <property name="deploy.context.root.argument" value=""/>
79 <target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup">
80 <tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/>
81 <mkdir dir="${gfv3.resources.dir}"/>
82 <mkdir dir="${gfv3.resources.dir}/META-INF"/>
83 <copy todir="${gfv3.resources.dir}/META-INF">
84 <fileset dir="${deploy.ant.resource.dir}"/>
86 <jar destfile="${deploy.ant.archive}" update="true">
87 <fileset dir="${gfv3.resources.dir}"/>
89 <delete dir="${gfv3.resources.dir}"/>
91 <target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled">
92 <antcall target="-deploy-without-pw"/>
93 <antcall target="-deploy-with-pw"/>
96 <target name="-deploy-without-pw" unless="gfv3.password">
97 <echo message="Deploying ${deploy.ant.archive}"/>
98 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
99 <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
100 <get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&force=true&name=${ant.project.name}"
101 dest="${gfv3.results.file}"/>
102 <delete file="${gfv3.results.file}"/>
104 <target name="-deploy-with-pw" if="gfv3.password">
105 <echo message="Deploying ${deploy.ant.archive}"/>
106 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
107 <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
108 <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&force=true&name=${ant.project.name}"
109 dest="${gfv3.results.file}"/>
110 <delete file="${gfv3.results.file}"/>
112 <target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled">
113 <antcall target="-undeploy-without-pw"/>
114 <antcall target="-undeploy-with-pw"/>
117 <target name="-undeploy-without-pw" unless="gfv3.password">
118 <echo message="Undeploying ${deploy.ant.archive}"/>
119 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
120 <get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
121 dest="${gfv3.results.file}"/>
122 <delete file="${gfv3.results.file}"/>
124 <target name="-undeploy-with-pw" if="gfv3.password">
125 <echo message="Undeploying ${deploy.ant.archive}"/>
126 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
127 <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
128 dest="${gfv3.results.file}"/>
129 <delete file="${gfv3.results.file}"/>