summaryrefslogtreecommitdiff
path: root/ant/tomcat-common.xml
blob: a10727948ea0da24b8e6aa80afe5f6e845979fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<project name="tomcat-common">

    <property file="${user.home}/opt/tomcat/conf/build.properties"/>
    
    <property name="web.dir" value="web" />
    
    <property name="build.classes" value="WEB-INF/classes" />
    
    <property name="context.path"  value="/${ant.project.name}"/>
    <property name="manager.url"   value="http://localhost:8080/manager/text"/>
    
    <import file="build-common.xml" />
    
    <path id="catalina-ant-classpath">
        <fileset dir="${catalina.home}/bin" erroronmissingdir="false">
            <include name="*.jar"/>
        </fileset>
        
        <fileset dir="${catalina.home}/lib" erroronmissingdir="false">
            <!-- <include name="*.jar"/> -->
        </fileset>
    </path>

    <taskdef resource="org/apache/catalina/ant/catalina.tasks"
        classpathref="catalina-ant-classpath" onerror="report" />
       
    <target name="prepare" depends="build-common.prepare"
        description="Create the build directories">
        
        <copy todir="${build.dir}">
            <fileset dir="${web.dir}" />
        </copy>
        <copy todir="${build.dir}/WEB-INF/lib">
            <fileset dir="${lib.dir}" />
        </copy>
    </target>

    <target name="war" depends="build" description="Generate WAR">
        <war destfile="build/${ant.project.name}.war" webxml="${web.dir}/WEB-INF/web.xml">
            <fileset dir="${web.dir}" />
            <lib dir="${lib.dir}" />
            <classes dir="${build.dir}/${build.classes}" />
        </war>
    </target>

    <target name="install" depends="build"
        description="Install application to servlet container">

        <deploy
            url="${manager.url}"
            username="${manager.username}"
            password="${manager.password}"
            path="${context.path}"
            localWar="file://${basedir}/${build.dir}" />

    </target>

    <target name="prompt">
       <input message="Manager URL"
               defaultvalue="${deploy.manager.url}"
               addproperty="prompt.manager.url" />

       <input message="Context Path"
               defaultvalue="${deploy.context.path}"
               addproperty="prompt.context.path" />

       <input message="Username"
               defaultvalue="${deploy.manager.username}"
               addproperty="prompt.manager.username" />

       <input message="Password"
               defaultvalue="${deploy.manager.password}"
               addproperty="prompt.manager.password" />
    </target>

    <target name="deploy" depends="prompt,build"
        description="Install application to servlet container in production">

        <deploy
            url="${prompt.manager.url}"
            username="${prompt.manager.username}"
            password="${prompt.manager.password}"
            path="${prompt.context.path}"
            war="file://${basedir}/${build.dir}" />

    </target>

    <target name="undeploy" depends="prompt"
        description="Uninstall application to servlet container in production">

        <undeploy
            url="${prompt.manager.url}"
            username="${prompt.manager.username}"
            password="${prompt.manager.password}"
            path="${prompt.context.path}" />

    </target>

    <target name="redeploy" depends="prompt,undeploy,deploy" />

    <target name="list"
        description="List installed applications on servlet container">

        <list
            url="${manager.url}"
            username="${manager.username}"
            password="${manager.password}" />

    </target>

    <target name="reload" depends="build"
        description="Reload application on servlet container">

        <reload 
            url="${manager.url}"
            username="${manager.username}"
            password="${manager.password}"
            path="${context.path}"/>

    </target>

    <target name="uninstall"
        description="Remove application on servlet container">

        <undeploy 
            url="${manager.url}"
            username="${manager.username}"
            password="${manager.password}"
            path="${context.path}"/>

    </target>

    <target name="setup-tomcat" unless="catalina.home">
        <input message="Enter a tomcat password (stored in plaintext):"
            addproperty="manager.password" />
        <exec executable="${jesterpm.buildtools.root}/scripts/setup-tomcat.sh"
            inputstring="${manager.password}">
            <arg line="${manager.password}" />
        </exec>
    </target>

</project>