logger/uihandlerserver/build.xml
author jsedek@netbeans.org
Thu, 08 Nov 2007 18:24:10 +0000
changeset 2681 5ec5bb8e8852
parent 2667 b74061950e68
child 2706 6246dd8792e3
permissions -rw-r--r--
skip.upload not to check upload while parsing logs
jtulach@1806
     1
<?xml version="1.0" encoding="UTF-8"?>
jtulach@2096
     2
<project name="analytics" default="all" basedir=".">
jtulach@1859
     3
    <description>Builds, tests, and runs the project analytics.</description>
jtulach@1829
     4
    
jtulach@1806
     5
    <import file="nbproject/build-impl.xml"/>
jtulach@2665
     6
    
jtulach@2666
     7
    <condition property="nbroot.defined">
jtulach@2667
     8
        <available file="nbproject/private/private.properties"/>
jtulach@2666
     9
    </condition>
jtulach@2665
    10
    <available file="../../nbbuild/build.xml" property="nbroot" value="../.."/>
jtulach@2665
    11
    <property name="nbroot" location="nball"/>
jtulach@2666
    12
    
jtulach@2666
    13
    <target name="-nbroot-define" unless="nbroot.defined">
jtulach@2666
    14
        <mkdir dir="nbproject/private"/>
jtulach@2667
    15
        <echo file="nbproject/private/private.properties" append="true" message="nbroot=${nbroot}${line.separator}"/>
jtulach@2666
    16
    </target>
jsedek@2681
    17
    
jsedek@2681
    18
    
jtulach@2665
    19
    <property name="cvsmodules" value="openide/util nbbuild libs junit/external xtest core/javahelp/external performance logger/uihandlerlib"/>
jtulach@2115
    20
    <condition property="skip.checkout">
jtulach@2115
    21
        <equals arg1="" arg2="${cvsmodules}"/>
jtulach@2115
    22
    </condition> 
jsedek@2681
    23
    
jtulach@2270
    24
    <target name="-post-test-run" if="have.tests" unless="ignore.test.failure" depends="init,compile-test,-pre-test-run,-do-test-run">
jtulach@2270
    25
        <fail if="tests.failed">Some tests failed; see details above.</fail>
jtulach@2270
    26
    </target>
jsedek@2681
    27
    
jsedek@2681
    28
    <target name="checkout" depends="-nbroot-define,init" unless="skip.checkout" description="Check out all CVS modules which are needed to build the server">
jsedek@2681
    29
        <!-- The following mess is an attempt to guess the correct CVSROOT and branch from the current checkout. -->
jsedek@2681
    30
        <loadfile srcfile="CVS/Root" property="cvsroot" failonerror="false" quiet="true">
jsedek@2681
    31
            <filterchain>
jsedek@2681
    32
                <striplinebreaks/>
jsedek@2681
    33
            </filterchain>
jsedek@2681
    34
        </loadfile>
jsedek@2681
    35
        <property name="cvsroot" value=":pserver:anoncvs@cvs.netbeans.org:/cvs"/>
jsedek@2681
    36
        <loadfile srcfile="CVS/Tag" property="cvstag" failonerror="false" quiet="true">
jsedek@2681
    37
            <filterchain> 
jsedek@2681
    38
                <tokenfilter delimoutput="">
jsedek@2681
    39
                    <containsregex pattern="^T(.+)" replace="\1"/>
jsedek@2681
    40
                </tokenfilter>
jsedek@2681
    41
            </filterchain>
jsedek@2681
    42
        </loadfile>
jsedek@2681
    43
        <property name="cvstag" value=""/>
jsedek@2681
    44
        <!-- on my hudson date 2007.04.20.07.52.56 is not seen as valid date for the cvs task
jtulach@2115
    45
      <loadfile srcfile="CVS/Tag" property="cvsdate" failonerror="false">
jtulach@2115
    46
          <filterchain> 
