java/nekurak.net-ear/nbproject/ant-deploy.xml
author František Kučera <franta-hg@frantovo.cz>
Tue Apr 23 21:43:37 2013 +0200 (2013-04-23)
changeset 204 bebec432330a
parent 142 44ef544460ca
permissions -rw-r--r--
oprava chatu, tabulátory
franta-hg@27
     1
<?xml version="1.0" encoding="UTF-8"?>
franta-hg@27
     2
<project default="-deploy-ant" basedir=".">
franta-hg@27
     3
    <target name="-init-cl-deployment-env" if="deploy.ant.enabled">
franta-hg@27
     4
        <property file="${deploy.ant.properties.file}" />
franta-hg@27
     5
        <available file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" property="sun.web.present"/>
franta-hg@186
     6
        <available file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" property="glassfish.web.present"/>
franta-hg@27
     7
        <available file="${deploy.ant.resource.dir}" property="has.setup"/>
franta-hg@27
     8
        <tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
franta-hg@27
     9
        <echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
franta-hg@27
    10
    </target>
franta-hg@27
    11
    
franta-hg@27
    12
    <target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
franta-hg@27
    13
        <tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
franta-hg@27
    14
        <copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
franta-hg@27
    15
        <!-- The doctype triggers resolution which can fail -->
franta-hg@27
    16
        <replace file="${temp.sun.web}">
franta-hg@27
    17
            <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
franta-hg@27
    18
            <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
franta-hg@27
    19
        </replace>
franta-hg@27
    20
        <replace file="${temp.sun.web}">
franta-hg@27
    21
            <replacetoken><![CDATA[<sun-web-app]]></replacetoken>
franta-hg@27
    22
            <replacevalue><![CDATA[--> <sun-web-app]]></replacevalue>
franta-hg@27
    23
        </replace>
franta-hg@27
    24
        <xmlproperty file="${temp.sun.web}" validate="false">
franta-hg@27
    25
        </xmlproperty>    
franta-hg@27
    26
        <delete file="${temp.sun.web}"/>
franta-hg@186
    27
        <condition property="deploy.ant.client.url" value="${gfv3.url}${sun-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
franta-hg@186
    28
            <isset property="sun-web-app.context-root"/>
franta-hg@186
    29
        </condition>
franta-hg@186
    30
        <condition property="deploy.context.root.argument" value="&amp;contextroot=${sun-web-app.context-root}" else="/${ant.project.name}">
franta-hg@186
    31
            <isset property="sun-web-app.context-root"/>
franta-hg@186
    32
        </condition>
franta-hg@186
    33
    </target>
franta-hg@186
    34
    <target name="-parse-glassfish-web" depends="-init-cl-deployment-env" if="glassfish.web.present">
franta-hg@186
    35
        <tempfile prefix="gfv3" property="temp.gf.web" destdir="${java.io.tmpdir}"/>
franta-hg@186
    36
        <copy file="${deploy.ant.docbase.dir}/WEB-INF/glassfish-web.xml" tofile="${temp.gf.web}"/>
franta-hg@186
    37
        <!-- The doctype triggers resolution which can fail -->
franta-hg@186
    38
        <replace file="${temp.gf.web}">
franta-hg@186
    39
            <replacetoken><![CDATA[<!DOCTYPE]]></replacetoken>
franta-hg@186
    40
            <replacevalue><![CDATA[<!-- <!DOCTYPE]]></replacevalue>
franta-hg@186
    41
        </replace>
franta-hg@186
    42
        <replace file="${temp.gf.web}">
franta-hg@186
    43
            <replacetoken><![CDATA[<glassfish-web-app]]></replacetoken>
franta-hg@186
    44
            <replacevalue><![CDATA[--> <glassfish-web-app]]></replacevalue>
franta-hg@186
    45
        </replace>
franta-hg@186
    46
        <xmlproperty file="${temp.gf.web}" validate="false">
franta-hg@186
    47
        </xmlproperty>
franta-hg@186
    48
        <delete file="${temp.gf.web}"/>
franta-hg@186
    49
        <condition property="deploy.ant.client.url" value="${gfv3.url}${glassfish-web-app.context-root}" else="${gfv3.url}/${ant.project.name}">
franta-hg@186
    50
            <isset property="glassfish-web-app.context-root"/>
franta-hg@186
    51
        </condition>
franta-hg@186
    52
        <condition property="deploy.context.root.argument" value="&amp;contextroot=${glassfish-web-app.context-root}" else="/${ant.project.name}">
franta-hg@186
    53
            <isset property="glassfish-web-app.context-root"/>
franta-hg@186
    54
        </condition>
