summaryrefslogtreecommitdiffstats
path: root/branches/das-java-M2/samples/testing/tomcat/build.xml
blob: af159f940a152c8499d18d6223066da2cbd8d830 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?xml version="1.0" encoding="UTF-8" ?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
 -->
<project name="setup tomcat" default="prepareTomcat" basedir='.'>
        <property environment="env" />
        <property file="${user.home}/tuscany/build.properties" />
        <property file="${user.home}/build.properties" />

        <property name="tuscany.acceptance.tomcat.version" value='5.5.17' />
        <condition property="tuscany.acceptance.tomcat.zipped" value='apache-tomcat-${tuscany.acceptance.tomcat.version}.zip'>
            <os family="windows"/>
        </condition>
        <condition property="tuscany.acceptance.tomcat.zipped" value='apache-tomcat-${tuscany.acceptance.tomcat.version}.tar.gz'>
            <or>
                <os family="unix"/>
                <os family="mac"/>
            </or>
        </condition>
        <condition property="ant.home" value="${env.ANT_HOME}">
            <os family="unix"/>
        </condition>

        <property name="tuscany.acceptance.target.dir" value='target' />
        <property name="tuscany.acceptance.tc.dir" value='${tuscany.acceptance.target.dir}/apache-tomcat-${tuscany.acceptance.tomcat.version}' />


<!-- KJW define property for the complete path of apache dir -->
        <property name="fullpath.tuscany.acceptance.tc.dir" value= '${basedir}/${tuscany.acceptance.tc.dir}' />


        <property name="tuscany.acceptance.groupId" value='org/apache/tuscany' />
        <property name="tuscany.acceptance.version" value='incubating-M1' />

        <property name="tuscany.commonj.acceptance.groupId" value='commonj' />
        <property name="tuscany.commonj.acceptance.version" value='incubating-M1' />

        <property name="tuscany.sdo.acceptance.groupId" value='org/apache/tuscany' />
        <property name="tuscany.sdo.acceptance.version" value='incubating-M1' />