jtulach@2115
    47
              <tokenfilter delimoutput="">
jtulach@2115
    48
                  <containsregex pattern="^D(.+)" replace="\1"/>
jtulach@2115
    49
              </tokenfilter>
jtulach@2115
    50
          </filterchain>
jtulach@2115
    51
      </loadfile>
jtulach@2116
    52
      -->
jsedek@2681
    53
        <property name="cvsdate" value=""/>
jsedek@2681
    54
        <echo>Right now we'll do checkout of necessary modules from CVS</echo>
jsedek@2681
    55
        <echo>To suppress this you can invoke the Ant script with -Dskip.checkout=true</echo>
jsedek@2681
    56
        <cvs 
jsedek@2681
    57
            command="checkout -P -f" compressionlevel="6" cvsroot="${cvsroot}" 
jsedek@2681
    58
            dest="${nbroot}" package="${cvsmodules}" tag="${cvstag}" date="${cvsdate}" 
jsedek@2681
    59
            quiet="true" failonerror="true" 
jsedek@2681
    60
        />
jsedek@2681
    61
    </target>
jsedek@2681
    62
    
jtulach@1806
    63
    <!--
jtulach@1806
    64
jtulach@1806
    65
    There exist several targets which are by default empty and which can be 
jtulach@1806
    66
    used for execution of your tasks. These targets are usually executed 
jtulach@1806
    67
    before and after some main targets. They are: 
jtulach@1806
    68
jtulach@1806
    69
      -pre-init:                 called before initialization of project properties 
jtulach@1806
    70
      -post-init:                called after initialization of project properties 
jtulach@1806
    71
      -pre-compile:              called before javac compilation 
jtulach@1806
    72
      -post-compile:             called after javac compilation 
jtulach@1806
    73
      -pre-compile-single:       called before javac compilation of single file
jtulach@1806
    74
      -post-compile-single:      called after javac compilation of single file
jtulach@1806
    75
      -pre-compile-test:         called before javac compilation of JUnit tests
jtulach@1806
    76
      -post-compile-test:        called after javac compilation of JUnit tests
jtulach@1806
    77
      -pre-compile-test-single:  called before javac compilation of single JUnit test
jtulach@1806
    78
      -post-compile-test-single: called after javac compilation of single JUunit test
jtulach@1806
    79
      -pre-dist:                 called before jar building 
jtulach@1806
    80
      -post-dist:                called after jar building 
jtulach@1806
    81
      -post-clean:               called after cleaning build products 
jtulach@1806
    82
      -pre-run-deploy:           called before deploying
jtulach@1806
    83
      -post-run-deploy:          called after deploying
jtulach@1806
    84
jtulach@1806
    85
    Example of pluging an obfuscator after the compilation could look like 
jtulach@1806
    86
jtulach@1806
    87
        <target name="post-compile">
jtulach@1806
    88
            <obfuscate>
jtulach@1806
    89
                <fileset dir="${build.classes.dir}"/>
jtulach@1806
    90
            </obfuscate>
jtulach@1806
    91
        </target>
jtulach@1806
    92
jtulach@1806
    93
    For list of available properties check the imported 
jtulach@1806
    94
    nbproject/build-impl.xml file. 
jtulach@1806
    95
jtulach@1806
    96
jtulach@1806
    97
    Other way how to customize the build is by overriding existing main targets.
jtulach@1806
    98
    The target of interest are: 
jtulach@1806
    99
jtulach@1806
   100
      init-macrodef-javac:    defines macro for javac compilation
jtulach@1806
   101
      init-macrodef-junit:   defines macro for junit execution
jtulach@1806
   102
      init-macrodef-debug:    defines macro for class debugging
jtulach@1806
   103
      do-dist:                jar archive building
jtulach@1806
   104
      run:                    execution of project 
jtulach@1806
   105
      javadoc-build:          javadoc generation 
jtulach@1806
   106
