nbproject/ant-deploy.xml

changeset 3
acf54d3fa1d1
parent 0
ad22b29e3a40
     1.1 --- a/nbproject/ant-deploy.xml	Thu Apr 06 17:44:17 2017 +0200
     1.2 +++ b/nbproject/ant-deploy.xml	Sun Oct 29 13:35:43 2017 +0100
     1.3 @@ -1,111 +1,76 @@
     1.4  <?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!--
     1.6 +DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     1.7 +
     1.8 +Copyright (c) 2006, 2016 Oracle and/or its affiliates. All rights reserved.
     1.9 +
    1.10 +Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    1.11 +Other names may be trademarks of their respective owners.
    1.12 +
    1.13 +The contents of this file are subject to the terms of either the GNU
    1.14 +General Public License Version 2 only ("GPL") or the Common
    1.15 +Development and Distribution License("CDDL") (collectively, the
    1.16 +"License"). You may not use this file except in compliance with the
    1.17 +License. You can obtain a copy of the License at
    1.18 +http://www.netbeans.org/cddl-gplv2.html
    1.19 +or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    1.20 +specific language governing permissions and limitations under the
    1.21 +License.  When distributing the software, include this License Header
    1.22 +Notice in each file and include the License file at
    1.23 +nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    1.24 +particular file as subject to the "Classpath" exception as provided
    1.25 +by Oracle in the GPL Version 2 section of the License file that
    1.26 +accompanied this code. If applicable, add the following below the
    1.27 +License Header, with the fields enclosed by brackets [] replaced by
    1.28 +your own identifying information:
    1.29 +"Portions Copyrighted [year] [name of copyright owner]"
    1.30 +
    1.31 +If you wish your version of this file to be governed by only the CDDL
    1.32 +or only the GPL Version 2, indicate your decision by adding
    1.33 +"[Contributor] elects to include this software in this distribution
    1.34 +under the [CDDL or GPL Version 2] license." If you do not indicate a
    1.35 +single choice of license, a recipient has the option to distribute
    1.36 +your version of this file under either the CDDL, the GPL Version 2 or
    1.37 +to extend the choice of license to its licensees as provided above.
    1.38 +However, if you add GPL Version 2 code and therefore, elected the GPL
    1.39 +Version 2 license, then the option applies only if the new code is
    1.40 +made subject to such option by the copyright holder.
    1.41 +
    1.42 +Contributor(s):
    1.43 +-->
    1.44  <project default="-deploy-ant" basedir=".">
    1.45 -    <target name="-init-cl-deployment-env" if="deploy.ant.enabled">
    1.46 -        <property file="${deploy.ant.properties.file}" />
    1.47 -        <available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>
    1.48 -        <available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/>
    1.49 -        <available file="${deploy.ant.resource.dir}" property="has.setup"/>
    1.50 -        <tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
    1.51 -        <echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
    1.52 +    <target name="-init" if="deploy.ant.enabled">
    1.53 +        <property file="${deploy.ant.properties.file}"/>
    1.54 +        <tempfile property="temp.module.folder" prefix="tomcat" destdir="${java.io.tmpdir}"/>
    1.55 +        <unwar src="${deploy.ant.archive}" dest="${temp.module.folder}">
    1.56 +            <patternset includes="META-INF/context.xml"/>
    1.57 +        </unwar>
    1.58 +        <xmlproperty file="${temp.module.folder}/META-INF/context.xml"/>
    1.59 +        <delete dir="${temp.module.folder}"/>
    1.60      </target>
    1.61 -    
    1.62 -    <target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
    1.63 -        <tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
    1.64 -        <copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
    1.65 -        <!-- The doctype triggers resolution which can fail -->
    1.66 -        <replace file="${temp.sun.web}">
    1.67 -            <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
    1.68 -            <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
    1.69 -        </replace>
    1.70 -        <replace file="${temp.sun.web}">
    1.71 -            <replacetoken><![CDATA[<sun-web-app]]></replacetoken>
    1.72 -            <replacevalue><![CDATA[--> <sun-web-app]]></replacevalue>
    1.73 -        </replace>
    1.74 -        <xmlproperty file="${temp.sun.web}" validate="false">
    1.75 -        </xmlproperty>    
    1.76 -        <delete file="${temp.sun.web}"/>
    1.77 -        <condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
    1.78 -            <isset property="sun-web-app.context-root"/>
    1.79 -        </condition>
    1.80 -        <condition property="deploy.context.root.argument" value="&amp;contextroot=${sun-web-app.context-root}" else="/${ant.project.name}">
    1.81 -            <isset property="sun-web-app.context-root"/>
    1.82 -        </condition>
    1.83 +    <target name="-check-credentials" if="deploy.ant.enabled" depends="-init">
    1.84 +        <fail message="Tomcat password has to be passed as tomcat.password property.">
    1.85 +            <condition>
    1.86 +                <not>
    1.87 +                    <isset property="tomcat.password"/>
    1.88 +                </not>
    1.89 +            </condition>
    1.90 +        </fail>
    1.91      </target>
    1.92 -    <target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present">
    1.93 -        <tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/>
    1.94 -        <copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/>
    1.95 -        <!-- The doctype triggers resolution which can fail -->
    1.96 -        <replace file="${temp.gf.web}">
    1.97 -            <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
    1.98 -            <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
    1.99 -        </replace>
   1.100 -        <replace file="${temp.gf.web}">
   1.101 -            <replacetoken><![CDATA[<glassfish-web-app]]></replacetoken>
   1.102 -            <replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue>
   1.103 -        </replace>
   1.104 -        <xmlproperty file="${temp.gf.web}" validate="false">
   1.105 -        </xmlproperty>
   1.106 -        <delete file="${temp.gf.web}"/>
   1.107 -        <condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
   1.108 -            <isset property="glassfish-web-app.context-root"/>
   1.109 -        </condition>
   1.110 -        <condition property="deploy.context.root.argument" value="&amp;contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}">
   1.111 -            <isset property="glassfish-web-app.context-root"/>
   1.112 -        </condition>
   1.113 +    <target name="-deploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
   1.114 +        <echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/>
   1.115 +        <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
   1.116 +                 classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
   1.117 +        <deploy url="${tomcat.url}/manager" username="${tomcat.username}"
   1.118 +                password="${tomcat.password}" path="${Context(path)}"
   1.119 +                war="${deploy.ant.archive}"/>
   1.120 +        <property name="deploy.ant.client.url" value="${tomcat.url}${Context(path)}"/>
   1.121      </target>
   1.122 -    <target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present">
   1.123 -        <property name="deploy.context.root.argument" value=""/>
   1.124 -    </target>
   1.125 -    <target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup">
   1.126 -        <tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/>
   1.127 -        <mkdir dir="${gfv3.resources.dir}"/>
   1.128 -        <mkdir dir="${gfv3.resources.dir}/META-INF"/>
   1.129 -        <copy todir="${gfv3.resources.dir}/META-INF">
   1.130 -            <fileset dir="${deploy.ant.resource.dir}"/>
   1.131 -        </copy>
   1.132 -        <jar destfile="${deploy.ant.archive}" update="true">
   1.133 -            <fileset dir="${gfv3.resources.dir}"/>
   1.134 -        </jar>
   1.135 -        <delete dir="${gfv3.resources.dir}"/>
   1.136 -    </target>
   1.137 -    <target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled">
   1.138 -        <antcall target="-deploy-without-pw"/>
   1.139 -        <antcall target="-deploy-with-pw"/>
   1.140 -    </target>
   1.141 -
   1.142 -    <target name="-deploy-without-pw" unless="gfv3.password">
   1.143 -        <echo message="Deploying ${deploy.ant.archive}"/>
   1.144 -        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
   1.145 -        <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
   1.146 -        <get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
   1.147 -            dest="${gfv3.results.file}"/>
   1.148 -        <delete file="${gfv3.results.file}"/>    
   1.149 -    </target>
   1.150 -    <target name="-deploy-with-pw" if="gfv3.password">
   1.151 -        <echo message="Deploying ${deploy.ant.archive}"/>
   1.152 -        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
   1.153 -        <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
   1.154 -        <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
   1.155 -            dest="${gfv3.results.file}"/>
   1.156 -        <delete file="${gfv3.results.file}"/>
   1.157 -    </target>
   1.158 -    <target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled">
   1.159 -        <antcall target="-undeploy-without-pw"/>
   1.160 -        <antcall target="-undeploy-with-pw"/>
   1.161 -    </target>
   1.162 -
   1.163 -    <target name="-undeploy-without-pw" unless="gfv3.password">
   1.164 -        <echo message="Undeploying ${deploy.ant.archive}"/>
   1.165 -        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
   1.166 -        <get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
   1.167 -            dest="${gfv3.results.file}"/>
   1.168 -        <delete file="${gfv3.results.file}"/>    
   1.169 -    </target>
   1.170 -    <target name="-undeploy-with-pw" if="gfv3.password">
   1.171 -        <echo message="Undeploying ${deploy.ant.archive}"/>
   1.172 -        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
   1.173 -        <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
   1.174 -            dest="${gfv3.results.file}"/>
   1.175 -        <delete file="${gfv3.results.file}"/>
   1.176 +    <target name="-undeploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
   1.177 +        <echo message="Undeploying ${Context(path)}"/>
   1.178 +        <taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask"
   1.179 +                classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
   1.180 +        <undeploy url="${tomcat.url}/manager" username="${tomcat.username}" 
   1.181 +                  password="${tomcat.password}" path="${Context(path)}"/>
   1.182      </target>
   1.183  </project>

mercurial