|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<project default="-deploy-ant" basedir="."> |
| 3 | + <target name="-init-cl-deployment-env" if="deploy.ant.enabled"> |
| 4 | + <property file="${deploy.ant.properties.file}" /> |
| 5 | + <available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/> |
| 6 | + <available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/> |
| 7 | + <available file="${deploy.ant.resource.dir}" property="has.setup"/> |
| 8 | + <tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! --> |
| 9 | + <echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/> |
| 10 | + </target> |
| 11 | + |
| 12 | + <target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present"> |
| 13 | + <tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/> |
| 14 | + <copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/> |
| 15 | + <!-- The doctype triggers resolution which can fail --> |
| 16 | + <replace file="${temp.sun.web}"> |
| 17 | + <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken> |
| 18 | + <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue> |
| 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> |
| 34 | + <target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present"> |
| 35 | + <tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/> |
| 36 | + <copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/> |
| 37 | + <!-- The doctype triggers resolution which can fail --> |
| 38 | + <replace file="${temp.gf.web}"> |
| 39 | + <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken> |
| 40 | + <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue> |
| 41 | + </replace> |
| 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> |
| 56 | + <target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present"> |
| 57 | + <property name="deploy.context.root.argument" value=""/> |
| 58 | + </target> |
| 59 | + <target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup"> |
| 60 | + <tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/> |
| 61 | + <mkdir dir="${gfv3.resources.dir}"/> |
| 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> |
| 111 | +</project> |
0 commit comments