jtulach@1806
   107
    Example of overriding the target for project execution could look like 
jtulach@1806
   108
jtulach@1806
   109
        <target name="run" depends="<PROJNAME>-impl.jar">
jtulach@1806
   110
            <exec dir="bin" executable="launcher.exe">
jtulach@1806
   111
                <arg file="${dist.jar}"/>
jtulach@1806
   112
            </exec>
jtulach@1806
   113
        </target>
jtulach@1806
   114
jtulach@1806
   115
    Notice that overridden target depends on jar target and not only on 
jtulach@1806
   116
    compile target as regular run target does. Again, for list of available 
jtulach@1806
   117
    properties which you can use check the target you are overriding in 
jtulach@1806
   118
    nbproject/build-impl.xml file. 
jtulach@1806
   119
jtulach@1806
   120
    -->
jtulach@2415
   121
    <target name="all" depends="deploy" description="Builds everything, starts the server, runs the tests">
jtulach@2415
   122
        <antcall target="test">
jtulach@2415
   123
            <param name="ignore.test.failure" value="true"/>
jtulach@2415
   124
        </antcall>
jtulach@2415
   125
    </target>
jhorvath@2249
   126
    
jtulach@2576
   127
    <target name="dist" depends="build-all"/>
jtulach@2576
   128
    <target name="build-all" depends="-tomcat-properties,checkout">
jhorvath@2249
   129
        <!-- bootstrap builds necessary Ant tasks -->
jtulach@2665
   130
        <ant dir="${nbroot}/nbbuild" target="bootstrap" inheritall="false" inheritrefs="false"/>
jhorvath@2249
   131
        <!-- make sure openide/util is built -->
jtulach@2665
   132
        <ant dir="${nbroot}/openide/util" inheritall="false" inheritrefs="false"/>
jhorvath@2249
   133
        <!-- make sure testing libraries are present -->
jtulach@2665
   134
        <ant dir="${nbroot}/performance/insanelib" inheritall="false" inheritrefs="false"/>
jtulach@2665
   135
        <ant dir="${nbroot}/performance/insanelibmodule" inheritall="false" inheritrefs="false"/>
jtulach@2665
   136
        <ant dir="${nbroot}/xtest/nbjunit" inheritall="false" inheritrefs="false"/>
jhorvath@2249
   137
        <!-- make sure we have all our 3rd party libraries -->
jhorvath@2249
   138
        <ant dir="../external"/>
jhorvath@2249
   139
        <!-- make sure our library is built -->
jhorvath@2249
   140
        <subant inheritall="false" inheritrefs="false" target="jar">
jtulach@2665
   141
            <property name="nbroot" location="${nbroot}"/>
jhorvath@2249
   142
            <dirset dir="..">
jtulach@2665
   143
                <include name="ExceptionUtils"/>
jtulach@2665
   144
            </dirset>
jtulach@2665
   145
        </subant>
jtulach@2665
   146
        <subant inheritall="false" inheritrefs="false" target="jar">
jtulach@2665
   147
            <property name="nbroot" location="${nbroot}"/>
jtulach@2665
   148
            <dirset dir="${nbroot}/logger">
jhorvath@2249
   149
                <include name="uihandlerlib"/>
jhorvath@2252
   150
            </dirset>
jhorvath@2252
   151
        </subant>
jtulach@2576
   152
        <antcall target="analytics-impl.dist">
jhorvath@2264
   153
        </antcall>
jhorvath@2262
   154
        <subant inheritall="false" inheritrefs="false" target="default">
jtulach@2665
   155
            <property name="nbroot" location="${nbroot}"/>
jhorvath@2252
   156
            <dirset dir="..">
jhorvath@2262
   157
                <include name="issueaillarealm"/>
jhorvath@2249
   158
                <include name="StrutsExceptions"/>
jhorvath@2249
   159
            </dirset>
jhorvath@2249
   160
        </subant>
