1<project name="CLDR Web Apps" default="all" basedir="."> 2 <target name="init"> 3 <!-- copied from cldr/tools/java's build.xml --> 4 <tstamp/> 5 6 <property name="src.dir" value="src"/> 7 8 <!-- libs.dir remains the same, for Ant compatibility. TODO: delete when we drop ant.--> 9 <property name="libs.dir" value="WebContent/WEB-INF/lib"/> 10 11 <property name="build.dir" value="build/classes"/> 12 <property name="jar.file" value="cldr-apps.jar"/> 13 <property name="jarSrc.file" value="cldr-apps-src.jar"/> 14 <property name="jarDocs.file" value="cldr-apps-docs.jar"/> 15 <property name="doc.dir" value="doc"/> 16 <property name="doc.params" value=""/> 17 <!-- Load local definitions from an optional build.properties file, if available. 18 build.properties is NOT checked into CVS. --> 19 <!-- Load environment variables --> 20 <!-- 21 <property environment="env"/> 22 --> 23 <property file="build.properties" /> 24 25 <!-- CLDR_TOOLS defaults to ../java, override if not correct. --> 26 <property name="CLDR_TOOLS" value="../java"/> 27 <property name="CLDR_DIR" value="../../common/.."/> 28 <property name="CLDR_JAR" value="${CLDR_TOOLS}/cldr.jar"/> 29 30 <path id="build.classpath"> 31 <pathelement path="${build.dir}"/> 32 </path> 33 34 <property name="ICU4J_JAR" value="${CLDR_TOOLS}/libs/icu4j.jar"/> 35 <property name="UTILITIES_JAR" value="${CLDR_TOOLS}/libs/utilities.jar"/> 36 <property name="GUAVA_JAR" value="${CLDR_TOOLS}/libs/guava.jar" /> 37 <property name="FAILUREACCESS_JAR" value="${CLDR_TOOLS}/libs/failureaccess.jar" /> 38 <property name="MYANMAR_TOOLS_JAR" value="${CLDR_TOOLS}/libs/myanmar-tools-1.1.1.jar" /> 39 40 <property name="env.JVM_OPTIONS" value="-DCLDR_DIR=${CLDR_DIR} -Dorg.unicode.cldr.unittest.web.dir=cldr_db_test -DDEBUG=true"/> 41 <property name="jvm_options" value="${env.JVM_OPTIONS}"/> 42 <property name="env.JVM_EXTRA_OPTIONS" value=""/> 43 <property name="jvm_extra_options" value="${env.JVM_EXTRA_OPTIONS}"/> 44 45 <!-- from webinit: --> 46 <property name="tomcat.home" value="${CATALINA_HOME}"/> 47 <condition property="is.tomcat.home.set" > 48 <isset property="CATALINA_HOME" /> 49 </condition> 50 <fail unless="is.tomcat.home.set" message="Please set the CATALINA_HOME property in build.properties to point at your Tomcat installation."/> 51 <property name="SERVLET_JAR" value="${CATALINA_HOME}/lib/servlet-api.jar"/> 52 <property name="JSP_JAR" value="${CATALINA_HOME}/lib/jsp-api.jar"/> 53 54 <!-- Configure the context path for this application --> 55 <property name="path" value="/cldr-apps"/> 56 <property name="hostport" value="http://localhost:8080"/> 57 <!-- Configure properties to access the Manager application --> 58 <property name="managerpath" value="/manager/text" /> 59 <property name="url" value="${hostport}${managerpath}"/> <!-- TODO: support multiple, overrides --> 60 <property name="appurl" value="${hostport}${path}"/> 61 <property name="username" value="admin"/> <!-- TODO: support overrides --> 62 <property name="webcheck.delay" value="15"/> <!-- delay time --> 63 <!-- call ant with: -Dpassword=adminpass to use the updating stuff --> 64 65 <property name="warfile" location="cldr-apps.war"/> 66 67 <property name="WebContent" location="src/main/webapp"/> 68 <property name="WEB-INF" location="${WebContent}/WEB-INF"/> 69 <property name="webxml" location="${WEB-INF}/web.xml"/> 70 71 <mkdir dir="${build.dir}"/> 72 73 <path id="project.class.path"> 74 <pathelement path="${java.class.path}/"/> 75 <pathelement path="${build.dir}"/> 76 <pathelement path="${CLDR_CLASSES}"/> 77 <fileset dir="${libs.dir}"> 78 <include name="**/*.jar"/> 79 </fileset> 80 <fileset erroronmissingdir="false" dir="${CLDR_TOOLS}/dist/for-build"> 81 <include name="cldr.jar"/> 82 <include name="cldr-apps.war"/> 83 </fileset> 84 <!-- <pathelement location="${CLDR_JAR}"/> --> 85 <pathelement path="${CLDR_TOOLS}/classes"/> 86 <pathelement location="${CATALINA_HOME}/lib/tomcat-dbcp.jar"/> 87 <pathelement location="${ICU4J_JAR}"/> 88 <pathelement location="${UTILITIES_JAR}"/> 89 <pathelement location="${GUAVA_JAR}"/> 90 <pathelement location="${FAILUREACCESS_JAR}"/> 91 <pathelement location="${XML_APIS_JAR}"/> 92 <pathelement location="${DERBY_LIB}"/> 93 <pathelement location="${JDOM_LIB}"/> 94 <pathelement location="${SERVLET_JAR}"/> 95 <pathelement location="${JSP_JAR}"/> 96 <pathelement location="${MAIL_LIB}"/> 97 <pathelement location="${ROME_LIB}"/> 98 <pathelement location="${MYANMAR_TOOLS_JAR}"/> 99 </path> 100 101 <!-- <property name="icu.home" value="${env.ICU4J_HOME}"/> --> 102 103 <!-- 104 Does not exist. Ignoring this. 105 <property name="wardata" value="${src.dir}/org/unicode/cldr/web/data"/> 106 --> 107 108 <path id="catalina-ant.classpath"> 109 <fileset dir="${tomcat.home}/lib"> 110 <include name="**/*.jar"/> 111 </fileset> 112 <fileset dir="${tomcat.home}/bin"> 113 <include name="**/*.jar"/> 114 </fileset> 115 </path> 116 117 <!-- Configure the custom Ant tasks for the Manager application --> 118 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"><classpath refid="catalina-ant.classpath" /></taskdef> 119 <taskdef name="list" classname="org.apache.catalina.ant.ListTask"><classpath refid="catalina-ant.classpath" /></taskdef> 120 <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"><classpath refid="catalina-ant.classpath" /></taskdef> 121 <taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask"><classpath refid="catalina-ant.classpath" /></taskdef> 122 <!-- <taskdef name="roles" classname="org.apache.catalina.ant.RolesTask"><classpath refid="catalina-ant.classpath" /></taskdef> --> 123 <taskdef name="start" classname="org.apache.catalina.ant.StartTask"><classpath refid="catalina-ant.classpath" /></taskdef> 124 <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"><classpath refid="catalina-ant.classpath" /></taskdef> 125 <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"><classpath refid="catalina-ant.classpath" /></taskdef> 126 127 <!-- 128 TODO: do the following for the other env variables above.. 129 <condition property="is.icu4j.classes.set" > 130 <isset property="env.ICU4J_CLASSES" /> 131 </condition > 132 <fail unless="is.icu4j.classes.set" message="Please set the ICU4J_CLASSES environment variable."/> 133 --> 134 135 <echo message="Java: ${java.version}. [For verbose list of properties, use the 'properties' target.]"/> 136 </target> 137 138 <target name="properties" description="dump out properties" depends="init"> 139 <echo message="java home: ${java.home}"/> 140 <echo message="java version: ${java.version} ant java version: ${ant.java.version}"/> 141 <echo message="java.class.path: ${java.class.path}/"/> 142 <echo message="project.class.path: ${project.class.path}"/> 143 <echo message="build.dir: ${build.dir}"/> 144 <echo message="${ant.version}"/> 145 <echo message="CATALINA_HOME ${CATALINA_HOME}"/> 146 <echo message="tomcat.home ${tomcat.home}"/> 147 <echo/> 148 <echo message="ICU properties:"/> 149 <echo message="env.ICU4J_CLASSES: ${env.ICU4J_CLASSES}"/> 150 <echo message="env.CLDR_CLASSES: ${env.CLDR_CLASSES}"/> 151 <echo message="env.ICU4J_JAR: ${env.ICU4J_JAR}"/> 152 <echo/> 153 <echo message="Properties from build.properties (see build-sample.properties)"/> 154 <echo message="CLDR_TOOLS: ${CLDR_TOOLS} ( usually just ../java )"/> 155 <echo message="JDOM_LIB: ${JDOM_LIB}"/> 156 <echo message="DERBY_LIB: ${DERBY_LIB}"/> 157 <echo message="DERBYTOOLS_LIB: ${DERBYTOOLS_LIB}"/> 158 <echo message="ROME_LIB: ${ROME_LIB}"/> 159 <echo message="MAIL_LIB: ${MAIL_LIB}"/> 160 <echo message="SERVLET_JAR: ${SERVLET_JAR}"/> 161 <echo message="JSP_JAR: ${JSP_JAR}"/> 162 <echo/> 163 <echo message="Derived properties"/> 164 <echo message="CLDR_JAR: ${CLDR_JAR}"/> 165 <echo message="CLDR_CLASSES: ${CLDR_CLASSES}"/> 166 <echo message="env.UTILITIES_JAR: ${env.UTILITIES_JAR}"/> 167 <echo message="env.XML_APIS_JAR: ${env.XML_APIS_JAR}"/> 168 <echo/> 169 <echo message="Servlet properties"/> 170 <echo message="appurl: ${appurl}"/> 171 <echo message="url: ${url}"/> 172 </target> 173 174 175 <target name="clean" depends="init" description="remove all build targets"> 176 <delete dir="${build.dir}"/> 177 <delete file="${jar.file}"/> 178 <delete file="${warfile}"/> 179 <delete file="${jarSrc.file}"/> 180 <delete file="${jarDocs.file}"/> 181 <delete dir="${doc.dir}"/> 182 </target> 183 184 <target name="jar" depends="web" description="build full 'cldr-apps.jar' jar file (Not normally used.)"> 185 <jar jarfile="${jar.file}" 186 compress="true" 187 includes="org/unicode/cldr/util/**/*,org/unicode/cldr/tool/**/*,org/unicode/cldr/test/**/*,org/unicode/cldr/posix/**/*,org/unicode/cldr/ooo/**/*,org/unicode/cldr/ant/**/*,org/unicode/cldr/icu/**/*" 188 basedir="${build.dir}"/> 189 <!-- does not include git hash. --> 190 </target> 191 <!-- Docs stuff --> 192 <!-- use excludefiles below when we move to ant 1.5 --> 193 <target name="docs-jar" depends="docs"> 194 <jar jarfile="${jarDocs.file}" 195 compress="true" 196 includes="**/*" 197 basedir="${doc.dir}"/> 198 </target> 199 <target name="docs" depends="init" description="build user javadoc"> 200 <tstamp> 201 <format property="current.year" pattern="yyyy"/> 202 </tstamp> 203 <echo message="doc params: ${doc.params}"/> 204 <mkdir dir="${doc.dir}"/> 205 <javadoc 206 packagenames="org.unicode.cldr.*" 207 sourcepath="${src.dir}/main/java" 208 destdir="${doc.dir}" 209 classpathref="project.class.path" 210 nodeprecatedlist="true" 211 windowtitle="CLDR | Java Tools" 212 doctitle="CLDR | Java Tools" 213 encoding="utf-8" 214 docencoding="utf-8" 215 additionalparam="${doc.params}" 216 link="http://docs.oracle.com/javase/7/docs/api" 217 bottom="<font size=-1><a target='_top' href='http://www.unicode.org/copyright.html'>Copyright &copy; 2004-${current.year} Unicode, Inc. All Rights Reserved.</a></font>" 218 source="1.8" /> 219 </target> 220 <!-- bottom="<font size=-1>Copyright (c) ${current.year} IBM Corporation and others.</font>" --> 221 222 <!-- SurveyTool (web) stuff follows ................. --> 223 224 <!-- build all web related things --> 225 <!-- 226 // includes="${src.dir}/**/*.java" 227 excludes="**/.svn/**/*" 228 --> 229 <target name="web" depends="all" description="alias for old 'web' target"/> 230 231 <target name="all" depends="init" description="build web classes"> 232 <javac 233 srcdir="${src.dir}/main/java" 234 includes="org/unicode/cldr/util/*.java,org/unicode/cldr/web/*.java,org/json/*.java" 235 destdir="${build.dir}" 236 classpathref="project.class.path" 237 source="1.8" 238 target="1.8" 239 debug="on" deprecation="off" 240 includeantruntime="false" 241 encoding="UTF-8"/> 242 </target> 243 244 <target name="init-githash" depends="init" description="calculate build.githash"> 245 <exec executable="git" outputproperty="build.githash" failifexecutionfails="false"> 246 <arg value="rev-parse" /> 247 <arg value="HEAD" /> 248 </exec> 249 <condition property="build.githash" value="(unknown)"> 250 <not> 251 <isset property="build.githash" /> 252 </not> 253 </condition> 254 </target> 255 256 <!-- build as a WAR file --> 257 <!-- TODO: include CLDR as a jar? Only include certain classes? --> 258 <target name="war" depends="web,init-githash" description="Build war"> 259 <war destfile="${warfile}" webxml="${webxml}"> 260 <!-- classes (for now, may want to take cldr utils as a jar later) --> 261 <classes dir="${build.dir}" /> 262 263 <!-- all other files in /root --> 264 <zipfileset dir="${WebContent}" excludes="**/.svn/**/*"/> 265 266 <!-- TODO: include OLD jars. These will be deleted when we drop ant. --> 267 <zipfileset dir="./WebContent" excludes="**/.svn/**/*"/> 268 269 <!-- certain jars that we want --> 270 <!-- I suppose these were here in case they were in a different location? --> 271 <lib file="${UTILITIES_JAR}"/> <!-- CLDR utilities --> 272 <lib file="${ICU4J_JAR}"/> <!-- CLDR jar --> 273 <lib file="${CLDR_JAR}"/> <!-- CLDR jar --> 274 <lib file="${GUAVA_JAR}" /> <!-- GUAVA jar --> 275 <lib file="${FAILUREACCESS_JAR}" /> <!-- FAILUREACCESS jar --> 276 <lib file="${MYANMAR_TOOLS_JAR}" /> <!-- MYANMAR_TOOLS_JAR jar --> 277 <!-- May want this later. --> 278 <!-- <pathelement path="${jsp.jar}"/> --> 279 <manifest> 280 <attribute name="Built-By" value="${user.name}" /> 281 <attribute name="CLDR-Apps-Git-Commit" value="${build.githash}" /> 282 </manifest> 283 </war> 284 </target> 285 286 <!-- deploy to the server --> 287 <target name="deploy" depends="init,war"> 288 <deploy url="${url}" username="${username}" password="${password}" 289 path="${path}" war="${warfile}"/> 290 </target> 291 292 <!-- reload on the server - doesn't require building --> 293 <target name="reload" description="Reload SurveyTool application" 294 depends="init"> 295 <reload url="${url}" username="${username}" password="${password}" 296 path="${path}"/> 297 </target> 298 299 <!-- un-deploy from the server --> 300 <target name="undeploy" description="Remove SurveyTool application" depends="init"> 301 <undeploy url="${url}" username="${username}" password="${password}" 302 path="${path}"/> 303 </target> 304 305 <!-- redeploy to the server. Builds first so we catch trouble early. 306 Note, this will fail if you haven't deployed the first time. --> 307 <target name="redeploy" description="Redeploy SurveyTool application" 308 depends="init,war,undeploy,deploy"> 309 </target> 310 311 <!-- must use this to initialize the derby DB. --> 312 <target name="create-derby-db" description="Create empty Derby DB" 313 depends="init"> 314 <java classname="org.apache.derby.tools.ij" inputstring="exit;"> 315 <sysproperty key="derby.system.home" value="${tomcat.home}"/> 316 <sysproperty key="ij.database" value="jdbc:derby:cldr/cldrdb;create=true"/> 317 <classpath> 318 <pathelement location="${DERBY_LIB}"/> 319 <pathelement location="${DERBYTOOLS_LIB}"/> 320 </classpath> 321 </java> 322 </target> 323 324 325 <target name="tests" depends="all" description="Rebuild just tests"> 326 <javac 327 srcdir="${src.dir}/test/java" 328 includes="org/unicode/cldr/unittest/web/*.java" 329 excludes="org/unicode/cldr/unittest/web/TestShim.java" 330 destdir="${build.dir}" 331 classpathref="project.class.path" 332 source="1.8" 333 target="1.8" 334 debug="on" deprecation="off" 335 includeantruntime="false" 336 encoding="UTF-8"/> 337 <mkdir dir="${build.dir}/org/unicode/cldr/unittest/web/data"/> 338 <copy todir="${build.dir}/org/unicode/cldr/unittest/web/data"> 339 <fileset dir="${src.dir}/test/resources/org/unicode/cldr/unittest/web/data" 340 excludes="**/CVS/**/*"/> 341 </copy> 342 343 </target> 344 345 <target name="check" description="Run the standard ICU4J test suite" depends="init"> 346 <antcall target="_runCheck"> 347 <param name="runcheck.arg" value="-n"/> 348 <param name="runcheck.jvmarg" value="${jvm_options} ${jvm_extra_options}"/> 349 </antcall> 350 </target> 351 352 <target name="_runCheck" depends="init,tests"> 353 <echo message="JVM argument: ${runcheck.jvmarg} -DCLDR_ENVIRONMENT=UNITTEST -Djava.awt.headless=true"/> 354 <echo message="Test argument: ${runcheck.arg}"/> 355 <java classname="org.unicode.cldr.unittest.web.TestAll" fork="yes" failonerror="true" classpathref="project.class.path"> 356 <arg line="${runcheck.arg}"/> 357 <jvmarg line="${runcheck.jvmarg} -DCLDR_ENVIRONMENT=UNITTEST -Djava.awt.headless=true"/> 358 </java> 359 </target> 360 361 <target name="webcheck" description="Test that the server is semi working" depends="init"> 362 <delete file="tmp.survey.html"/> 363 <get src="${appurl}/survey" dest="tmp.survey.html" verbose="false" httpusecaches="false" /> 364 <echo message="... waiting ${webcheck.delay}s for server to settle ..."/> 365 <sleep seconds="${webcheck.delay}" /> 366 <delete file="tmp.survey2.html"/> 367 <get src="${appurl}/survey" dest="tmp.survey2.html" verbose="false" httpusecaches="false" /> 368 <delete file="tmp.mt.xml"/> 369 <get src="${appurl}/survey/vxml/main/mt.xml" dest="tmp.mt.xml" verbose="false" httpusecaches="false" /> 370 <delete file="tmp.status.json"/> 371 <get src="${appurl}/SurveyAjax?what=status" dest="tmp.status.json" verbose="false" httpusecaches="false" /> 372 <loadfile property="st.status" srcfile="tmp.status.json" /> 373 <loadfile property="st.ok" srcfile="tmp.status.json"> 374 <filterchain> 375 <linecontainsregexp> 376 <regexp pattern="isSetup.:true" /> 377 </linecontainsregexp> 378 </filterchain> 379 </loadfile> 380 <fail unless="st.ok" message="${appurl} SurveyTool not running: ${st.status}"/> 381 <echo message="${appurl} SurveyTool OK: ${st.status}"/> 382 </target> 383 384</project> 385