1 <?xml version="1.0" encoding="UTF-8"?> |
1 <?xml version="1.0" encoding="UTF-8"?> |
|
2 <!-- |
|
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
4 |
|
5 Copyright (c) 2006, 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 --> |
2 <project default="-deploy-ant" basedir="."> |
41 <project default="-deploy-ant" basedir="."> |
3 <target name="-init-cl-deployment-env" if="deploy.ant.enabled"> |
42 <target name="-init" if="deploy.ant.enabled"> |
4 <property file="${deploy.ant.properties.file}" /> |
43 <property file="${deploy.ant.properties.file}"/> |
5 <available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/> |
44 <tempfile property="temp.module.folder" prefix="tomcat" destdir="${java.io.tmpdir}"/> |
6 <available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/> |
45 <unwar src="${deploy.ant.archive}" dest="${temp.module.folder}"> |
7 <available file="${deploy.ant.resource.dir}" property="has.setup"/> |
46 <patternset includes="META-INF/context.xml"/> |
8 <tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! --> |
47 </unwar> |
9 <echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/> |
48 <xmlproperty file="${temp.module.folder}/META-INF/context.xml"/> |
|
49 <delete dir="${temp.module.folder}"/> |
10 </target> |
50 </target> |
11 |
51 <target name="-check-credentials" if="deploy.ant.enabled" depends="-init"> |
12 <target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present"> |
52 <fail message="Tomcat password has to be passed as tomcat.password property."> |
13 <tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/> |
53 <condition> |
14 <copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/> |
54 <not> |
15 <!-- The doctype triggers resolution which can fail --> |
55 <isset property="tomcat.password"/> |
16 <replace file="${temp.sun.web}"> |
56 </not> |
17 <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken> |
57 </condition> |
18 <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue> |
58 </fail> |
19 </replace> |
|
20 <replace file="${temp.sun.web}"> |
|
21 <replacetoken><![CDATA[<sun-web-app]]></replacetoken> |
|
22 <replacevalue><![CDATA[--> <sun-web-app]]></replacevalue> |
|
23 </replace> |
|
24 <xmlproperty file="${temp.sun.web}" validate="false"> |
|
25 </xmlproperty> |
|
26 <delete file="${temp.sun.web}"/> |
|
27 <condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}"> |
|
28 <isset property="sun-web-app.context-root"/> |
|
29 </condition> |
|
30 <condition property="deploy.context.root.argument" value="&contextroot=${sun-web-app.context-root}" else="/${ant.project.name}"> |
|
31 <isset property="sun-web-app.context-root"/> |
|
32 </condition> |
|
33 </target> |
59 </target> |
34 <target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present"> |
60 <target name="-deploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials"> |
35 <tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/> |
61 <echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/> |
36 <copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/> |
62 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" |
37 <!-- The doctype triggers resolution which can fail --> |
63 classpath="${tomcat.home}/server/lib/catalina-ant.jar"/> |
38 <replace file="${temp.gf.web}"> |
64 <deploy url="${tomcat.url}/manager" username="${tomcat.username}" |
39 <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken> |
65 password="${tomcat.password}" path="${Context(path)}" |
40 <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue> |
66 war="${deploy.ant.archive}"/> |
41 </replace> |
67 <property name="deploy.ant.client.url" value="${tomcat.url}${Context(path)}"/> |
42 <replace file="${temp.gf.web}"> |
|
43 <replacetoken><![CDATA[<glassfish-web-app]]></replacetoken> |
|
44 <replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue> |
|
45 </replace> |
|
46 <xmlproperty file="${temp.gf.web}" validate="false"> |
|
47 </xmlproperty> |
|
48 <delete file="${temp.gf.web}"/> |
|
49 <condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}"> |
|
50 <isset property="glassfish-web-app.context-root"/> |
|
51 </condition> |
|
52 <condition property="deploy.context.root.argument" value="&contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}"> |
|
53 <isset property="glassfish-web-app.context-root"/> |
|
54 </condition> |
|
55 </target> |
68 </target> |
56 <target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present"> |
69 <target name="-undeploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials"> |
57 <property name="deploy.context.root.argument" value=""/> |
70 <echo message="Undeploying ${Context(path)}"/> |
58 </target> |
71 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" |
59 <target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup"> |
72 classpath="${tomcat.home}/server/lib/catalina-ant.jar"/> |
60 <tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/> |
73 <undeploy url="${tomcat.url}/manager" username="${tomcat.username}" |
61 <mkdir dir="${gfv3.resources.dir}"/> |
74 password="${tomcat.password}" path="${Context(path)}"/> |
62 <mkdir dir="${gfv3.resources.dir}/META-INF"/> |
|
63 <copy todir="${gfv3.resources.dir}/META-INF"> |
|
64 <fileset dir="${deploy.ant.resource.dir}"/> |
|
65 </copy> |
|
66 <jar destfile="${deploy.ant.archive}" update="true"> |
|
67 <fileset dir="${gfv3.resources.dir}"/> |
|
68 </jar> |
|
69 <delete dir="${gfv3.resources.dir}"/> |
|
70 </target> |
|
71 <target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled"> |
|
72 <antcall target="-deploy-without-pw"/> |
|
73 <antcall target="-deploy-with-pw"/> |
|
74 </target> |
|
75 |
|
76 <target name="-deploy-without-pw" unless="gfv3.password"> |
|
77 <echo message="Deploying ${deploy.ant.archive}"/> |
|
78 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! --> |
|
79 <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/> |
|
80 <get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&force=true&name=${ant.project.name}" |
|
81 dest="${gfv3.results.file}"/> |
|
82 <delete file="${gfv3.results.file}"/> |
|
83 </target> |
|
84 <target name="-deploy-with-pw" if="gfv3.password"> |
|
85 <echo message="Deploying ${deploy.ant.archive}"/> |
|
86 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! --> |
|
87 <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/> |
|
88 <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}" |
|
89 dest="${gfv3.results.file}"/> |
|
90 <delete file="${gfv3.results.file}"/> |
|
91 </target> |
|
92 <target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled"> |
|
93 <antcall target="-undeploy-without-pw"/> |
|
94 <antcall target="-undeploy-with-pw"/> |
|
95 </target> |
|
96 |
|
97 <target name="-undeploy-without-pw" unless="gfv3.password"> |
|
98 <echo message="Undeploying ${deploy.ant.archive}"/> |
|
99 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! --> |
|
100 <get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}" |
|
101 dest="${gfv3.results.file}"/> |
|
102 <delete file="${gfv3.results.file}"/> |
|
103 </target> |
|
104 <target name="-undeploy-with-pw" if="gfv3.password"> |
|
105 <echo message="Undeploying ${deploy.ant.archive}"/> |
|
106 <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! --> |
|
107 <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}" |
|
108 dest="${gfv3.results.file}"/> |
|
109 <delete file="${gfv3.results.file}"/> |
|
110 </target> |
75 </target> |
111 </project> |
76 </project> |