jtulach@2352
   161
        <copy todir="${tomcat.base}">
jtulach@2352
   162
            <fileset dir="../ExceptionUtils/tomcat_base">
jtulach@2352
   163
                <include name="**/*"/>
jtulach@2414
   164
                <exclude name='**/server.xml'/>
jsedek@2638
   165
                <exclude name='**/logging.properties'/>
jtulach@2352
   166
            </fileset>
jtulach@2352
   167
        </copy>
jtulach@2414
   168
        <copy todir="${tomcat.base}" encoding="utf-8" filtering="true">
jtulach@2414
   169
            <fileset dir="../ExceptionUtils/tomcat_base">
jtulach@2414
   170
                <include name='**/server.xml'/>
jsedek@2638
   171
                <include name='**/logging.properties'/>
jtulach@2414
   172
            </fileset>
jtulach@2414
   173
            <filterset>
jtulach@2414
   174
                <filter token="PORT" value="${tomcat.port}"/>
jtulach@2415
   175
                <filter token="PERSISTENCE_UNIT" value="${persistence.unit}"/>
jsedek@2638
   176
                <filter token="LOGGING_LEVEL" value="${logging.level}"/>
jhorvath@2653
   177
                <filter token="SETTINGS_DIR" value="${settings.dir}"/>
jtulach@2414
   178
            </filterset>
jtulach@2414
   179
        </copy>
jtulach@2352
   180
        <copy todir="${tomcat.base}/common/lib">
jtulach@2352
   181
            <fileset dir="../external">
jtulach@2352
   182
                <include name="*.jar"/>
jtulach@2352
   183
            </fileset>
jtulach@2352
   184
            <fileset dir="../ExceptionUtils/dist">
jtulach@2352
   185
                <include name="*.jar"/>
jtulach@2352
   186
            </fileset>
jtulach@2352
   187
        </copy>
jtulach@2352
   188
        <copy todir="${tomcat.base}/server/lib">
jtulach@2352
   189
            <fileset dir="../issueaillarealm/dist">
jtulach@2352
   190
                <include name="*.jar"/>
jtulach@2352
   191
            </fileset>
jtulach@2352
   192
        </copy>
jtulach@2352
   193
        <mkdir dir="${tomcat.base}/logs/"/>
jhorvath@2249
   194
    </target>
jsedek@2681
   195
    
jtulach@2576
   196
    <target name="deploy" depends="-tomcat-properties,build-all,run"/>
jtulach@2576
   197
    <target name="debug" depends="deploy">
jtulach@2576
   198
        <antcall target="connect-debugger">
jtulach@2576
   199
            <param name="jpda.address" value="${tomcat.debug.port}"/>
jtulach@2576
   200
            <param name="jpda.host" value="localhost"/>
jtulach@2576
   201
            <param name="name" value="debug-analytics"/>
jtulach@2576
   202
            <param name="jpda.transport" value="dt_socket"/>
jtulach@2576
   203
        </antcall>
jtulach@2576
   204
    </target>
jtulach@2576
   205
    
jtulach@2576
   206
    <target name="run" depends="-tomcat-properties,start-tomcat">
jhorvath@2262
   207
        <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
jhorvath@2262
   208
                 classpath="${tomcat.home}/lib/catalina-ant.jar"/>
jsedek@2681
   209
        
jhorvath@2262
   210
        <deploy url="${tomcat.url}/manager" username="${tomcat.username}"
jhorvath@2262
   211
                password="${tomcat.password}" path="/exceptions"
jhorvath@2266
   212
                war="${basedir}/../StrutsExceptions/dist/exceptions.war" update="true"/>
jsedek@2681
   213
        
jhorvath@2264
   214
        <deploy url="${tomcat.url}/manager" username="${tomcat.username}"
jhorvath@2264
   215
                password="${tomcat.password}" path="/analytics"
