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