franta-hg@27
    55
    </target>
franta-hg@27
    56
    <target name="-no-parse-sun-web" depends="-init-cl-deployment-env" unless="sun.web.present">
franta-hg@27
    57
        <property name="deploy.context.root.argument" value=""/>
franta-hg@27
    58
    </target>
franta-hg@27
    59
    <target name="-add-resources" depends="-init-cl-deployment-env" if="has.setup">
franta-hg@27
    60
        <tempfile prefix="gfv3" property="gfv3.resources.dir" destdir="${java.io.tmpdir}"/>
franta-hg@27
    61
        <mkdir dir="${gfv3.resources.dir}"/>
franta-hg@27
    62
        <mkdir dir="${gfv3.resources.dir}/META-INF"/>
franta-hg@27
    63
        <copy todir="${gfv3.resources.dir}/META-INF">
franta-hg@27
    64
            <fileset dir="${deploy.ant.resource.dir}"/>
franta-hg@27
    65
        </copy>
franta-hg@27
    66
        <jar destfile="${deploy.ant.archive}" update="true">
franta-hg@27
    67
            <fileset dir="${gfv3.resources.dir}"/>
franta-hg@27
    68
        </jar>
franta-hg@27
    69
        <delete dir="${gfv3.resources.dir}"/>
franta-hg@27
    70
    </target>
franta-hg@186
    71
    <target name="-deploy-ant" depends="-parse-glassfish-web, -parse-sun-web, -no-parse-sun-web,-add-resources" if="deploy.ant.enabled">
franta-hg@142
    72
        <antcall target="-deploy-without-pw"/>
franta-hg@142
    73
        <antcall target="-deploy-with-pw"/>
franta-hg@142
    74
    </target>
franta-hg@142
    75
franta-hg@142
    76
    <target name="-deploy-without-pw" unless="gfv3.password">
franta-hg@27
    77
        <echo message="Deploying ${deploy.ant.archive}"/>
franta-hg@27
    78
        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
franta-hg@27
    79
        <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
franta-hg@142
    80
        <get src="${gfv3.admin.url}/__asadmin/deploy?path=${full.deploy.ant.archive}${deploy.context.root.argument}&amp;force=true&amp;name=${ant.project.name}"
franta-hg@27
    81
            dest="${gfv3.results.file}"/>
franta-hg@27
    82
        <delete file="${gfv3.results.file}"/>    
franta-hg@27
    83
    </target>
franta-hg@142
    84
    <target name="-deploy-with-pw" if="gfv3.password">
franta-hg@142
    85
        <echo message="Deploying ${deploy.ant.archive}"/>
franta-hg@142
    86
        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
franta-hg@142
    87
        <property name="full.deploy.ant.archive" location="${deploy.ant.archive}"/>
franta-hg@142
    88
        <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}"
franta-hg@142
    89
            dest="${gfv3.results.file}"/>
franta-hg@142
    90
        <delete file="${gfv3.results.file}"/>
franta-hg@142
    91
    </target>
franta-hg@27
    92
    <target name="-undeploy-ant" depends="-init-cl-deployment-env" if="deploy.ant.enabled">
franta-hg@142
    93
        <antcall target="-undeploy-without-pw"/>
franta-hg@142
    94
        <antcall target="-undeploy-with-pw"/>
franta-hg@142
    95
    </target>
franta-hg@142
    96
franta-hg@142
    97
    <target name="-undeploy-without-pw" unless="gfv3.password">
franta-hg@27
    98
        <echo message="Undeploying ${deploy.ant.archive}"/>
franta-hg@27
    99
        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
franta-hg@142
   100
        <get src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
franta-hg@27
   101
            dest="${gfv3.results.file}"/>
franta-hg@27
   102
        <delete file="${gfv3.results.file}"/>    
franta-hg@27
   103
    </target>
franta-hg@142
   104
    <target name="-undeploy-with-pw" if="gfv3.password">
franta-hg@142
   105
        <echo message="Undeploying ${deploy.ant.archive}"/>
franta-hg@142
   106
        <tempfile prefix="gfv3" property="gfv3.results.file" destdir="${java.io.tmpdir}"/>  <!-- do not forget to delete this! -->
franta-hg@142
   107
        <get username="${gfv3.username}" password="${gfv3.password}" src="${gfv3.admin.url}/__asadmin/undeploy?name=${ant.project.name}"
franta-hg@142
   108
            dest="${gfv3.results.file}"/>
franta-hg@142
   109
        <delete file="${gfv3.results.file}"/>
franta-hg@142
   110
    </target>
franta-hg@27
   111
</project>