jhorvath@2266
   216
                war="${basedir}/dist/analytics.war" update="true"/>
jsedek@2681
   217
        
jtulach@2275
   218
        <antcall target="-define-analytics-dir" inheritall="true"/>
jsedek@2681
   219
        
jsedek@2681
   220
        <antcall target="-test-server" inheritall="true"/>
jsedek@2681
   221
        <antcall target="-test-server-upload" inheritall="true"/>
jhorvath@2242
   222
    </target>
jtulach@2189
   223
    
jtulach@2275
   224
    <target name="-define-analytics-dir" if="analytics.dir">
jtulach@2275
   225
        <waitfor maxwait="10" maxwaitunit="second">
jtulach@2275
   226
            <available file="${tomcat.base}/conf/Catalina/localhost/analytics.xml"/>
jtulach@2275
   227
        </waitfor>
jtulach@2275
   228
        <fail message="Analytics must be deployed: ${tomcat.base}/conf/Catalina/localhost/analytics.xml">
jtulach@2275
   229
            <condition>
jtulach@2275
   230
                <not><available file="${tomcat.base}/conf/Catalina/localhost/analytics.xml"/></not>
jtulach@2275
   231
            </condition>
jtulach@2275
   232
        </fail>
jtulach@2275
   233
        
jtulach@2287
   234
        <sleep seconds="3"/>
jtulach@2275
   235
        <echo message="Using analytics dir: ${analytics.dir}"/>
jtulach@2275
   236
        <property name="define.analytics.dir.before" value=''/>
jtulach@2275
   237
        <replace 
jtulach@2275
   238
            file="${tomcat.base}/conf/Catalina/localhost/analytics.xml" 
jtulach@2275
   239
            token='&lt;/Context&gt;'
jtulach@2275
   240
            value='&lt;Environment name="analytics/dir" value="${analytics.dir}" type="java.lang.String" override="false"/&gt;${line.separator}&lt;/Context&gt;'
jtulach@2275
   241
            summary="true"
jtulach@2275
   242
        />
jtulach@2275
   243
        <echo message="Modified ${tomcat.base}/conf/Catalina/localhost/analytics.xml"/>
jtulach@2275
   244
    </target>
jtulach@2275
   245
    
jtulach@2348
   246
    <target name="-copy-tomcat-base" unless="tomcat.base">
jtulach@2348
   247
        <mkdir dir="build/tomcat_base"/>
jtulach@2576
   248
        <mkdir dir="build/tomcat_base/logs"/>
jtulach@2348
   249
        <property name="tomcat.base" location="build/tomcat_base/"/>
jtulach@2348
   250
    </target>
jtulach@2348
   251
    
jtulach@2576
   252
    <target name="-tomcat-properties" depends="init,-copy-tomcat-base" unless="tomcat.home">
jtulach@2204
   253
        <property name="tomcat.home" location="../external/apache-tomcat-5.5.23/server/"/>
jhorvath@2242
   254
        <property name="tomcat.port" value="8888"/>
jtulach@2576
   255
        <property name="tomcat.debug.port" value="8889"/>
jtulach@2576
   256
        <property name="tomcat.debug.suspend" value="n"/>
jhorvath@2242
   257
        <property name="tomcat.host" value="localhost"/>
jhorvath@2242
   258
        <property name="tomcat.url" value="http://${tomcat.host}:${tomcat.port}"/>
jtulach@2204
   259
        <property name="tomcat.username" value="tomcat"/>
jtulach@2204
   260
        <property name="tomcat.password" value="tomcat"/>
jtulach@2415
   261
        <property name="persistence.unit" value="TestPU"/>
jhorvath@2653
   262
        <property name="settings.dir" value="/space/exceptionsReporter"/>
jsedek@2638
   263
        <property name="logging.level" value="INFO"/>
jhorvath@2242
   264
    </target>
jhorvath@2242
   265
    