<!--KJW  Define location of canned Derby database -->
        <property name="tuscany.acceptance.das.samples.companyweb.dir" value='../../companyweb' />

        <property name="tuscany.maven.repos.dir" value='${user.home}\.m2\repository' />
        <condition property="isWindows">
            <os family="windows"/>
        </condition>
        <condition property="isUnix">
            <os family="unix"/>
        </condition>
        <condition property="isMac">
            <os family="mac"/>
        </condition>

        <patternset id="tuscany.acceptance.common.dependencies">
	            <include name="**/stax/stax-api/1.0/stax-api-1.0.jar"/>
                <include name="**/woodstox/wstx-asl/2.9.3/wstx-asl-2.9.3.jar" />
        </patternset>

        <patternset id="tuscany.acceptance.emf.dependencies">
                <include name="**/org/eclipse/emf/common/2.2.0-RC4/common-2.2.0-RC4.jar" />
                <include name="**/org/eclipse/emf/ecore/2.2.0-RC4/ecore-2.2.0-RC4.jar" />
                <include name="**/org/eclipse/emf/ecore-change/2.2.0-RC4/ecore-change-2.2.0-RC4.jar" />
                <include name="**/org/eclipse/emf/ecore-xmi/2.2.0-RC4/ecore-xmi-2.2.0-RC4.jar" />
                <include name="**/org/eclipse/xsd/xsd/2.2.0-RC4/xsd-2.2.0-RC4.jar" />
        </patternset>

        <patternset id="tuscany.acceptance.tc.specsdoimpl">  <!--jars which need to go into tomcat common/lib  -->
                <include name="**/${tuscany.sca.acceptance.groupId}/sca-api/${tuscany.sca.acceptance.version}/sca-api-${tuscany.sca.acceptance.version}.jar" />
                <include name="**/${tuscany.commonj.acceptance.groupId}/sdo-api/${tuscany.commonj.acceptance.version}/sdo-api-${tuscany.commonj.acceptance.version}.jar" />
                <include name="**/${tuscany.acceptance.groupId}/tuscany-sdo-impl/${tuscany.acceptance.version}/tuscany-sdo-impl-${tuscany.acceptance.version}.jar" />
        </patternset>

        <target name="init">
                <available property='tomcat.is.available' file='${tuscany.acceptance.tc.dir}/server/lib/catalina.jar' type='file' />
                <available property='tuscany.acceptance.tomcat.zipped.available' file='${tuscany.acceptance.tomcat.zipped}' type='file' />
                <available property='tuscany.acceptance.tomcat.serverxmlorg.available' file='${tuscany.acceptance.tc.dir}/conf/server.xml.original' />
                <available property='tuscany.acceptance.tomcat.contextxmlorg.available' file='${tuscany.acceptance.tc.dir}/conf/context.xml.original' />
        </target>

        <target name="check.for.zip" depends="init" unless='tuscany.acceptance.tomcat.zipped.available'>
                <property name='tuscany.acceptance.tomcat.zipped.full' location="${tuscany.acceptance.tomcat.zipped}" />
                <echo level="error" message="${tuscany.acceptance.tomcat.zipped} file not found here:'${tuscany.acceptance.tomcat.zipped.full}'" />
                <echo level="error" message="Either place zip file there or change ${user.home}/build.properties in home dir to include 'tuscany.acceptance.tomcat.zipped' property to where zip is located. " />
                <fail />
        </target>


        <target name="tuscany.tomcat.unzipWindows" if="isWindows" depends='init,check.for.zip' description='Just unzip tomcat' unless='tomcat.is.available'>
                <unzip src="${tuscany.acceptance.tomcat.zipped}" dest="${tuscany.acceptance.target.dir}" />
        </target>
        <target name="tuscany.tomcat.unzipUnix" if="isUnix" depends='init,check.for.zip' description='Just unzip tomcat' unless='tomcat.is.available'>
            <mkdir dir="${tuscany.acceptance.target.dir}" />
            <gunzip src="${tuscany.acceptance.tomcat.zipped}" dest="${tuscany.acceptance.target.dir}/temp.tar"/>
            <!-- Exec tar because ant builtin tar does not preserve execute permissions. -->
            <exec executable="tar" dir="${tuscany.acceptance.target.dir}">
                <arg value="xf"/>
                <arg value="temp.tar"/>
            </exec>
			<delete file="${tuscany.acceptance.target.dir}/temp.tar"/>
        </target>
        <target name="tuscany.tomcat.unzipMac" if="isMac" depends='init,check.for.zip' description='Just unzip tomcat' unless='tomcat.is.available'>
                <antcall target="tuscany.tomcat.unzipUnix" /> <!-- just use unix for now -->
        </target>

        <target name="prepareTomcat" depends='tuscany.tomcat.unzipWindows,tuscany.tomcat.unzipUnix,tuscany.tomcat.unzipMac,tuscany.tomcat.fixup,tuscany.deploy.das.standalone' description='Unzip tomcat, fix it up, and deploy samples'>
                <dirname property='tuscany.acceptance.tc.dir.full' file="${tuscany.acceptance.tc.dir}/bin" />
                <echo level="info" message="Tomcat fixed up here:  ${tuscany.acceptance.tc.dir.full}" />
                
        </target>
        <target name="startTestServer" depends='prepareTomcat' description='start server prepared to run tests'>
                <waitfor maxwait="1" maxwaitunit="second" checkevery="200" timeoutproperty="tuscany.tomcat.notstarted" >
                        <http url="http://localhost:8080"/>
                </waitfor>
                <condition property="tuscany.tomcat.alreadystarted">
                    <not>
                     <istrue value="${tuscany.tomcat.notstarted}"/>
                    </not>
                </condition>
                <antcall target="startTomcat" />
        </target>

        <target name="tuscany.tomcat.fixup" depends='tuscany.tomcat.fixserverconfig' description='Fix up tomcat for tuscany.'>
                <mkdir dir="${tuscany.acceptance.target.dir}" />

                <copy todir="${tuscany.acceptance.tc.dir}/common/lib" flatten='true'>
                        <fileset dir="${tuscany.maven.repos.dir}">
                                <patternset refid="tuscany.acceptance.emf.dependencies" />
                        </fileset>
                        <fileset dir="${tuscany.maven.repos.dir}">
                                <patternset refid="tuscany.acceptance.tc.specsdoimpl" />
                        </fileset>
                        <fileset dir="${tuscany.maven.repos.dir}">
                                <patternset>  <!-- for Derby and DAS support -->
                                  <include name="**/${tuscany.acceptance.groupId}/das/tuscany-das-rdb/${tuscany.acceptance.version}/tuscany-das-rdb-${tuscany.acceptance.version}.jar" />
                                  <include name="**/org/apache/derby/derby/10.1.2.1/derby-10.1.2.1.jar" />
                                </patternset>
                        </fileset>
	                    <fileset dir="${tuscany.maven.repos.dir}">
        	                    <patternset refid="tuscany.acceptance.common.dependencies" />
    	                </fileset>
                </copy>
        </target>

        <!-- DAS standalone target -->
        <target name="tuscany.deploy.das.standalone" description='Deploy DAS stand alone sample to tomcat.'>
               <copy todir="${tuscany.acceptance.tc.dir}/webapps" flatten='true'>
                        <fileset dir="${tuscany.acceptance.das.samples.companyweb.dir}">
                                <include name="**/*.war" />
                        </fileset>
                        <chainedmapper>
                                <flattenmapper/>
                                <globmapper from="*-1.0-incubator-M2-SNAPSHOT.war" to="*.war"/>
                        </chainedmapper>
                </copy>

                <!-- Create directory for the derby database -->
                <property name="tuscany.acceptance.target.databases.dir" value='${tuscany.acceptance.tc.dir}/Databases' />
                <mkdir dir="${tuscany.acceptance.target.databases.dir}" />

                <!-- Copy over the Derby database -->
                <copy todir="${tuscany.acceptance.target.databases.dir}">
                        <fileset dir="${tuscany.acceptance.das.samples.companyweb.dir}">
                                <include name="**/dastest/**" />
                        </fileset>
                </copy>
        </target>


        <!-- provide a convenient -Djava.ext.dirs=  to run j2se samples -->
        <target name="j2se" description='create a java extensions directory to run J2SE tuscany applications.'>
                <property name="tuscany.acceptance.j2se.dir" value='${tuscany.acceptance.target.dir}/j2se' />
                <mkdir dir="${tuscany.acceptance.j2se.dir}" />
                <copy todir="${tuscany.acceptance.j2se.dir}" flatten='true'>
                        <fileset dir="${tuscany.maven.repos.dir}">
                                <patternset refid="tuscany.acceptance.common.dependencies" />
                        </fileset>
                        <fileset dir="${tuscany.maven.repos.dir}">
                                <patternset refid="tuscany.acceptance.emf.dependencies" />
                                <patternset refid="tuscany.acceptance.tc.specsdoimpl" />
                        </fileset>
                </copy>
        </target>

        <target name="backup.server.xml" depends="init" unless='tuscany.acceptance.tomcat.serverxmlorg.available'>
                <copy file='${tuscany.acceptance.tc.dir}/conf/server.xml' tofile='${tuscany.acceptance.tc.dir}/conf/server.xml.original' />
        </target>
        <target name="backup.context.xml" depends="init" unless='tuscany.acceptance.tomcat.contextxmlorg.available'>
                <copy file='${tuscany.acceptance.tc.dir}/conf/context.xml' tofile='${tuscany.acceptance.tc.dir}/conf/context.xml.original' />
        </target>
        <target name="tuscany.tomcat.fixserverconfig" depends='tuscany.tomcat.fixserverxml,tuscany.tomcat.fixcontextxml' description='Add listeners' />
        <target name="tuscany.tomcat.fixserverxml" depends='init,backup.server.xml'  unless='tuscany.acceptance.tomcat.serverxmlorg.available'>
                <property name="tuscany.acceptance.tomcat.serverxmlorg.available" value='true' />

