1 <?xml version="1.0" encoding="UTF-8"?>
2 <project name="analytics" default="all" basedir=".">
3 <description>Builds, tests, and runs the project analytics.</description>
5 <import file="nbproject/build-impl.xml"/>
7 <condition property="nbroot.defined">
8 <available file="nbproject/private/private.properties"/>
10 <available file="../../nbbuild/build.xml" property="nbroot" value="../.."/>
11 <property name="nbroot" location="nball"/>
13 <target name="-nbroot-define" unless="nbroot.defined">
14 <mkdir dir="nbproject/private"/>
15 <echo file="nbproject/private/private.properties" append="true" message="nbroot=${nbroot}${line.separator}"/>
19 <property name="cvsmodules" value="openide/util nbbuild libs junit/external xtest core/javahelp/external performance logger/uihandlerlib"/>
20 <condition property="skip.checkout">
21 <equals arg1="" arg2="${cvsmodules}"/>
24 <target name="-post-test-run" if="have.tests" unless="ignore.test.failure" depends="init,compile-test,-pre-test-run,-do-test-run">
25 <fail if="tests.failed">Some tests failed; see details above.</fail>
28 <target name="checkout" depends="-nbroot-define,init" unless="skip.checkout" description="Check out all CVS modules which are needed to build the server">
29 <!-- The following mess is an attempt to guess the correct CVSROOT and branch from the current checkout. -->
30 <loadfile srcfile="CVS/Root" property="cvsroot" failonerror="false" quiet="true">
35 <property name="cvsroot" value=":pserver:anoncvs@cvs.netbeans.org:/cvs"/>
36 <loadfile srcfile="CVS/Tag" property="cvstag" failonerror="false" quiet="true">
38 <tokenfilter delimoutput="">
39 <containsregex pattern="^T(.+)" replace="\1"/>
43 <property name="cvstag" value=""/>
44 <!-- on my hudson date 2007.04.20.07.52.56 is not seen as valid date for the cvs task
45 <loadfile srcfile="CVS/Tag" property="cvsdate" failonerror="false">
47 <tokenfilter delimoutput="">
48 <containsregex pattern="^D(.+)" replace="\1"/>
53 <property name="cvsdate" value=""/>
54 <echo>Right now we'll do checkout of necessary modules from CVS</echo>
55 <echo>To suppress this you can invoke the Ant script with -Dskip.checkout=true</echo>
57 command="checkout -P -f" compressionlevel="6" cvsroot="${cvsroot}"
58 dest="${nbroot}" package="${cvsmodules}" tag="${cvstag}" date="${cvsdate}"
59 quiet="true" failonerror="true"
65 There exist several targets which are by default empty and which can be
66 used for execution of your tasks. These targets are usually executed
67 before and after some main targets. They are:
69 -pre-init: called before initialization of project properties
70 -post-init: called after initialization of project properties
71 -pre-compile: called before javac compilation
72 -post-compile: called after javac compilation
73 -pre-compile-single: called before javac compilation of single file
74 -post-compile-single: called after javac compilation of single file
75 -pre-compile-test: called before javac compilation of JUnit tests
76 -post-compile-test: called after javac compilation of JUnit tests
77 -pre-compile-test-single: called before javac compilation of single JUnit test
78 -post-compile-test-single: called after javac compilation of single JUunit test
79 -pre-dist: called before jar building
80 -post-dist: called after jar building
81 -post-clean: called after cleaning build products
82 -pre-run-deploy: called before deploying
83 -post-run-deploy: called after deploying
85 Example of pluging an obfuscator after the compilation could look like
87 <target name="post-compile">
89 <fileset dir="${build.classes.dir}"/>
93 For list of available properties check the imported
94 nbproject/build-impl.xml file.
97 Other way how to customize the build is by overriding existing main targets.
98 The target of interest are:
100 init-macrodef-javac: defines macro for javac compilation
101 init-macrodef-junit: defines macro for junit execution
102 init-macrodef-debug: defines macro for class debugging
103 do-dist: jar archive building
104 run: execution of project
105 javadoc-build: javadoc generation
107 Example of overriding the target for project execution could look like
109 <target name="run" depends="<PROJNAME>-impl.jar">
110 <exec dir="bin" executable="launcher.exe">
111 <arg file="${dist.jar}"/>
115 Notice that overridden target depends on jar target and not only on
116 compile target as regular run target does. Again, for list of available
117 properties which you can use check the target you are overriding in
118 nbproject/build-impl.xml file.
121 <target name="all" depends="deploy" description="Builds everything, starts the server, runs the tests">
122 <antcall target="test">
123 <param name="ignore.test.failure" value="true"/>
127 <target name="dist" depends="build-all"/>
128 <target name="build-all" depends="-tomcat-properties,checkout">
129 <!-- bootstrap builds necessary Ant tasks -->
130 <ant dir="${nbroot}/nbbuild" target="bootstrap" inheritall="false" inheritrefs="false"/>
131 <!-- make sure openide/util is built -->
132 <ant dir="${nbroot}/openide/util" inheritall="false" inheritrefs="false"/>
133 <!-- make sure testing libraries are present -->
134 <ant dir="${nbroot}/performance/insanelib" inheritall="false" inheritrefs="false"/>
135 <ant dir="${nbroot}/performance/insanelibmodule" inheritall="false" inheritrefs="false"/>
136 <ant dir="${nbroot}/xtest/nbjunit" inheritall="false" inheritrefs="false"/>
137 <!-- make sure we have all our 3rd party libraries -->
138 <ant dir="../external"/>
139 <!-- make sure our library is built -->
140 <subant inheritall="false" inheritrefs="false" target="jar">
141 <property name="nbroot" location="${nbroot}"/>
143 <include name="ExceptionUtils"/>
146 <subant inheritall="false" inheritrefs="false" target="jar">
147 <property name="nbroot" location="${nbroot}"/>
148 <dirset dir="${nbroot}/logger">
149 <include name="uihandlerlib"/>
152 <antcall target="analytics-impl.dist">
154 <subant inheritall="false" inheritrefs="false" target="default">
155 <property name="nbroot" location="${nbroot}"/>
157 <include name="issueaillarealm"/>
158 <include name="StrutsExceptions"/>
161 <copy todir="${tomcat.base}">
162 <fileset dir="../ExceptionUtils/tomcat_base">
163 <include name="**/*"/>
164 <exclude name='**/server.xml'/>
165 <exclude name='**/logging.properties'/>
168 <copy todir="${tomcat.base}" encoding="utf-8" filtering="true">
169 <fileset dir="../ExceptionUtils/tomcat_base">
170 <include name='**/server.xml'/>
171 <include name='**/logging.properties'/>
174 <filter token="PORT" value="${tomcat.port}"/>
175 <filter token="PERSISTENCE_UNIT" value="${persistence.unit}"/>
176 <filter token="LOGGING_LEVEL" value="${logging.level}"/>
177 <filter token="SETTINGS_DIR" value="${settings.dir}"/>
180 <copy todir="${tomcat.base}/common/lib">
181 <fileset dir="../external">
182 <include name="*.jar"/>
184 <fileset dir="../ExceptionUtils/dist">
185 <include name="*.jar"/>
188 <copy todir="${tomcat.base}/server/lib">
189 <fileset dir="../issueaillarealm/dist">
190 <include name="*.jar"/>
193 <mkdir dir="${tomcat.base}/logs/"/>
196 <target name="deploy" depends="-tomcat-properties,build-all,run"/>
197 <target name="debug" depends="deploy">
198 <antcall target="connect-debugger">
199 <param name="jpda.address" value="${tomcat.debug.port}"/>
200 <param name="jpda.host" value="localhost"/>
201 <param name="name" value="debug-analytics"/>
202 <param name="jpda.transport" value="dt_socket"/>
206 <target name="run" depends="-tomcat-properties,start-tomcat">
207 <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
208 classpath="${tomcat.home}/lib/catalina-ant.jar"/>
210 <deploy url="${tomcat.url}/manager" username="${tomcat.username}"
211 password="${tomcat.password}" path="/exceptions"
212 war="${basedir}/../StrutsExceptions/dist/exceptions.war" update="true"/>
214 <deploy url="${tomcat.url}/manager" username="${tomcat.username}"
215 password="${tomcat.password}" path="/analytics"
216 war="${basedir}/dist/analytics.war" update="true"/>
218 <antcall target="-define-analytics-dir" inheritall="true"/>
220 <antcall target="-test-server" inheritall="true"/>
221 <antcall target="-test-server-upload" inheritall="true"/>
224 <target name="-define-analytics-dir" if="analytics.dir">
225 <waitfor maxwait="10" maxwaitunit="second">
226 <available file="${tomcat.base}/conf/Catalina/localhost/analytics.xml"/>
228 <fail message="Analytics must be deployed: ${tomcat.base}/conf/Catalina/localhost/analytics.xml">
230 <not><available file="${tomcat.base}/conf/Catalina/localhost/analytics.xml"/></not>
235 <echo message="Using analytics dir: ${analytics.dir}"/>
236 <property name="define.analytics.dir.before" value=''/>
238 file="${tomcat.base}/conf/Catalina/localhost/analytics.xml"
239 token='</Context>'
240 value='<Environment name="analytics/dir" value="${analytics.dir}" type="java.lang.String" override="false"/>${line.separator}</Context>'
243 <echo message="Modified ${tomcat.base}/conf/Catalina/localhost/analytics.xml"/>
246 <target name="-copy-tomcat-base" unless="tomcat.base">
247 <mkdir dir="build/tomcat_base"/>
248 <mkdir dir="build/tomcat_base/logs"/>
249 <property name="tomcat.base" location="build/tomcat_base/"/>
252 <target name="-tomcat-properties" depends="init,-copy-tomcat-base" unless="tomcat.home">
253 <property name="tomcat.home" location="../external/apache-tomcat-5.5.23/server/"/>
254 <property name="tomcat.port" value="8888"/>
255 <property name="tomcat.debug.port" value="8889"/>
256 <property name="tomcat.debug.suspend" value="n"/>
257 <property name="tomcat.host" value="localhost"/>
258 <property name="tomcat.url" value="http://${tomcat.host}:${tomcat.port}"/>
259 <property name="tomcat.username" value="tomcat"/>
260 <property name="tomcat.password" value="tomcat"/>
261 <property name="persistence.unit" value="TestPU"/>
262 <property name="settings.dir" value="/space/exceptionsReporter"/>
263 <property name="logging.level" value="INFO"/>
266 <target name="-check-tomcat" depends="-tomcat-properties">
268 <format pattern="yyyyMMddHHmmssSSS" property="stamp"/>
271 <mkdir dir="${tomcat.base}/webapps/ROOT"/>
272 <echo file="${tomcat.base}/webapps/ROOT/stamp" message="${stamp}" append="false"/>
274 <loadresource property="serverstamp" failonerror="false" quiet="true">
275 <url url="${tomcat.url}/stamp"/>
277 <condition property="tomcat.running">
278 <equals arg1="${stamp}" arg2="${serverstamp}"/>
281 <fail message="Port ${tomcat.port} is already in use">
285 <istrue value="${tomcat.running}"/>
287 <socket server="${tomcat.host}" port="${tomcat.port}"/>
291 <mkdir dir="../ExceptionUtils/tomcat_base/logs"/>
294 <target name="start-tomcat" depends="-check-tomcat" unless="tomcat.running">
295 <echo message="Starting Tomcat..."/>
296 <property name="tomcat.root" location="${tomcat.home}/.."/>
297 <property name="tomcat.opts" value=""/>
299 <mkdir dir="${tomcat.base}/temp"/>
300 <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows 2003 Windows XP"
301 executable="${tomcat.root}/bin/catalina.bat" dir="${tomcat.root}/bin/"
307 <env key="java.awt.headless" value="true"/>
308 <env key="CATALINA_HOME" value="${tomcat.root}"/>
309 <env key="CATALINA_BASE" value="${tomcat.base}"/>
310 <env key="JAVA_HOME" value="${java.home}"/>
311 <env key="JAVA_OPTS" value="${tomcat.opts}"/>
312 <env key="JPDA_ADDRESS" value="${tomcat.debug.port}"/>
313 <env key="JPDA_SUSPEND" value="${tomcat.debug.suspend}"/>
315 <exec os="Linux SunOS Solaris Mac OS X"
316 executable="/bin/sh" dir="${tomcat.root}/bin/"
318 <!--<arg value="-x"/>-->
319 <arg value="${tomcat.root}/bin/catalina.sh"/>
323 <env key="DISPLAY" value=""/>
324 <env key="CATALINA_HOME" value="${tomcat.root}"/>
325 <env key="CATALINA_BASE" value="${tomcat.base}"/>
326 <env key="JAVA_HOME" value="${java.home}"/>
327 <env key="JAVA_OPTS" value="${tomcat.opts}"/>
328 <env key="JPDA_ADDRESS" value="${tomcat.debug.port}"/>
329 <env key="JPDA_SUSPEND" value="${tomcat.debug.suspend}"/>
331 <waitfor maxwait="30" maxwaitunit="second" checkevery="5" checkeveryunit="second">
332 <http url="${tomcat.url}"/>
335 <loadresource property="serverstamp1" failonerror="false" quiet="true">
336 <url url="${tomcat.url}/stamp"/>
339 <fail message="Tomcat is not started at ${tomcat.url}">
342 <equals arg1="${stamp}" arg2="${serverstamp1}"/>
348 <target name="stop-tomcat" depends="-check-tomcat" if="tomcat.running">
350 <echo message="Stopping Tomcat..."/>
352 <property name="tomcat.root" location="${tomcat.home}/.."/>
354 <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows 2003 Windows XP"
355 executable="${tomcat.root}/bin/catalina.bat" dir="${tomcat.root}/bin/"
359 <env key="CATALINA_HOME" value="${tomcat.root}"/>
360 <env key="CATALINA_BASE" value="${tomcat.base}"/>
361 <env key="JAVA_HOME" value="${java.home}"/>
363 <exec os="Linux SunOS Solaris Mac OS X"
364 executable="${tomcat.root}/bin/catalina.sh" dir="${tomcat.root}/bin/"
368 <env key="DISPLAY" value=""/>
369 <env key="CATALINA_HOME" value="${tomcat.root}"/>
370 <env key="CATALINA_BASE" value="${tomcat.base}"/>
371 <env key="JAVA_HOME" value="${java.home}"/>
373 <waitfor maxwait="30" maxwaitunit="second" checkevery="5">
375 <http url="${tomcat.url}"/>
381 <target name="-pre-run-deploy" depends="start-tomcat">
382 <!-- get the server if not available -->
383 <!-- place libraries into correct place -->
384 <!-- maybe: choose some random port -->
385 <fail message="We need tomcat to run! Specify its location using -Dtomcat.home, or just execute 'ant all' it should download it automatically.">
388 <available file="${tomcat.home}/lib/catalina-ant.jar"/>
393 <target name="-post-run-deploy">
394 <!-- configuration changes? -->
397 <target name="run-server" depends="run" if="url.file">
398 <fail unless="tomcat.url" message="tomcat.url property has to be filled now after starting tomcat"/>
399 <echo message="${tomcat.url}" file="${url.file}"/>
402 <target name="-test-server">
403 <tempfile destdir="build" deleteonexit="true" property="index.file"/>
404 <get src="${tomcat.url}/analytics/index.jsp" dest="${index.file}"/>
405 <loadfile srcfile="${index.file}" property="${index.content}"/>
406 <fail message="Valid page must be returned">
409 <contains string="${index.content}" substring="NetBeans Analytics Community"/>
410 <contains string="${index.content}" substring="uploaded logs on the server right now"/>
416 <target name="-test-server-upload" unless="skip.upload">
417 <tempfile deleteonexit="true" property="upload.file"/>
418 <get src="${tomcat.url}/analytics/upload.jsp" dest="${upload.file}"/>
419 <loadfile srcfile="${upload.file}" property="${upload.content}"/>
420 <fail message="upload.jsp file should be accessible">
423 <contains string="${upload.content}" substring="Upload of NetBeans Analytics Logs Finished"/>
429 <target description="Stops the server and clean build products." name="clean" depends="stop-tomcat,analytics-impl.clean"/>
431 <target name="javadoc-build"/>