jtulach@2414
   266
    <target name="-check-tomcat" depends="-tomcat-properties">
jhorvath@2242
   267
        <tstamp> 
jhorvath@2242
   268
            <format pattern="yyyyMMddHHmmssSSS" property="stamp"/>
jhorvath@2242
   269
        </tstamp>
jtulach@2204
   270
        
jtulach@2414
   271
        <mkdir dir="${tomcat.base}/webapps/ROOT"/>
jhorvath@2242
   272
        <echo file="${tomcat.base}/webapps/ROOT/stamp" message="${stamp}" append="false"/>
jhorvath@2242
   273
        
jhorvath@2264
   274
        <loadresource property="serverstamp" failonerror="false" quiet="true">
jhorvath@2242
   275
            <url url="${tomcat.url}/stamp"/>
jhorvath@2242
   276
        </loadresource>
jhorvath@2242
   277
        <condition property="tomcat.running">
jhorvath@2242
   278
            <equals arg1="${stamp}" arg2="${serverstamp}"/>
jhorvath@2242
   279
        </condition>
jhorvath@2242
   280
        
jhorvath@2242
   281
        <fail message="Port ${tomcat.port} is already in use">
jhorvath@2242
   282
            <condition>
jhorvath@2242
   283
                <and>
jhorvath@2242
   284
                    <not>
jhorvath@2242
   285
                        <istrue value="${tomcat.running}"/>
jhorvath@2242
   286
                    </not>
jhorvath@2242
   287
                    <socket server="${tomcat.host}" port="${tomcat.port}"/>
jhorvath@2242
   288
                </and>
jhorvath@2242
   289
            </condition>
jhorvath@2242
   290
        </fail>
jhorvath@2248
   291
        <mkdir dir="../ExceptionUtils/tomcat_base/logs"/>
jhorvath@2242
   292
    </target>
jhorvath@2242
   293
    
jtulach@2659
   294
    <target name="start-tomcat" depends="-check-tomcat" unless="tomcat.running">
jhorvath@2242
   295
        <echo message="Starting Tomcat..."/>
jtulach@2204
   296
        <property name="tomcat.root" location="${tomcat.home}/.."/>
jtulach@2632
   297
        <property name="tomcat.opts" value=""/>
jsedek@2681
   298
        
jtulach@2286
   299
        <mkdir dir="${tomcat.base}/temp"/>
jtulach@2204
   300
        <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows 2003 Windows XP" 
jsedek@2681
   301
              executable="${tomcat.root}/bin/catalina.bat" dir="${tomcat.root}/bin/"
jsedek@2681
   302
              spawn="true"
jtulach@2204
   303
        >
jtulach@2576
   304
            <arg value="jpda"/>
jhorvath@2242
   305
            <arg value="start"/>
jtulach@2204
   306
            
jsedek@2563
   307
            <env key="java.awt.headless" value="true"/>
jtulach@2204
   308
            <env key="CATALINA_HOME" value="${tomcat.root}"/>
jtulach@2204
   309
            <env key="CATALINA_BASE" value="${tomcat.base}"/>
jtulach@2204
   310
            <env key="JAVA_HOME" value="${java.home}"/>
jtulach@2632
   311
            <env key="JAVA_OPTS" value="${tomcat.opts}"/>
jtulach@2576
   312
            <env key="JPDA_ADDRESS" value="${tomcat.debug.port}"/>
jtulach@2576
   313
            <env key="JPDA_SUSPEND"  value="${tomcat.debug.suspend}"/>
jtulach@2204
   314
        </exec>
jtulach@2204
   315
        <exec os="Linux SunOS Solaris Mac OS X"
jsedek@2681
   316
              executable="/bin/sh" dir="${tomcat.root}/bin/"
jtulach@2204
   317
        >
jtulach@2659
   318
            <!--<arg value="-x"/>-->
jtulach@2576
   319
            <arg value="${tomcat.root}/bin/catalina.sh"/>