<!-- KJW save results to server_temp.xml -->
                <!-- DO NOTHING AT THIS TIME                
                <xslt processor="trax"
                  in="${tuscany.acceptance.tc.dir}/conf/server.xml.original" 
                  style="server.xsl" 
                  out="${tuscany.acceptance.tc.dir}/conf/server_temp.xml">
                </xslt>
                -->

                
<!--KJW modify server.xml to include derby database resource -->
               <echo level="info" message="Running datasource.xsl" />
               <xslt processor="trax"
                  in="${tuscany.acceptance.tc.dir}/conf/server.xml.original" style="datasource.xsl" 
                  out="${tuscany.acceptance.tc.dir}/conf/server.xml">
                  <param name="database_location" expression="jdbc:derby:../Databases/dastest"/>
                </xslt>


        </target>
        <target name="tuscany.tomcat.fixcontextxml" depends='init,backup.context.xml'  unless='tuscany.acceptance.tomcat.contextxmlorg.available'>
                <property name="tuscany.acceptance.tomcat.contextxmlorg.available" value='true' />
                <!-- DO NOTHING AT THIS TIME                
                <xslt
                  in="${tuscany.acceptance.tc.dir}/conf/context.xml.original" style="context.xsl" 
                  out="${tuscany.acceptance.tc.dir}/conf/context.xml">

                 </xslt>
                 -->
        </target>
        
        <target name="startTomcatWindows" if="isWindows" unless='tuscany.tomcat.alreadystarted' >
                <exec spawn='true' vmlauncher="false" failonerror='false' dir="${tuscany.acceptance.tc.dir}\bin" executable="cmd.exe" >
                        <arg line="/C start &quot; Tomcat running ${tuscany.acceptance.tc.dir}&quot;  catalina run &amp;&amp;   exit" />
                </exec>
        </target>
        <target name="startTomcatUnix" if="isUnix" unless='tuscany.tomcat.alreadystarted'>
            <echo level="info" message="Starting Tomcat"/>
            <exec spawn='true' vmlauncher="false" failonerror='false' dir="${tuscany.acceptance.tc.dir}/bin" executable="xterm" >
                <arg line="-e ./catalina.sh run"/>
            </exec>
        </target>
        <target name="startTomcatMac" if="isMac" unless='tuscany.tomcat.alreadystarted' >
                <antcall target="startTomcatUnix" />
        </target>

        <target name="tuscany.tomcat.alreadystartedmsg" if="tuscany.tomcat.alreadystarted">
             <echo level="info" message="Tomcat has been already started! ${tuscany.tomcat.alreadystarted}" />
        </target>
        <target name="startTomcat" description="Start up tomcat." depends="tuscany.tomcat.alreadystartedmsg,startTomcatWindows,startTomcatUnix,startTomcatMac" unless='tuscany.tomcat.alreadystarted'>
                <sleep seconds="10"/> <!-- it's going to at least require this -->
                <waitfor maxwait="15" maxwaitunit="second" checkevery="200">
                        <http url="http://localhost:8080"/>
                </waitfor>
                
        </target>

        <target name="clean" description='Clean out all built artifacts'>
                <delete dir="${tuscany.acceptance.target.dir}" />
        </target>

        <target name='setup.TC.antscripts' depends='tuscany.tomcat.unzipWindows,tuscany.tomcat.unzipUnix,tuscany.tomcat.unzipMac'>
                <!-- Configure the custom Ant tasks for the Manager application -->
                <taskdef resource="org/apache/catalina/ant/catalina.tasks">
                        <classpath>
                                <fileset dir="${tuscany.acceptance.tc.dir}/server/lib">
                                        <include name="*.jar" />
                                </fileset>
                                <fileset dir="${tuscany.acceptance.tc.dir}/common/lib">
                                        <include name="*.jar" />
                                </fileset>
                                <fileset dir="${tuscany.acceptance.tc.dir}/bin">
                                        <include name="*.jar" />
                                </fileset>
                        </classpath>
                </taskdef>

        </target>

</project>