jtulach@2576
   320
            <arg value="jpda"/>
jhorvath@2242
   321
            <arg value="start"/>
jsedek@2681
   322
            
jtulach@2564
   323
            <env key="DISPLAY" value=""/>
jtulach@2204
   324
            <env key="CATALINA_HOME" value="${tomcat.root}"/>
jtulach@2204
   325
            <env key="CATALINA_BASE" value="${tomcat.base}"/>
jtulach@2204
   326
            <env key="JAVA_HOME" value="${java.home}"/>
jtulach@2632
   327
            <env key="JAVA_OPTS" value="${tomcat.opts}"/>
jtulach@2576
   328
            <env key="JPDA_ADDRESS" value="${tomcat.debug.port}"/>
jtulach@2576
   329
            <env key="JPDA_SUSPEND"  value="${tomcat.debug.suspend}"/>
jtulach@2204
   330
        </exec>
jtulach@2576
   331
        <waitfor maxwait="30" maxwaitunit="second" checkevery="5" checkeveryunit="second">
jhorvath@2242
   332
            <http url="${tomcat.url}"/>
jhorvath@2242
   333
        </waitfor>
jhorvath@2242
   334
        
jhorvath@2264
   335
        <loadresource property="serverstamp1" failonerror="false" quiet="true">
jhorvath@2242
   336
            <url url="${tomcat.url}/stamp"/>
jhorvath@2242
   337
        </loadresource>
jsedek@2681
   338
        
jtulach@2548
   339
        <fail message="Tomcat is not started at ${tomcat.url}">
jhorvath@2242
   340
            <condition>
jhorvath@2242
   341
                <not>
jhorvath@2242
   342
                    <equals arg1="${stamp}" arg2="${serverstamp1}"/>
jhorvath@2242
   343
                </not>
jhorvath@2242
   344
            </condition>
jhorvath@2242
   345
        </fail>
jhorvath@2242
   346
    </target>
jhorvath@2242
   347
    
jtulach@2414
   348
    <target name="stop-tomcat" depends="-check-tomcat"  if="tomcat.running">
jsedek@2681
   349
        
jhorvath@2242
   350
        <echo message="Stopping Tomcat..."/>
jhorvath@2242
   351
        
jhorvath@2242
   352
        <property name="tomcat.root" location="${tomcat.home}/.."/>
jsedek@2681
   353
        
jhorvath@2242
   354
        <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows 2003 Windows XP" 
jsedek@2681
   355
              executable="${tomcat.root}/bin/catalina.bat" dir="${tomcat.root}/bin/"
jhorvath@2242
   356
        >
jhorvath@2242
   357
            <arg value="stop"/>
jhorvath@2242
   358
            
jhorvath@2242
   359
            <env key="CATALINA_HOME" value="${tomcat.root}"/>
jhorvath@2242
   360
            <env key="CATALINA_BASE" value="${tomcat.base}"/>
jhorvath@2242
   361
            <env key="JAVA_HOME" value="${java.home}"/>
jhorvath@2242
   362
        </exec>
jhorvath@2242
   363
        <exec os="Linux SunOS Solaris Mac OS X"
jsedek@2681
   364
              executable="${tomcat.root}/bin/catalina.sh" dir="${tomcat.root}/bin/"
jhorvath@2242
   365
        >
jhorvath@2242
   366
            <arg value="stop"/>
jsedek@2681
   367
            
jtulach@2564
   368
            <env key="DISPLAY" value=""/>
jhorvath@2242
   369
            <env key="CATALINA_HOME" value="${tomcat.root}"/>
jhorvath@2242
   370
            <env key="CATALINA_BASE" value="${tomcat.base}"/>
jhorvath@2242
   371
            <env key="JAVA_HOME" value="${java.home}"/>
jhorvath@2242
   372
        </exec>
jhorvath@2242
   373
        <waitfor maxwait="30" maxwaitunit="second" checkevery="5">
jhorvath@2242
   374
            <not>
jhorvath@2242
   375
                <http url="${tomcat.url}"/>
jhorvath@2242
   376
            </not>
jhorvath@2242
   377
        </waitfor>
jhorvath@2242
   378
        
jtulach@2204
   379
    </target>
jtulach@2204
   380
    
jtulach@2204
   381
    <target name="-pre-run-deploy" depends="start-tomcat">
jtulach@2189
   382
        <!-- get the server if not available -->
jtulach@2189
   383
        <!-- place libraries into correct place -->
jtulach@2189
   384
        <!-- maybe: choose some random port -->
jtulach@2204
   385
        <fail message="We need tomcat to run! Specify its location using -Dtomcat.home, or just execute 'ant all' it should download it automatically.">
jtulach@2204
   386
            <condition>
jtulach@2204
   387
                <not>
jhorvath@2242
   388
                    <available file="${tomcat.home}/lib/catalina-ant.jar"/>  
jtulach@2204
   389
                </not>
jhorvath@2242
   390
            </condition> 
jtulach@2204
   391
        </fail>
jtulach@2189
   392
    </target>
jtulach@2190
   393
    <target name="-post-run-deploy">
jtulach@2190
   394
        <!-- configuration changes? -->
jtulach@2190
   395
    </target>
jtulach@2189
   396
    
jtulach@2016
   397
    <target name="run-server" depends="run" if="url.file">
jtulach@2659
   398
        <fail unless="tomcat.url" message="tomcat.url property has to be filled now after starting tomcat"/>
jtulach@2659
   399
        <echo message="${tomcat.url}" file="${url.file}"/>
jtulach@2016
   400
    </target>
jsedek@2681
   401
    
jtulach@2287
   402
    <target name="-test-server">
jtulach@2661
   403
        <tempfile destdir="build" deleteonexit="true" property="index.file"/>
jtulach@2287
   404
        <get src="${tomcat.url}/analytics/index.jsp" dest="${index.file}"/>
jtulach@2188
   405
        <loadfile srcfile="${index.file}" property="${index.content}"/>
jtulach@2188
   406
        <fail message="Valid page must be returned">
jtulach@2188
   407
            <condition>
jtulach@2188
   408
                <and>
jtulach@2188
   409
                    <contains string="${index.content}" substring="NetBeans Analytics Community"/>
jtulach@2188
   410
                    <contains string="${index.content}" substring="uploaded logs on the server right now"/>
jtulach@2188
   411
                </and>
jtulach@2188
   412
            </condition>
jtulach@2188
   413
        </fail>
jsedek@2681
   414
    </target>
jsedek@2681
   415
    
jsedek@2681
   416
    <target name="-test-server-upload" unless="skip.upload">
jsedek@2681
   417
        <tempfile deleteonexit="true" property="upload.file"/>
jsedek@2681
   418
        <get src="${tomcat.url}/analytics/upload.jsp" dest="${upload.file}"/>
jsedek@2681
   419
        <loadfile srcfile="${upload.file}" property="${upload.content}"/>
jsedek@2662
   420
        <fail message="upload.jsp file should be accessible">
jsedek@2662
   421
            <condition>
jsedek@2662
   422
                <and>
jsedek@2662
   423
                    <contains string="${upload.content}" substring="Upload of NetBeans Analytics Logs Finished"/>
jsedek@2662
   424
                </and>
jsedek@2662
   425
            </condition>
jsedek@2662
   426
        </fail>
jtulach@2188
   427
    </target>
jtulach@2414
   428
jtulach@2414
   429
    <target description="Stops the server and clean build products." name="clean" depends="stop-tomcat,analytics-impl.clean"/>
jtulach@2415
   430
    
jtulach@2415
   431
    <target name="javadoc-build"/>
jtulach@1806
   432
</project>