You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/04/28 21:31:37 UTC

cvs commit: jakarta-tomcat/proposals/build2/ant tomcat.jsp

costin      01/04/28 12:31:37

  Added:       proposals/build2 index.html
               proposals/build2/WEB-INF ant.tld build.xml web.xml
               proposals/build2/WEB-INF/scripts ant.properties nightly.sh
                        runant.xml tomcat.xml
               proposals/build2/WEB-INF/src AntProperty.java
                        AntServletLogger.java AntTEI.java AntTag.java
                        AntTarget.java
               proposals/build2/ant tomcat.jsp
  Log:
  Adding the (experimental) new build tool. It is used already
  for nightly ( and normal ) tomcat builds ( in a slightly modified form ).
  
  The user interface is not even started, just some links to allow
  run of individual or agregate steps of the build process ( checkout,
  build individual components, tests, etc ).
  
  Revision  Changes    Path
  1.1                  jakarta-tomcat/proposals/build2/index.html
  
  Index: index.html
  ===================================================================
  <h1>Tomcat web-based build </h1>
  
  <h2>Intro</h2>
  
  Build is difficult - there are many small steps involved, READMEs that
  are out of date, dependencies and settings. Scripts that automate it
  are hard to setup and provide very little customization.
  
  <p>
  
  About a year ago we started nightly builds for tomcat. We than started
  to run tests, build other projects. The whole thing was rewritten 3
  times. Gump is a great tool that does the same thing ( in a different 
  way ) - but it has the same problem as most scripts I know: hard to
  setup, hard to customize.
  
  <p>
  
  This project tries to improve the situation in few ways:
  
  <ul>
  <li>Use a self-contained web application. The whole thing will be packaged
  as a WAR, with ant, jaxp and other dependencies in WEB-INF/lib, and with
  a single configuration point ( and a web-based form will be added to
  set it up ).
  
  <li>Open up the build process and split it in individual steps. You should be
  able to run any step manually, at any time. In time we can add "wizard"
  like interfaces, and logic to verify the dependencies are realized.
   
  </ul>
  
  <h2>Goals</h2>
  
  <ul>
  <li>Easy to use tool - get the WAR, deploy it, use the wizard
  to set up the environment, run the steps you need.
  
  <li>Integration with the "normal" development environment. This should
  work similar with the "antidote" - except that it'll be web based. 
  
  <li>Integration with gump. Xml descriptions of the projects will be
  used to generate the UI ( probably we'll use ant-based scripts instead
  of bat/bash ).
  
  <ul>
  
  <h2>Status</h2>
  
  The current scripts are usable ( and used for nightly tomcat build and
  test ). The user interface is not done, we just have a set of links to
  various scripts. Gump integration isn't started, but few experiments were
  made ( I would do it after some work on interface is done ). 
  
  <h2>Architecture</h2>
  
  We use few jsp taglibs to allow calls to ant and create the UI. <p>
  Few custom ant tasks and scripts allow execution of ant out-of-process,
  using different java VMs, starting and stoping tomcat ( or executing 
  different programs ).
  
  <p>
    
  
  <hr>
  
  Links:
  
  <ul>
  <li><a href="ws">Workspace</a>.
  <li><a href="log">Logs</a>.
  <li><a href="zip">Distribution files</a>.
  </ul>
  
  Nightly:
  
  <ol>
   <li><a href="ant/tomcat.jsp?target=tomcat.clean.src">Clean tomcat workspace</a>.
   <li>Get the source from CVS or snapshots
     <ul>
       <li><a href="ant/tomcat.jsp?target=cvs.get&package.name=jakarta-tomcat&arch.name=tomcat-3.3">Get jakarta-tomcat sources from CVS</a> or
         <a href="ant/tomcat.jsp?target=package.get&arch.name=tomcat-3.3">Get 
  	 from snapshot</a>
       </li>
     </ul>
   </li>
   <li>Create source packages
     <ul>
       <li><a href="ant/tomcat.jsp?target=src.package&arch.name=tomcat-3.3&package.name=jakarta-tomcat">Create source package for tomcat</a>.
       </li>
     </ul>
   </li>
  
   <li>Test special builds
     <ul>
       <li><a href="ant/tomcat.jsp?target=tomcat.clean.bin">Clean tomcat
  	   build/dist</a></li>
       <li><a href="ant/tomcat.jsp?target=tomcat-jdk11">JDK1.1</a>.
       </li>
       <li><a href="ant/tomcat.jsp?target=bin.package&arch.name=tomcat-jdk11">
  Create binary snapshots</a>. ( before testing or building test apps )
       </li>
       <li><a href="ant/tomcat.jsp?target=tomcat.clean.bin">Clean tomcat
  	   build/dist</a></li>
       <li><a href="ant/tomcat.jsp?target=tomcat-noext">Build tomcat, 
  	   no JSSE</a>.
       </li>
       <li><a href="ant/tomcat.jsp?target=bin.package&arch.name=tomcat-nojsse">Create binary snapshots</a>. ( before testing or building test apps )
       </li>
     </ul>
   </li>
  
   <li>Build and create binary packages
     <ul>
       <li><a href="ant/tomcat.jsp?target=tomcat.clean.bin">Clean tomcat
  	   build/dist</a></li>
       <li><a href="ant/tomcat.jsp?target=tomcat-jsse">Full build, all packages( JSSE )</a>.
       </li>
       <li><a href="ant/tomcat.jsp?target=bin.package&arch.name=tomcat">Create binary snapshots</a>. ( before testing or building test apps )
       </li>
       <li><a href="ant/tomcat.jsp?target=test.build">Build test applications</a>
       </li>
     </ul>
   </li>
  
  </ol>
  
  <h3>Prepare</h3>
  
  Download binaries tomcat build and testing depends on.  This should be updated
  for every new stable release of a binary package. In "gump" mode, this should 
  be done nightly using the latest builds.
  
  <ol>
   <li>Configure and download the binary packages
     <ul>
       <li><a href="ant/tomcat.jsp?target=ant.get">Get jakarta-ant binaries</a>
       </li>
       <li><a href="ant/tomcat.jsp?target=crimson.get">Get crimson binaries</a>
       </li>
     </ul>
   <li><a href="ant/tomcat.jsp?target=ws.clean">Clean ws and dist dirs (?)</a>.
   <li>Get the source from CVS or snapshots
     <ul>
       <li><a href="ant/tomcat.jsp?target=cvs.get&package.name=jakarta-tomcat&arch.name=tomcat-3.3">Get jakarta-tomcat sources from CVS</a> or
         <a href="ant/tomcat.jsp?target=package.get&arch.name=tomcat-3.3">Get 
  	 from snapshot</a>
       </li>
       <li><a href="ant/tomcat.jsp?target=cvs.get.tag&package.name=jakarta-watchdog&arch.name=watchdog&tag=tomcat_32">Get jakarta-watchdog source from CVS</a> 
       </li>
       <li><a href="ant/tomcat.jsp?target=cvs.get&package.name=jakarta-tools&arch.name=jakarta-tools">Get jakarta-tools source from CVS</a> 
       </li>
       <li><a href="ant/tomcat.jsp?target=cvs.get&package.name=jakarta-servletapi&arch.name=jakarta-servletapi">Get jakarta-servletapi source from CVS</a> 
       </li>
     </ul>
   </li>
   <li>Create source packages
     <ul>
       <li><a href="ant/tomcat.jsp?target=src.package&arch.name=watchdog&package.name=jakarta-watchdog">Create source package for watchdog</a>.
       </li>
     </ul>
   </li>
  
   <li>Build and create binary packages
     <ul>
       <li><a href="ant/tomcat.jsp?target=servletapi.build">Build servletapi</a>
    ( needed for watchdog build )
       </li>
       <li><a href="ant/tomcat.jsp?target=tomcat-jsse">Full build, all packages( JSSE )</a>.
       </li>
       <li><a href="ant/tomcat.jsp?target=test.build">Build test applications</a>
       </li>
       <li><a href="ant/tomcat.jsp?target=watchdog.build">Build watchdog</a>
       </li>
     </ul>
   </li>
  
  
  </ol>
  
  
  <h2>Agregate targets</h2>
  
  <ul>
  
  <li><a href="ant/tomcat.jsp?target=from.web">Full build, get sources from snapshot</a>
  
  <li><a href="ant/tomcat.jsp?target=from.cvs">Full build, get sources from cvs</a>
  
  
  </ul>
  
  
  <h2>Testing</h2>
  
  <ul>
  
  <li>Get and install tomcat binary
  ( watchdog wars, sanity-test) from the binary distribution
  
  
  <li><a href="ant/tomcat.jsp?target=wars.get">Get test applications</a> 
  ( watchdog wars, sanity-test)
  
  <li><a href="ant/tomcat.jsp?target=change.port">Get the port</a> 
  ( watchdog wars, sanity-test)
  
  <li><a href="ant/tomcat.jsp?target=start.tomcat">Start tomcat</a> 
  
  <li><a href="ant/tomcat.jsp?target=start.tomcat">Run watchdog</a> 
  
  <li><a href="ant/tomcat.jsp?target=start.tomcat">Stop tomcat</a> 
  
  </ul>
  
  
  <h2>Other</h2>
  
  <ul>
  
  <li><a href="ant/tomcat.jsp?target=rebuild">Rebuild myself</a>. Will rebuild
  the build webapp.
  
  <li><a href="ant/tomcat.jsp?target=ws.clean">Clean all temp files</a>.
  
  <li>Install 
  <a href="/admin/contextAdmin/contextAdd.jsp?submit=Add+Context&addContextPath=/test&addContextDocBase=test">test</a> 
  <a href="/admin/contextAdmin/contextAdd.jsp?submit=Add+Context&addContextPath=/servlet-tests&addContextDocBase=servlet-tests">servlet-tests</a> 
  <a href="/admin/contextAdmin/contextAdd.jsp?submit=Add+Context&addContextPath=/jsp-tests&addContextDocBase=jsp-tests">jsp-tests</a> 
  
  <li>Remove 
  <a href="/admin/contextAdmin/contextRemove.jsp?removeContextName=/test">test</a>
  <a href="/admin/contextAdmin/contextRemove.jsp?removeContextName=/servlet-tests">servlet-tests</a>
  <a href="/admin/contextAdmin/contextRemove.jsp?removeContextName=/jsp-tests">jsp-tests</a>
  </ul>
  
  <h2>Prepare</h2>
  
  <br>If you are behind a socks firewall, remember to do 
  "runsocks tomcat.sh run" ( or socksify ).
  If you are behind a firewall, and you have a HTTP proxy, rememver to
  set TOMCAT_OPTS="-Dhttp.proxyHost=MYPROXY -Dhttp.proxyPort=PROXYPORT"
  
  <ol>
  <li>Download and install 
   <a href="http://jakarta.apache.org/builds/jakarta-ant/release/v1.3/bin">Ant</a>,
   <a href="http://java.sun.com/products/jsse">JSSE</a>, 
   <a href="http://java.sun.com/xml/archive.html"JAXP1.0.1</a>
  
  <li>Make sure you have JDK1.1 and JDK1.2(or later) installed
  
  <li>Edit the file 
   TOMCAT_HOME/webapps/build/WEB-INF/scripts/ant.properties and set all the 
  properties to match your system.
  <br>XXX a web based page can be created - contributions welcomed.
  
  <ol>
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/ant.tld
  
  Index: ant.tld
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
    "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
  
  <taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>Ant</shortname>
    <uri>http://jakarta.apache.org/taglibs/ant-1.0</uri>
  
    <info>
      Tags allowing us to run ant. Ant can do a lot of usefull tasks 
      ( run time building, automated testing, etc ).
    </info>
  
    <!-- ******************** Defined Custom Tags *************************** -->
    <tag>
      <name>ant</name>
      <tagclass>tadm.AntTag</tagclass>
      <teiclass>tadm.AntTEI</teiclass>
      <info>Run ant</info>
      <attribute>
         <name>testFile</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>target</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>debug</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>
  
  
    <tag>
      <name>property</name>
      <tagclass>tadm.AntProperty</tagclass>
      <info>Set a property to GTest and ant. If no value is specificed, 
  a request parameter with the same name will be used</info>
      <attribute>
         <name>name</name>
         <required>true</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>param</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>value</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>location</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>webApp</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>
  
    <tag>
      <name>target</name>
      <tagclass>tadm.AntTarget</tagclass>
      <info>Add a target. You can either specify the target name or the 
  name of a request parameter holding the name(s)</info>
      <attribute>
         <name>name</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>param</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
    </tag>
  
  </taglib>
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <project name="build2" default="main" basedir=".">
  
    <!-- Directories -->
    <!-- assume proposals/built2/WEB-INF -->
    <property name="tmp.tomcat.src" location="../../.."/>
  
    <property name="tomcat.home" 
  	    location="${tmp.tomcat.src}/build/tomcat"/>
    
    <!-- predefined -->
    <property name="ant.home" value="XXX predefined XXX"/>
    
    <property name="webapp.name" value="build2" />
  
    <property name="webapp.src" location=".." />
    
    <property name="webapp.dest" 
  	    value="${tomcat.home}/webapps/${webapp.name}" />
  
     <property name="servlet.jar" 
  	    value="${tomcat.home}/lib/common/servlet.jar" />
  
    <!-- ==================== Initialization - guessing config ========== -->
    <target name="help" > 
      <echo message="Build for the build application "/>
      <echo message="Use ant -f proposals/build2/WEB-INF/build.xml "/>
      <echo message="Properties:"/>
      <echo message="-Dtomcat.home  location of tomcat install"/>
      <echo message="-Dwebapp.name  the name of the build app [build2]"/>
    </target>
  
    <target name="init">
    </target>
    
    <!-- ==================== Copy static files ==================== -->
    
    <target name="prepare" depends="init">
      <mkdir dir="${webapp.dest}" />
      <mkdir dir="${webapp.dest}/WEB-INF" />
      <mkdir dir="${webapp.dest}/WEB-INF/lib" />
      
      <copy todir="${webapp.dest}">
        <fileset dir="${webapp.src}" includes="**"/>
      </copy>
   
      <!-- Extra dependencies -->
      <copy todir="${webapp.dest}/WEB-INF/lib"
  	  file="${tomcat.home}/lib/container/tomcat_util.jar" />
      <copy todir="${webapp.dest}/WEB-INF/lib"
  	  file="${tomcat.home}/lib/common/core_util.jar" />
      <copy todir="${webapp.dest}/WEB-INF/lib"
  	  file="${ant.home}/lib/ant.jar" />
      <copy todir="${webapp.dest}/WEB-INF/lib"
  	  file="${ant.home}/lib/jaxp.jar" />
      <copy todir="${webapp.dest}/WEB-INF/lib"
  	  file="${ant.home}/lib/parser.jar" />
      
    </target>
      
    <target name="build" depends="prepare"
  	  description="Build and install into tomcat.home" >
      <mkdir dir="${webapp.dest}/WEB-INF/classes" />
      <javac srcdir="${webapp.src}/WEB-INF/src" 
  	   destdir="${webapp.dest}/WEB-INF/classes" >
        <classpath>
  	<pathelement location="${servlet.jar}" />
  	<fileset dir="${webapp.dest}/WEB-INF/lib" 
  		 includes="*.jar" />
        </classpath>
      </javac>
    </target>
      
    <target name="rebuild" depends="init" 
  	  description="Build without copy and prepare">
      <mkdir dir="${webapp.dest}/WEB-INF/classes" />
      <mkdir dir="${webapp.dest}/WEB-INF/lib" />
      <javac srcdir="${webapp.dest}/WEB-INF/src" 
  	   destdir="${webapp.dest}/WEB-INF/classes" >
        <classpath>
  	<pathelement location="${servlet.jar}" />
  	<fileset dir="${webapp.dest}/WEB-INF/lib" 
  		 includes="*.jar" />
        </classpath>
      </javac>
    </target>
      
    <target name="dist" depends="build" 
  	  description="Create distribution war file ">
      <jar jarfile="${tomcat.home}/webapps/${webapp.name}.war" 
  	 basedir="${tomcat.home}/webapps/${webapp.name}" 
  	 includes="**"/> 
  	
      <copy file="${tomcat.home}/webapps/${webapp.name}.war" 
  	  todir="${tomcat.home}/webapps/" />
  	
    </target>
  
    <target name="main" depends="build"/>
      
  </project>
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <!DOCTYPE web-app PUBLIC 
       "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
  
  <web-app>
    <description>Tomcat Build</description>
    <taglib>
      <taglib-uri>http://jakarta.apache.org/taglibs/tomcat_util-1.0</taglib-uri>
      <taglib-location>/WEB-INF/util.tld</taglib-location>
    </taglib>
    <taglib>
      <taglib-uri>http://jakarta.apache.org/taglibs/ant-1.0</taglib-uri>
      <taglib-location>/WEB-INF/ant.tld</taglib-location>
    </taglib>
  
    <security-constraint>
      <web-resource-collection>
        <web-resource-name>Protected Area</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>DELETE</http-method>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
      </web-resource-collection>
      <auth-constraint>
        <role-name>tomcat_admin</role-name>
      </auth-constraint>
    </security-constraint>
    
    <security-constraint>
      <web-resource-collection>
        <web-resource-name>Protected Area</web-resource-name>
        <url-pattern>/opt/*</url-pattern>
        <http-method>DELETE</http-method>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
      </web-resource-collection>
      <auth-constraint>
        <role-name>private_XXXXXXX</role-name>
      </auth-constraint>
    </security-constraint>
    
    <login-config>
      <auth-method>BASIC</auth-method>
      <realm-name>Admin</realm-name>
    </login-config>
  </web-app>
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/scripts/ant.properties
  
  Index: ant.properties
  ===================================================================
  jdk11.home=/usr/java/jdk118
  jdk12.home=/usr/java/jdk1.3.1
  build.compiler=modern
  #install.dir=/home/costin/opt
  cvs.root=:pserver:anoncvs@jakarta.apache.org:/home/cvspublic
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/scripts/nightly.sh
  
  Index: nightly.sh
  ===================================================================
  #!/bin/sh
  
  TOMCAT=$HOME/tomcat
  S=$TOMCAT/webapps/build/WEB-INF/scripts
  H=$TOMCAT/webapps/build
  L=$TOMCAT/webapps/build/log
  ANT_HOME=$HOME/opt/jakarta-ant-1.3
  ANT=$ANT_HOME/bin/ant
  DEF="-Dtomcat.home=$TOMCAT -Dant.home=$ANT_HOME"
  JAVA_HOME=/usr/java1.3.0
  PATH=/home/costin/bin:/usr/local/bin:$JAVA_HOME/bin:$PATH
  export PATH
  unset ZIP
  export JAVA_HOME
  
  $ANT -f $S/tomcat.xml tomcat.clean.src >$L/tomcat.clean.src.log 2>&1
  
  $ANT -f $S/tomcat.xml $DEF -Dpackage.name=jakarta-tomcat -Darch.name=tomcat-3.3 cvs.get >$L/cvs.get.tomcat.log 2>&1
  
  $ANT -f $S/tomcat.xml $DEF -Dpackage.name=jakarta-tomcat -Darch.name=tomcat-3.3 src.package >$L/src.package.tomcat.log 2>&1
  
  $ANT -f $S/tomcat.xml $DEF tomcat-clean >$L/jdk11.log 2>&1
  
  $ANT -f $S/tomcat.xml $DEF tomcat-jdk11 >>$L/jdk11.log 2>&1
  
  
  $ANT -f $S/tomcat.xml $DEF tomcat-clean >$L/nosse.log 2>&1
  $ANT -f $S/tomcat.xml $DEF tomcat-noext >>$L/nosse.log 2>&1
  
  $ANT -f $S/tomcat.xml $DEF tomcat-clean >$L/full.log 2>&1
  $ANT -f $S/tomcat.xml $DEF tomcat-jsse >>$L/full.log 2>&1
  $ANT -f $S/tomcat.xml $DEF -Darch.name=tomcat bin.package >>$L/full.log 2>&1
  
  $ANT -f $S/tomcat.xml $DEF test.build >>$L/full.log 2>&1
  
  $ANT -f $S/tomcat.xml $DEF change.port >$L/test.log 2>&1
  
  $ANT -f $S/tomcat.xml stop-tomcat >>$L/test.log 2>&1
  
  $ANT -f $S/tomcat.xml start-tomcat >>$L/test.log 2>&1
  
  $ANT -f $S/tomcat.xml run-watchdog >>$L/test.log 2>&1
  
  $ANT -f $S/tomcat.xml run-sanity >>$L/test.log 2>&1
  
  $ANT -f $S/tomcat.xml stop-tomcat >>$L/test.log 2>&1
  
  $ANT -f $S/tomcat.xml start-tomcat-security >$L/test-sandbox.log 2>&1
  
  $ANT -f $S/tomcat.xml run-watchdog >>$L/test-sandbox.log 2>&1
  
  $ANT -f $S/tomcat.xml run-sanity >>$L/test-sandbox.log 2>&1
  
  $ANT -f $S/tomcat.xml stop-tomcat >>$L/test-sandbox.log 2>&1
  
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/scripts/runant.xml
  
  Index: runant.xml
  ===================================================================
  <project name="tomcat" default="main" basedir=".">
     <!-- Helper to run ant and various programms - hacky code -->
  
     <!-- ******************** Initialization ******************** -->
    <target name="init">
      <property name="base.dir" value="../.." />
  
      <property file="${base.dir}/WEB-INF/scripts/ant.properties" />
     
      <property name="libs" value="${base.dir}/WEB-INF/lib" />
  
      <property name="ws.dir"
  	      value="${base.dir}/ws" />
      <property name="pkg.dir"
  	      value="${base.dir}/zip" />
  
      <property name="cvs.root" 
  	      value=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic" />
  
      <property name="package-src.url" 
  	      value="http://nagoya.apache.org:8080/build/zip" />
  
      <property name="script.dir"
  	      value="${base.dir}/WEB-INF/scripts" />
  
      <property name="pacakage.name" value="jakarta-tomcat" />
  
      <property name="ant.home" value="${install.dir}/jakarta-ant-1.3" />
  
  
     </target>
  
    <!-- External Tar -->
    <target name="tar" depends="init">
      <!-- Params: tar.basedir, tar.tarfile, tar.includes. tar.excludes
        -->
      <exec dir="${tar.basedir}" 
  	  executable="tar" 
  	  timeout="300000">
        <arg value="-cf"/>
        <arg value="tmp.tar"/>
        <arg value="${tar.includes}"/>
      </exec>
      <move file="${tar.basedir}/tmp.tar" tofile="${tar.tarfile}" />
    </target>
  
    <!-- External zip -->
    <target name="zip" depends="init">
      <!-- Params: zip.basedir, zip.zipfile, zip.includes. zip.excludes
        -->
      <exec dir="${zip.basedir}" 
  	  executable="zip" 
  	  timeout="300000" >
        <arg value="-r"/>
        <arg value="tmp.zip"/>
        <arg value="${zip.includes}"/>
      </exec>
      <move file="${zip.basedir}/tmp.zip" tofile="${zip.zipfile}" />
    </target>
  
  
  
    <!-- Run ant in a separate VM ( other JDK ) -->
    <target name="exec-ant-other-vm" depends="init">
      <property name="jdk.home" value="${java.home}" />
      <property name="extraCP" value="" />
      <property name="extraArgs" value="" />
      <property name="exec.ant.file" 
  	      value="${ws.dir}/jakarta-tomcat/build.xml" />
      <property name="exec.ant.target" value="clean" />
  
  
      <!-- set class path -->
      <property name="antCP" 
        value="${ant.home}/lib/ant.jar" />
      <property name="jaxpCP" 
        value="${ant.home}/lib/jaxp.jar:${ant.home}/lib/parser.jar" />
      <property name="toolCP" 
        value="${jdk.home}/../lib/tools.jar:${jdk.home}/lib/classes.zip" />
  
      <echo message="Running ant" />
      <echo message="CP=${antCP}:${toolCP}:${jaxpCP}:${extraCP}" />
      <echo message="extraParam=${extraArgs}" />
      <exec dir="." 
  	  executable="${jdk.home}/bin/java" 
  	  timeout="300000">
        <env key="JAVA_HOME"
  	   path="${jdk.home}" />
        <env key="CLASSPATH"
  	   path="${antCP}:${toolCP}:${jaxpCP}:${extraCP}" />
        <arg value="org.apache.tools.ant.Main"/>
        <arg value="-Dant.home"/>
        <arg value="${ant.home}"/>
        <arg value="-Dtomcat.home"/>
        <arg value="${tomcat.home}"/>
        <arg value="-Dbuild.compiler"/>
        <arg value="${build.compiler}"/>
        <arg line="${extraArgs}" />
        <arg value="-f"/>
        <arg value="${exec.ant.file}"/>
        <arg value="${exec.ant.target}"/>
      </exec>
    </target>
  
    <!-- Run ant in a separate VM ( other JDK ) -->
    <target name="run-ant-other-vm-1" depends="init">
      <property name="jdk.home" value="${jdk12.home}/jre" />
      <property name="antCP" 
  	      value="${ant.home}/lib/ant.jar" />
      <property name="jaxpCP" 
  	      value="${ant.home}/lib/jaxp.jar:${ant.home}/lib/parser.jar" />
      <property name="toolCP" 
  	      value="${jdk.home}/../lib/tools.jar:${jdk.home}/lib/classes.zip" />
      <property name="extraCP" value="" />
  
      <echo message="Running ant with ${antCP}:${toolCP}:${jaxpCP}:${extraCP}" />
      <java dir="${ws.dir}/jakarta-tomcat" 
  	  fork="true"
  	  classname="org.apache.tools.ant.Main"
  	  jvm="${jdk.home}/bin/java" 
            failonerror="false"	  >
        <arg value="-Dant.home"/>
        <arg value="${ant.home}"/>
        <arg value="-Dbuild.compiler"/>
        <arg value="${build.compiler}"/>
        <arg value="-f"/>
        <arg value="${ws.dir}/jakarta-tomcat/build.xml"/>
        <arg value="dist"/>
        <classpath>
  	<pathelement path="${antCP}" />
  	<pathelement path="${toolCP}" />
  	<pathelement path="${jaxpCP}" />
  	<pathelement path="${extraCP}" />
        </classpath>
      </java>
    </target>
  
  
    <target name="run-ant-same-vm" depends="init">
      <java classname="org.apache.tools.ant.Main" >
        <arg value="-Dant.home"/>
        <arg value="${ant.home}"/>
        <arg value="-Dbuild.compiler"/>
        <arg value="${build.compiler}"/>
        <arg value="-f"/>
        <arg value="${ws.dir}/jakarta-tomcat/build.xml"/>
        <arg value="dist"/>
        <classpath>
  	<pathelement location="${libs}/parser.jar" />
  	<pathelement location="${libs}/jaxp.jar" />
  	<pathelement location="${libs}/ant.jar" />
  	<pathelement location="${java.home}/lib/classes.zip" />
  	<pathelement location="${java.home}/../lib/tools.jar" />
        </classpath>
      </java>
    </target>
  
    <target name="run-ant" depends="run-ant-same-vm"/>
  
    <target name="run-ant-call" depends="init">
      <ant dir="${ws.dir}/jakarta-tomcat" 
  	 antfile="${ws.dir}/jakarta-tomcat/build.xml"
  	 target="dist" >
        <property name="tomcat.home" value="${ws.dir}/dist/tomcat" />
        <property name="ant.home" value="${ant.home}" />
      </ant>
    </target>
  
  
    <target name="main" depends="init"/>
  
  </project>
  
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/scripts/tomcat.xml
  
  Index: tomcat.xml
  ===================================================================
  <project name="tomcat" default="main" basedir=".">
  
     <!-- ******************** Initialization ******************** -->
    <target name="init">
      <property name="base.dir" location="../.." />
  
      <property file="${base.dir}/WEB-INF/scripts/ant.properties" />
     
      <property name="libs" value="${base.dir}/WEB-INF/lib" />
  
      <property name="ws.dir"
  	      value="${base.dir}/ws" />
      <property name="pkg.dir"
  	      value="${base.dir}/zip" />
  
      <property name="log.dir"
  	      value="${base.dir}/log" />
      <property name="script.dir"
  	      value="${base.dir}/WEB-INF/scripts" />
  
      <property name="pacakage.name" value="jakarta-tomcat" />
  
      <property name="install.dir" location="${base.dir}/opt" />
  
      <property name="ant.home" value="${install.dir}/jakarta-ant-1.3" /> 
      <mkdir dir="${log.dir}" />
      <mkdir dir="${install.dir}" />
     </target>
  
     <!-- ******************** Building  ******************** -->
    <target name="tomcat-clean" depends="init">
      <ant antfile="${script.dir}/runant.xml" 
  	 target="exec-ant-other-vm" >
        <property name="exec.ant.file" 
  		value="${ws.dir}/jakarta-tomcat/build.xml" />
        <property name="exec.ant.target" value="clean" />
      </ant>
    </target>
  
  
    <target name="tomcat-noext" depends="init">
      <ant antfile="${script.dir}/runant.xml" 
  	 target="exec-ant-other-vm" >
        <property name="exec.ant.file" 
  		value="${ws.dir}/jakarta-tomcat/build.xml" />
        <property name="exec.ant.target" value="dist" />
        <property name="extraArgs" 
  		value="-Djsse.home=DUMMY -Dinstall.dir=${install.dir}" />
      </ant>
    </target>
  
    <target name="tomcat-jsse" depends="init">
      <ant antfile="${script.dir}/runant.xml" 
  	 target="exec-ant-other-vm" >
        <property name="exec.ant.file" 
  		value="${ws.dir}/jakarta-tomcat/build.xml" />
        <property name="exec.ant.target" value="dist" />
        <property name="extraArgs" 
  		value="-Dinstall.dir=${install.dir}" />
      </ant>
    </target>
  
    <target name="tomcat-jdk11" depends="init">
      <ant antfile="${script.dir}/runant.xml" 
  	 target="exec-ant-other-vm" >
        <property name="exec.ant.file" 
  		value="${ws.dir}/jakarta-tomcat/build.xml" />
        <property name="exec.ant.target" value="dist" />
        <property name="jdk.home" value="${jdk11.home}" />
        <property name="extraArgs" 
  		value="-Djsse.home=DUMMY -Dinstall.dir=${install.dir}" />
      </ant>
    </target>
  
    <target name="test.build" depends="init">
      <ant antfile="${script.dir}/runant.xml" 
  	 target="exec-ant-other-vm" >
        <property name="exec.ant.file" 
  		value="${ws.dir}/jakarta-tomcat/build.xml" />
        <property name="exec.ant.target" value="tests.dist" />
        <property name="extraArgs" 
  		value="-Dinstall.dir=${install.dir}" />
      </ant>
      <copy file="${ws.dir}/jakarta-tomcat/dist/tomcat/webapps/test.war"
  	  todir="${pkg.dir}" />
      <copy file="${ws.dir}/jakarta-tomcat/dist/tomcat/webapps/servlet-tests.war"
  	  todir="${pkg.dir}" />
      <copy file="${ws.dir}/jakarta-tomcat/dist/tomcat/webapps/jsp-tests.war"
  	  todir="${pkg.dir}" />
    </target>
  
    <target name="watchdog.build" depends="init">
      <mkdir dir="${ws.dir}/jakarta-ant" />
      <copy todir="${ws.dir}/jakarta-ant" >
        <fileset dir="${ant.home}" includes="lib/**,bin/**" />
      </copy>
      <copy file="${ws.dir}/jakarta-watchdog/README"
            tofile="${ws.dir}/jakarta-watchdog/Readme"/>
      <ant antfile="${script.dir}/runant.xml" 
  	 target="exec-ant-other-vm" >
        <property name="exec.ant.file" 
  		value="${ws.dir}/jakarta-watchdog/build.xml" />
        <property name="exec.ant.target" value="dist" />
        <property name="extraArgs" 
  		value="-Dant.home=${ant.home} -Dtomcat.home=${ws.dir}/jakarta-tomcat/dist/tomcat" />
      </ant>
    </target>
  
    <target name="servletapi.build" depends="init">
      <mkdir dir="${ws.dir}/jakarta-ant" />
      <copy todir="${ws.dir}/jakarta-ant" >
        <fileset dir="${ant.home}" includes="lib/**,bin/**" />
      </copy>
      <ant antfile="${script.dir}/runant.xml" 
  	 target="exec-ant-other-vm" >
        <property name="exec.ant.file" 
  		value="${ws.dir}/jakarta-servletapi/build.xml" />
        <property name="exec.ant.target" value="dist" />
        <property name="extraArgs" 
  		value="-Dant.home=${ant.home} -Dtomcat.home=${ws.dir}/jakarta-tomcat/dist/tomcat" />
      </ant>
    </target>
  
    <target name="rebuild.webapp" depends="init"
  	  description="Rebuild the build webapp" >
      <ant antfile="../build.xml" target="rebuild" >
      </ant>
    </target>
  
  
    <!-- Parameters: dist.name, dist.dir 
      -->
    <target name="bin.package" depends="init"
  	  description="Create packages for the binary" >
      <!-- defaults - if not set -->
      <property name="dist.name" value="tomcat" />
      <property name="arch.name" value="tomcat-3.3M2" />
      <property name="dist.dir" value="jakarta-tomcat/dist" />
  
      <ant antfile="runant.xml" target="zip" >
         <property name="zip.zipfile" value="${pkg.dir}/${arch.name}.zip" />
         <property name="zip.basedir" value="${ws.dir}/${dist.dir}" />
         <property name="zip.includes" value="${dist.name}" />
      </ant>
  
      <ant antfile="runant.xml" target="tar" >
        <property name="tar.tarfile" value="${pkg.dir}/${arch.name}.tar" />
        <property name="tar.basedir" value="${ws.dir}/${dist.dir}" />
        <property name="tar.includes" value="${dist.name}" />
     </ant>
  
      <gzip zipfile="${pkg.dir}/${arch.name}.tar.gz" 
  	  src="${pkg.dir}/${arch.name}.tar" />
  
      <delete file="${pkg.dir}/${arch.name}.tar" />
  
    </target>
  
  
    <target name="start-tomcat" depends="init">
      <exec executable="${ws.dir}/jakarta-tomcat/dist/tomcat/bin/tomcat.sh" 
  	  timeout="300000" >
        <arg value="start"/>
        <arg value="-wait"/>
        <arg value="-noout"/>
        <env key="TOMCAT_HOME"
  	 path="${ws.dir}/jakarta-tomcat/dist/tomcat" />
      </exec>
    </target>
  
    <target name="run-watchdog" depends="init">
      <property name="watchdog.home" location="${ws.dir}/dist/watchdog" />
      <property name="jaxpCP" 
  	      value="${ant.home}/lib/jaxp.jar:${ant.home}/lib/parser.jar" />
  
      <exec executable="${watchdog.home}/bin/watchdog.sh" 
  	  timeout="300000" >
        <arg value="all"/>
        <arg value="localhost"/>
        <arg value="9080"/>
        <env key="WATCHDOG_HOME"
  	 path="${watchdog.home}" />
        <env key="CLASSPATH"
  	   value="${jaxpCP}" />
        <env key="TOMCAT_HOME"
  	 path="${ws.dir}/jakarta-tomcat/dist/tomcat" />
      </exec>
    </target>
  
    <target name="run-sanity" depends="init">
      <property name="test.tomcat.home" location="${ws.dir}/jakarta-tomcat/dist/tomcat" />
  
      <chmod perm="+x" file="${test.tomcat.home}/webapps/admin/WEB-INF/scripts/run-test.sh" />
      <exec executable="${test.tomcat.home}/webapps/admin/WEB-INF/scripts/run-test.sh" 
  	  timeout="300000" >
        <arg value="-Dport=9080"/>
        <env key="TOMCAT_HOME"
  	 path="${test.tomcat.home}" />
      </exec>
    </target>
  
    <target name="start-tomcat-security" depends="init">
      <exec executable="${ws.dir}/jakarta-tomcat/dist/tomcat/bin/tomcat.sh" 
  	  timeout="300000" >
        <arg value="start"/>
        <arg value="-wait"/>
        <arg value="-noout"/>
        <arg value="-sandbox"/>
        <env key="TOMCAT_HOME"
  	 path="${ws.dir}/jakarta-tomcat/dist/tomcat" />
      </exec>
    </target>
  
    <target name="stop-tomcat" depends="init">
      <exec executable="${ws.dir}/jakarta-tomcat/dist/tomcat/bin/tomcat.sh" 
  	  timeout="300000" >
      <env key="TOMCAT_HOME"
  	 path="${ws.dir}/jakarta-tomcat/dist/tomcat" />
      <arg value="stop"/>
      <arg value="-port"/>
      <arg value="9007"/>
      </exec>
    </target>
  
   
     <target name="change.port" depends="init" 
             description="Change tomcat port for testing " >
        <property name="test.tomcat.home"
  		value="${ws.dir}/jakarta-tomcat/dist/tomcat" />
  
        <replace file="${test.tomcat.home}/conf/server.xml" 
   	     token="8080" 
  	     value="9080" />
        <replace file="${test.tomcat.home}/conf/server.xml" 
  	     token="8007" 
  	     value="9007" />
        <replace file="${test.tomcat.home}/conf/server.xml" 
  	     token="8009" 
  	     value="9009" />
     </target>
  
    
     <!-- ******************** Agregate targets  ******************** -->
    <target name="main" depends="init">
    </target>
  
  
    <target name="weekly" depends="init">
      <mkdir dir="${base.dir}/log" />
  
      <ant antfile="tomcat.xml" target="ws.clean" >
      </ant>
  
      <ant antfile="tomcat.xml" target="cvs.get.tag" >
        <property name="package.name" value="jakarta-watchdog" />
        <property name="arch.name" value="watchdog" />
        <property name="tag" value="tomcat_32" />
      </ant>
  
      <ant antfile="tomcat.xml" target="cvs.get" >
        <property name="package.name" value="jakarta-tools" />
        <property name="arch.name" value="jakarta-tools" />
      </ant>
  
    </target>
  
    <target name="from.cvs" depends="init">
      <mkdir dir="${base.dir}/log" />
      <delete dir="${ws}/jakarta-tomcat" />
  
      <ant antfile="tomcat.xml" target="cvs.get" >
        <property name="package.name" value="jakarta-tomcat" />
        <property name="arch.name" value="tomcat-3.3" />
      </ant>
  
      <ant antfile="tomcat.xml" target="src.package" >
        <property name="package.name" value="jakarta-tomcat" />
        <property name="arch.name" value="tomcat-3.3" />
      </ant>
  
      <ant antfile="tomcat.xml" target="tomcat-clean" >
      </ant>
  
      <ant antfile="tomcat.xml" target="tomcat-noext" >
      </ant>
  
      <ant antfile="tomcat.xml" target="tomcat-clean" >
      </ant>
  
      <ant antfile="tomcat.xml" target="tomcat-jdk11" >
      </ant>
  
      <ant antfile="tomcat.xml" target="tomcat-clean" >
      </ant>
  
      <ant antfile="tomcat.xml" target="tomcat-jsse" >
      </ant>
  
      <ant antfile="tomcat.xml" target="bin.package" >
      </ant>
  
      <ant antfile="tomcat.xml" target="test.build" >
      </ant>
      
    </target>
  
    <!-- ******************** Creating source snapshots  ******** -->
  
    <target name="ws.clean.all" depends="init" 
  	  description="Remove workspace and dist dir" >
      <deltree dir="${webapp.dest}/ws" />
      <deltree dir="${webapp.dest}/zip" />
    </target>
  
    <target name="ws.clean" depends="init,tomcat.clean.src" 
  	  description="Remove the source and clean workspace" >
    </target>
  
    <target name="tomcat.clean.src" depends="init" 
  	  description="Remove the source and clean workspace" >
      <delete dir="${ws.dir}/jakarta-tomcat" />
      <delete dir="${pkg.dir}/jakarta-tomcat**" />
      <delete dir="${pkg.dir}/tomcat**" />
    </target>
  
    <target name="tomcat.clean.bin" depends="init" >
      <delete dir="${ws.dir}/jakarta-tomcat/dist/**" />
      <delete dir="${ws.dir}/jakarta-tomcat/build/**" />
    </target>
  
    <!-- ******************** CVS ******************** -->
  
    <!-- called with package.name param -->  
    <target name="cvs.get" depends="init"
  	  description="Get a package from CVS " >
      <echo message="Getting ${package.name} from ${cvs.root} to ${ws.dir}/${package.name}" />
      <cvs command="checkout"
  	 cvsRoot="${cvs.root}" 
           package="${package.name}"
  	 dest="${ws.dir}"  />
  
    </target>
  
    <!-- called with package.name param -->  
    <target name="cvs.get.tag" depends="init"
  	  description="Get a package from CVS " >
      <echo message="Getting ${package.name} from ${cvs.root} to ${ws.dir}/${package.name} with ${tag}" />
      <cvs command="checkout"
  	 cvsRoot="${cvs.root}" 
           tag="${tag}"
           package="${package.name}"
  	 dest="${ws.dir}"  />
  
    </target>
  
    <!-- called with package.name param -->  
    <target name="cvs.update" depends="init"
  	  description="Update a package from CVS " >
      <echo message="Getting ${package.name} from ${cvs.root} to ${ws.dir}/${package.name}"  />
  
      <cvs command="update"
  	 cvsRoot="${cvs.root}" 
           package="${package.name}"
  	 dest="${ws.dir}/${package.name}"  />
    </target>
  
  
    <target name="cvsrm" depends="init"
  	  description="Create source zip and tar.gz" >
      <delete dir="${ws.dir}/${package.name}" includes="/CVS" 
              verbose="true" />
    </target>
  
    <target name="src.package" depends="init"
  	  description="Create source zip and tar.gz" >
      <delete file="${pkg.dir}/${arch.name}-src.zip" />
      <delete file="${pkg.dir}/${arch.name}-src.tar.gz" />
  
      <ant antfile="runant.xml" target="zip" >
         <property name="zip.zipfile" value="${pkg.dir}/${arch.name}-src.zip" />
         <property name="zip.basedir" value="${ws.dir}" />
         <property name="zip.includes" value="${package.name}" />
      </ant>
  
      <ant antfile="runant.xml" target="tar" >
        <property name="tar.tarfile" value="${pkg.dir}/${arch.name}-src.tar" />
        <property name="tar.basedir" value="${ws.dir}" />
        <property name="tar.includes" value="${package.name}" />
     </ant>
  
      <gzip zipfile="${pkg.dir}/${arch.name}-src.tar.gz" 
  	  src="${pkg.dir}/${arch.name}-src.tar" />
      <delete file="${pkg.dir}/${arch.name}-src.tar" />
    </target>
   
   
    <!-- Parameters:  package.name -->
    <target name="package.get" 
  	  depends="init" 
  	  description="Get the sources using HTTP, faster" >
      
      <delete dir="${ws.dir}/${arch.name}-src.zip" />
        
      <get src="${package-src.url}/${arch.name}-src.zip" 
  	 dest="${ws.dir}/${arch.name}-src.zip" />
      
      <unzip src="${ws.dir}/${arch.name}-src.zip" 
  	    dest="${ws.dir}" />
      <echo message="Done package" />
    </target>
    
    <target name="ant.get" 
  	  depends="init" >
      <get src="http://jakarta.apache.org/builds/jakarta-ant/release/v1.3/bin/jakarta-ant-1.3-bin.zip" 
  	 dest="${install.dir}/jakarta-ant-1.3-bin.zip" />
      <unzip src="${install.dir}/jakarta-ant-1.3-bin.zip" 
  	    dest="${install.dir}" />
  
    </target>
    
    <target name="crimson.get" 
  	  depends="init" >
      <get src="http://xml.apache.org/dist/crimson/crimson-1.1.zip" 
  	 dest="${install.dir}/crimson-1.1.zip" />
      <unzip src="${install.dir}/crimson-1.1.zip" 
  	    dest="${install.dir}" />
  
    </target>
    
  
    <!-- Parameters:  package.name -->
    <target name="wars.get" 
  	  depends="init" 
  	  description="Get test WARs" >
      
      <get src="${package-src.url}/test.war" 
  	 dest="${pkg.dir}/test.war" />
      <get src="${package-src.url}/jsp-tests.war" 
  	 dest="${pkg.dir}/jsp-tests.war" />
      <get src="${package-src.url}/servlet-tests.war" 
  	 dest="${pkg.dir}/servlet-tests.war" />
  
      <mkdir dir="${tomcat.home}/webapps/test" />
      <mkdir dir="${tomcat.home}/webapps/servlet-tests" />
      <mkdir dir="${tomcat.home}/webapps/jsp-tests" />
      <unzip src="${pkg.dir}/test.war" 
  	    dest="${tomcat.home}/webapps/test" />
      <unzip src="${pkg.dir}/jsp-tests.war" 
  	    dest="${tomcat.home}/webapps/jsp-tests" />
      <unzip src="${pkg.dir}/servlet-tests.war" 
  	    dest="${tomcat.home}/webapps/servlet-tests" />
    </target>
  
  
  
  </project>
  
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntProperty.java
  
  Index: AntProperty.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  import javax.servlet.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import org.apache.tools.ant.*;
  
  import org.apache.tomcat.util.test.*;
  
  /**
   * Child tag to pass ant properties to Ant tag
   * 
   */
  public class AntProperty extends TagSupport {
      
      public AntProperty() {}
  
      public int doStartTag() throws JspException {
  	Tag parent=getParent();
  	if( parent == null  )
  	    throw new JspException( "AntProperty used as top-level tag,"+
  				    "must be inside <ant>");
  	if( ! (parent instanceof AntTag))
  	    throw new JspException( "AntProperty must be child of <ant>");
  
  	AntTag antTag=(AntTag)parent;
  
  	if( value==null && location!= null ) {
  	    // the property will be set with the absolute path
  	    // of the "location", relative to this or another
  	    // (accessible) web application
  	    HttpServletRequest req=(HttpServletRequest)pageContext.
  		getRequest();
  	    ServletContext thisCtx=pageContext.getServletConfig().
  		getServletContext();
  	    ServletContext targetCtx=(webapp==null) ? thisCtx:
  		thisCtx.getContext( webapp );
  	    value=targetCtx.getRealPath(location);
  	}
  
  	
  	if( value == null ) {
  	    // if param is used, try it first ( param!= name )
  	    if( param != null ) {
  		value=pageContext.getRequest().getParameter( param );
  	    } else {
  		value=pageContext.getRequest().getParameter( name );
  	    }
  	}
  
  	if( value != null )
  	    antTag.setProperty( name, value );
  
  	return SKIP_BODY;
      }
  
      //-------------------- Properties --------------------
      String name;
      String value;
      String param;
  
      public void setName( String s ) {
  	name=s;
      }
  
      public void setParam( String s ) {
  	param=s;
      }
  
      public void setValue( String s ) {
  	value=s;
      }
  
      // -------------------- Special properties --------------------
      String location;
      String webapp;
  
      public void setLocation( String s ) {
  	location=s;
      }
  
      /** Set the property with the "base" of the web application
       */
      public void setWebApp( String s ) {
  	webapp=s;
      }
  
  
      // -------------------- From ant --------------------
      
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntServletLogger.java
  
  Index: AntServletLogger.java
  ===================================================================
  package tadm;
  import org.apache.tools.ant.*;
  
  import java.io.*;
  import javax.servlet.http.*;
  
  public class AntServletLogger implements BuildLogger {
      protected java.io.Writer out;
      protected java.io.PrintWriter err;
  
      protected int msgOutputLevel;
  
      private long startTime;
  
      protected static String lSep = System.getProperty("line.separator");
  
      protected boolean emacsMode = false;
  
      public AntServletLogger() {
  	
      }
      
      public void setMessageOutputLevel(int level) {
          this.msgOutputLevel = level;
      }
  
      public void setWriter(java.io.Writer output) {
          this.out = output;
  	this.err = new java.io.PrintWriter(output);
      }
  
      public void setEmacsMode(boolean emacsMode) {
          this.emacsMode = emacsMode;
      }
  
  
      public void setOutputPrintStream(PrintStream output) {
  	System.out.println("What the heck ");
      }
  
      public void setErrorPrintStream(PrintStream err) {
  	System.out.println("What the heck ");     
      }
  
      public void buildStarted(BuildEvent event) {
          startTime = System.currentTimeMillis();
      }
  
      public void buildFinished(BuildEvent event) {
          try {
  	    Throwable error = event.getException();
  	    
  	    if (error == null) {
  		out.write(lSep + "BUILD SUCCESSFUL");
  	    }
  	    else {
  		err.write(lSep + "BUILD FAILED" + lSep);
  		
  		if (error instanceof BuildException) {
  		    err.write(error.toString());
  		    
                  Throwable nested = ((BuildException)error).getException();
                  if (nested != null) {
                      nested.printStackTrace(err);
                  }
  		}
  		else {
  		    error.printStackTrace(err);
  		}
  	    }
  	    
  	    out.write(lSep + "Total time: " +
  		      (System.currentTimeMillis() - startTime));
  	    out.flush();
  	} catch( IOException ex ) {
  	    ex.printStackTrace();
  	}
      }
  
      public void targetStarted(BuildEvent event) {
          try {
  	    out.write("<h3>"+ event.getTarget().getName() + "</h3>");
  	    out.flush();
  	} catch(IOException ex ) {
  	    ex.printStackTrace();
  	}
      }
  
      public void targetFinished(BuildEvent event) {
          try {
  	    out.write("<hr>");
  	    out.flush();
  	} catch(IOException ex ) {
  	    ex.printStackTrace();
  	}
      }
  
      public void taskStarted(BuildEvent event) {
  	
      }
      
      public void taskFinished(BuildEvent event) {
  
      }
  
      public void messageLogged(BuildEvent event) {
          try {
  	    if( event.getPriority() > 2 ) 
  		return;
  
  	    String msg=event.getMessage();
  	    if( msg.indexOf("is deprecated") > 0 )
  		return;
  	    
  	    out.write("\n<br>");
  	    // Print the message
  	    if( msg.startsWith( "ERROR" )) {
  		out.write("<font color='red'>");
  	    }
  	    if( msg.startsWith("GOT" )) {
  		out.write("<pre>");
  	    }
  	    if( msg.startsWith("FAIL" )) {
  		out.write("</pre>");
  	    }
  	    out.write(event.getMessage());
  	    
  	    if( msg.startsWith( "ERROR" )) {
  		out.write("</font>");
  	    }
  	    out.flush();
  	} catch(IOException ex ) {
  	    ex.printStackTrace();
  	}
      }
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntTEI.java
  
  Index: AntTEI.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.File;
  import java.net.URL;
  import javax.servlet.http.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import javax.servlet.jsp.tagext.TagData;
  import javax.servlet.jsp.tagext.TagExtraInfo;
  import javax.servlet.jsp.tagext.VariableInfo;
  
  public class AntTEI extends TagExtraInfo {
  
      public VariableInfo[] getVariableInfo(TagData data) {
  	return (new VariableInfo[] {
  	    new VariableInfo("antProperties",
  			     "java.util.Properties",
  			     true,  VariableInfo.AT_BEGIN),
  	});
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntTag.java
  
  Index: AntTag.java
  ===================================================================
  package tadm;
  import java.util.*;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  import javax.servlet.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import org.apache.tools.ant.*;
  
  /**
   * This tag will run ant tasks
   * 
   */
  public class AntTag extends TagSupport {
      
      public AntTag() {}
  
      public int doStartTag() throws JspException {
  	try {
  	    pageContext.setAttribute("antProperties",
  				     args);
  	} catch (Exception ex ) {
  	    ex.printStackTrace();
  	}
  	return EVAL_BODY_INCLUDE;
      }
  
      public int doEndTag() throws JspException {
  	runTest();
  	return EVAL_PAGE;
      }
  
      // -------------------- child tag support --------------------
      Properties args=new Properties();
      Vector targets=new Vector();
      
      public void setProperty( String name, String value ) {
  	System.out.println("Adding property " + name + "=" + value );
  	args.put(name, value );
      }
  
      public String getProperty( String name ) {
  	System.out.println("Getting property " + name  );
  	return args.getProperty(name );
      }
  
      public void addTarget( String n ) {
  	System.out.println("Adding target " + n );
  	targets.addElement( n );
      }
      
      //-------------------- Properties --------------------
  
      /** Set the name of the test.xml, relative to the base dir.
       *  For example, /WEB-INF/test-tomcat.xml
       */
      public void setTestFile( String s ) {
  	args.put("ant.file", s);
      }
  
      /** Set the target - a subset of tests to be run
       */
      public void setTarget( String s ) {
  	addTarget(s);
      }
  
      public void setDebug( String s ) {
  	args.put( "debug", s);
      }
  
      // -------------------- Implementation methods --------------------
      
      private void runTest() throws JspException {
  	PrintWriter out=null;
  	try {
  	    out=pageContext.getResponse().getWriter();
  	    pageContext.getOut().flush();
  	    out.flush(); // we need a writer for ant
  	    
  	    Project project=new Project();
  	    
  	    AntServletLogger log=new AntServletLogger();
  	    log.setWriter( out );
  	    project.addBuildListener( log );
  	    
  	    project.init();
  
  	    Enumeration argsE=args.propertyNames();
  	    while( argsE.hasMoreElements() ) {
  		String k=(String)argsE.nextElement();
  		String v=args.getProperty( k );
  		if( k!=null && v!= null )
  		    project.setUserProperty( k, v );
  	    }
  
  	    String antFileN=args.getProperty("ant.file");
  	    if( antFileN==null )
  		throw new JspException( "ant.file not specified");
  	    File antF=new File(antFileN);
  	    ProjectHelper.configureProject( project,
  					   antF );
  
  	    // pre-execution properties
  	    Hashtable antProperties=project.getProperties();
  	    argsE=antProperties.keys();
  	    while( argsE.hasMoreElements() ) {
  		String k=(String)argsE.nextElement();
  		String v=(String)antProperties.get( k );
  		if( k!=null && v!= null )
  		    args.put( k, v ); // includes "revision"
  	    }
  	    
  	    if( targets.size()==0 ) {
  		//targets.addElement("client");
  	    }
  
  	    project.executeTargets( targets );
  
  	    // post-execution properties
  	    antProperties=project.getProperties();
  
  	    argsE=antProperties.keys();
  	    while( argsE.hasMoreElements() ) {
  		String k=(String)argsE.nextElement();
  		String v=(String)antProperties.get( k );
  		if( k!=null && v!= null )
  		    args.put( k, v ); 
  	    }
  	    
  	} catch( BuildException ex ) {
  	    if( out==null ) out=new PrintWriter(System.out);
  	    ex.printStackTrace(out);
  	    Throwable ex1=ex.getException();
  	    out.println("Root cause: " );
  	    if( ex1!=null)
  		ex1.printStackTrace(out);
  	    out.flush();
  	    throw new JspException( ex.toString() );
  	} catch( IOException ioex ) {
  	    if( out==null ) out=new PrintWriter(System.out);
  	    ioex.printStackTrace(out);
  	    throw new JspException( ioex.toString() );
  	}
      }
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntTarget.java
  
  Index: AntTarget.java
  ===================================================================
  package tadm;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.io.*;
  import java.net.URL;
  import javax.servlet.http.*;
  import javax.servlet.*;
  
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  
  import org.apache.tools.ant.*;
  import org.apache.tomcat.util.test.*;
  
  /**
   * Child tag to add ant targets to Ant taglib.
   * 
   */
  public class AntTarget extends TagSupport {
      
      public AntTarget() {}
  
      public int doStartTag() throws JspException {
  	Tag parent=getParent();
  	if( parent == null  )
  	    throw new JspException( "AntTarget used as top-level tag,"+
  				    "must be inside <ant>");
  	if( ! (parent instanceof AntTag ))
  	    throw new JspException( "AntTarget must be child of <ant>");
  
  	AntTag antTag=(AntTag)parent;
  	if( name == null ) {
  	    String names[]=pageContext.getRequest().
  		getParameterValues( param );
  	    for( int i=0; i<names.length; i++ ) 
  		antTag.addTarget( names[i]);
  	} else {
  	    antTag.addTarget( name );
  	}
  	return SKIP_BODY;
      }
  
      //-------------------- Properties --------------------
      String name;
      String param;
  
      public void setName( String s ) {
  	name=s;
      }
      public void setParam( String s ) {
  	param=s;
      }
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/build2/ant/tomcat.jsp
  
  Index: tomcat.jsp
  ===================================================================
  <h2>Ant results</h2> 
  <%@ page buffer="none" %>
  <%@ taglib uri="http://jakarta.apache.org/taglibs/ant-1.0" prefix="ant" %>
  
  <ant:ant >
    <ant:target param="target" />
    <ant:property name="ant.file" 
  		location="/WEB-INF/scripts/tomcat.xml" />
    <ant:property name="package.name" param="package.name" />
    <ant:property name="arch.name" param="arch.name" />
    <ant:property name="tag" param="tag" />
  </ant:ant>
  
  
  

Re: cvs commit: jakarta-tomcat/proposals/build2/ant tomcat.jsp

Posted by Casey Lucas <cl...@armassolutions.com>.

duh... too fast to type, too slow to think!  how about move the clears to
the end of doEndTag instead of doStartTag. :)

-casey

Casey Lucas wrote:
> 
> Costin,
> 
> Web based build will be a nice addition -- cool.
> 
> Small comment though.  Keep in mind that I don't have a complete understanding
> of all associated code, but at first glance, it appears that AntTag won't work
> correctly if tag pooling is being used.  I think the fix is simple though.  Just
> reset the list of targets and args at tag start time:
> 
> >   1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntTag.java
> >
> >   Index: AntTag.java
> >   ===================================================================
> >   package tadm;
> >   import java.util.*;
> >   import java.io.*;
> >   import java.net.URL;
> >   import javax.servlet.http.*;
> >   import javax.servlet.*;
> >
> >   import javax.servlet.jsp.*;
> >   import javax.servlet.jsp.tagext.*;
> >
> >   import org.apache.tools.ant.*;
> >
> >   /**
> >    * This tag will run ant tasks
> >    *
> >    */
> >   public class AntTag extends TagSupport {
> >
> >       public AntTag() {}
> >
> >       public int doStartTag() throws JspException {
> 
> add:
> 
> args.clear()
> targets.clear() // or removeAllElements() etc.
> 
> >         try {
> >             pageContext.setAttribute("antProperties",
> >                                      args);
> >         } catch (Exception ex ) {
> >             ex.printStackTrace();
> >         }
> >         return EVAL_BODY_INCLUDE;
> >       }
> >
> >       public int doEndTag() throws JspException {
> >         runTest();
> >         return EVAL_PAGE;
> >       }
> >
> >       // -------------------- child tag support --------------------
> >       Properties args=new Properties();
> >       Vector targets=new Vector();
> >
> >       public void setProperty( String name, String value ) {
> >         System.out.println("Adding property " + name + "=" + value );
> >         args.put(name, value );
> >       }
> >
> >       public String getProperty( String name ) {
> >         System.out.println("Getting property " + name  );
> >         return args.getProperty(name );
> >       }
> >
> >       public void addTarget( String n ) {
> >         System.out.println("Adding target " + n );
> >         targets.addElement( n );
> >       }
> >
> >       //-------------------- Properties --------------------
> >
> >       /** Set the name of the test.xml, relative to the base dir.
> >        *  For example, /WEB-INF/test-tomcat.xml
> >        */
> >       public void setTestFile( String s ) {
> >         args.put("ant.file", s);
> >       }
> >
> >       /** Set the target - a subset of tests to be run
> >        */
> >       public void setTarget( String s ) {
> >         addTarget(s);
> >       }
> >
> >       public void setDebug( String s ) {
> >         args.put( "debug", s);
> >       }
> >
> >       // -------------------- Implementation methods --------------------
> >
> >       private void runTest() throws JspException {
> >         PrintWriter out=null;
> >         try {
> >             out=pageContext.getResponse().getWriter();
> >             pageContext.getOut().flush();
> >             out.flush(); // we need a writer for ant
> >
> >             Project project=new Project();
> >
> >             AntServletLogger log=new AntServletLogger();
> >             log.setWriter( out );
> >             project.addBuildListener( log );
> >
> >             project.init();
> >
> >             Enumeration argsE=args.propertyNames();
> >             while( argsE.hasMoreElements() ) {
> >                 String k=(String)argsE.nextElement();
> >                 String v=args.getProperty( k );
> >                 if( k!=null && v!= null )
> >                     project.setUserProperty( k, v );
> >             }
> >
> >             String antFileN=args.getProperty("ant.file");
> >             if( antFileN==null )
> >                 throw new JspException( "ant.file not specified");
> >             File antF=new File(antFileN);
> >             ProjectHelper.configureProject( project,
> >                                            antF );
> >
> >             // pre-execution properties
> >             Hashtable antProperties=project.getProperties();
> >             argsE=antProperties.keys();
> >             while( argsE.hasMoreElements() ) {
> >                 String k=(String)argsE.nextElement();
> >                 String v=(String)antProperties.get( k );
> >                 if( k!=null && v!= null )
> >                     args.put( k, v ); // includes "revision"
> >             }
> >
> >             if( targets.size()==0 ) {
> >                 //targets.addElement("client");
> >             }
> >
> >             project.executeTargets( targets );
> >
> >             // post-execution properties
> >             antProperties=project.getProperties();
> >
> >             argsE=antProperties.keys();
> >             while( argsE.hasMoreElements() ) {
> >                 String k=(String)argsE.nextElement();
> >                 String v=(String)antProperties.get( k );
> >                 if( k!=null && v!= null )
> >                     args.put( k, v );
> >             }
> >
> >         } catch( BuildException ex ) {
> >             if( out==null ) out=new PrintWriter(System.out);
> >             ex.printStackTrace(out);
> >             Throwable ex1=ex.getException();
> >             out.println("Root cause: " );
> >             if( ex1!=null)
> >                 ex1.printStackTrace(out);
> >             out.flush();
> >             throw new JspException( ex.toString() );
> >         } catch( IOException ioex ) {
> >             if( out==null ) out=new PrintWriter(System.out);
> >             ioex.printStackTrace(out);
> >             throw new JspException( ioex.toString() );
> >         }
> >       }
> >   }
> >

Re: cvs commit: jakarta-tomcat/proposals/build2/ant tomcat.jsp

Posted by Casey Lucas <cl...@armassolutions.com>.
Hey costin,

Sure thing.  We recently moved and have been very busy but I'm starting to
have a little more time (knock on wood).  I should be able to help out with
at least the pooling stuff, so just let me know if you have specific ideas
or need help.

-casey

cmanolache@yahoo.com wrote:
> 
> Hi Casey,
> 
> Sorry, I have too many things for now - the web based build is going to
> wait a bit. If you could check in the changes, great.( I hope you got the
> commit access )
> 
> BTW, I have few ideas for the pooling in jasper34 ( I would like to make
> the pool pluggable, and managed by the container ). Getting the code
> generator to work is first, but I hope in few weeks to finally merge the 2
> runtimes and make the changes, and I hope you can review ( or help
> :-) some of it.
> 
> Costin
> 
> On Sun, 29 Apr 2001, Casey Lucas wrote:
> 
> >
> > Costin,
> >
> > Web based build will be a nice addition -- cool.
> >
> > Small comment though.  Keep in mind that I don't have a complete understanding
> > of all associated code, but at first glance, it appears that AntTag won't work
> > correctly if tag pooling is being used.  I think the fix is simple though.  Just
> > reset the list of targets and args at tag start time:
> >
> >
> > >   1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntTag.java
> > >
> > >   Index: AntTag.java
> > >   ===================================================================
> > >   package tadm;
> > >   import java.util.*;
> > >   import java.io.*;
> > >   import java.net.URL;
> > >   import javax.servlet.http.*;
> > >   import javax.servlet.*;
> > >
> > >   import javax.servlet.jsp.*;
> > >   import javax.servlet.jsp.tagext.*;
> > >
> > >   import org.apache.tools.ant.*;
> > >
> > >   /**
> > >    * This tag will run ant tasks
> > >    *
> > >    */
> > >   public class AntTag extends TagSupport {
> > >
> > >       public AntTag() {}
> > >
> > >       public int doStartTag() throws JspException {
> >
> > add:
> >
> > args.clear()
> > targets.clear() // or removeAllElements() etc.
> >
> >
> > >         try {
> > >             pageContext.setAttribute("antProperties",
> > >                                      args);
> > >         } catch (Exception ex ) {
> > >             ex.printStackTrace();
> > >         }
> > >         return EVAL_BODY_INCLUDE;
> > >       }
> > >
> > >       public int doEndTag() throws JspException {
> > >         runTest();
> > >         return EVAL_PAGE;
> > >       }
> > >
> > >       // -------------------- child tag support --------------------
> > >       Properties args=new Properties();
> > >       Vector targets=new Vector();
> > >
> > >       public void setProperty( String name, String value ) {
> > >         System.out.println("Adding property " + name + "=" + value );
> > >         args.put(name, value );
> > >       }
> > >
> > >       public String getProperty( String name ) {
> > >         System.out.println("Getting property " + name  );
> > >         return args.getProperty(name );
> > >       }
> > >
> > >       public void addTarget( String n ) {
> > >         System.out.println("Adding target " + n );
> > >         targets.addElement( n );
> > >       }
> > >
> > >       //-------------------- Properties --------------------
> > >
> > >       /** Set the name of the test.xml, relative to the base dir.
> > >        *  For example, /WEB-INF/test-tomcat.xml
> > >        */
> > >       public void setTestFile( String s ) {
> > >         args.put("ant.file", s);
> > >       }
> > >
> > >       /** Set the target - a subset of tests to be run
> > >        */
> > >       public void setTarget( String s ) {
> > >         addTarget(s);
> > >       }
> > >
> > >       public void setDebug( String s ) {
> > >         args.put( "debug", s);
> > >       }
> > >
> > >       // -------------------- Implementation methods --------------------
> > >
> > >       private void runTest() throws JspException {
> > >         PrintWriter out=null;
> > >         try {
> > >             out=pageContext.getResponse().getWriter();
> > >             pageContext.getOut().flush();
> > >             out.flush(); // we need a writer for ant
> > >
> > >             Project project=new Project();
> > >
> > >             AntServletLogger log=new AntServletLogger();
> > >             log.setWriter( out );
> > >             project.addBuildListener( log );
> > >
> > >             project.init();
> > >
> > >             Enumeration argsE=args.propertyNames();
> > >             while( argsE.hasMoreElements() ) {
> > >                 String k=(String)argsE.nextElement();
> > >                 String v=args.getProperty( k );
> > >                 if( k!=null && v!= null )
> > >                     project.setUserProperty( k, v );
> > >             }
> > >
> > >             String antFileN=args.getProperty("ant.file");
> > >             if( antFileN==null )
> > >                 throw new JspException( "ant.file not specified");
> > >             File antF=new File(antFileN);
> > >             ProjectHelper.configureProject( project,
> > >                                            antF );
> > >
> > >             // pre-execution properties
> > >             Hashtable antProperties=project.getProperties();
> > >             argsE=antProperties.keys();
> > >             while( argsE.hasMoreElements() ) {
> > >                 String k=(String)argsE.nextElement();
> > >                 String v=(String)antProperties.get( k );
> > >                 if( k!=null && v!= null )
> > >                     args.put( k, v ); // includes "revision"
> > >             }
> > >
> > >             if( targets.size()==0 ) {
> > >                 //targets.addElement("client");
> > >             }
> > >
> > >             project.executeTargets( targets );
> > >
> > >             // post-execution properties
> > >             antProperties=project.getProperties();
> > >
> > >             argsE=antProperties.keys();
> > >             while( argsE.hasMoreElements() ) {
> > >                 String k=(String)argsE.nextElement();
> > >                 String v=(String)antProperties.get( k );
> > >                 if( k!=null && v!= null )
> > >                     args.put( k, v );
> > >             }
> > >
> > >         } catch( BuildException ex ) {
> > >             if( out==null ) out=new PrintWriter(System.out);
> > >             ex.printStackTrace(out);
> > >             Throwable ex1=ex.getException();
> > >             out.println("Root cause: " );
> > >             if( ex1!=null)
> > >                 ex1.printStackTrace(out);
> > >             out.flush();
> > >             throw new JspException( ex.toString() );
> > >         } catch( IOException ioex ) {
> > >             if( out==null ) out=new PrintWriter(System.out);
> > >             ioex.printStackTrace(out);
> > >             throw new JspException( ioex.toString() );
> > >         }
> > >       }
> > >   }
> > >
> >

Re: cvs commit: jakarta-tomcat/proposals/build2/ant tomcat.jsp

Posted by cm...@yahoo.com.
Hi Casey,

Sorry, I have too many things for now - the web based build is going to
wait a bit. If you could check in the changes, great.( I hope you got the
commit access )

BTW, I have few ideas for the pooling in jasper34 ( I would like to make
the pool pluggable, and managed by the container ). Getting the code
generator to work is first, but I hope in few weeks to finally merge the 2
runtimes and make the changes, and I hope you can review ( or help
:-) some of it.

Costin

On Sun, 29 Apr 2001, Casey Lucas wrote:

> 
> Costin,
> 
> Web based build will be a nice addition -- cool.
> 
> Small comment though.  Keep in mind that I don't have a complete understanding
> of all associated code, but at first glance, it appears that AntTag won't work
> correctly if tag pooling is being used.  I think the fix is simple though.  Just
> reset the list of targets and args at tag start time:
> 
> 
> >   1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntTag.java
> > 
> >   Index: AntTag.java
> >   ===================================================================
> >   package tadm;
> >   import java.util.*;
> >   import java.io.*;
> >   import java.net.URL;
> >   import javax.servlet.http.*;
> >   import javax.servlet.*;
> > 
> >   import javax.servlet.jsp.*;
> >   import javax.servlet.jsp.tagext.*;
> > 
> >   import org.apache.tools.ant.*;
> > 
> >   /**
> >    * This tag will run ant tasks
> >    *
> >    */
> >   public class AntTag extends TagSupport {
> > 
> >       public AntTag() {}
> > 
> >       public int doStartTag() throws JspException {
> 
> add:
> 
> args.clear()
> targets.clear() // or removeAllElements() etc.
> 
> 
> >         try {
> >             pageContext.setAttribute("antProperties",
> >                                      args);
> >         } catch (Exception ex ) {
> >             ex.printStackTrace();
> >         }
> >         return EVAL_BODY_INCLUDE;
> >       }
> > 
> >       public int doEndTag() throws JspException {
> >         runTest();
> >         return EVAL_PAGE;
> >       }
> > 
> >       // -------------------- child tag support --------------------
> >       Properties args=new Properties();
> >       Vector targets=new Vector();
> > 
> >       public void setProperty( String name, String value ) {
> >         System.out.println("Adding property " + name + "=" + value );
> >         args.put(name, value );
> >       }
> > 
> >       public String getProperty( String name ) {
> >         System.out.println("Getting property " + name  );
> >         return args.getProperty(name );
> >       }
> > 
> >       public void addTarget( String n ) {
> >         System.out.println("Adding target " + n );
> >         targets.addElement( n );
> >       }
> > 
> >       //-------------------- Properties --------------------
> > 
> >       /** Set the name of the test.xml, relative to the base dir.
> >        *  For example, /WEB-INF/test-tomcat.xml
> >        */
> >       public void setTestFile( String s ) {
> >         args.put("ant.file", s);
> >       }
> > 
> >       /** Set the target - a subset of tests to be run
> >        */
> >       public void setTarget( String s ) {
> >         addTarget(s);
> >       }
> > 
> >       public void setDebug( String s ) {
> >         args.put( "debug", s);
> >       }
> > 
> >       // -------------------- Implementation methods --------------------
> > 
> >       private void runTest() throws JspException {
> >         PrintWriter out=null;
> >         try {
> >             out=pageContext.getResponse().getWriter();
> >             pageContext.getOut().flush();
> >             out.flush(); // we need a writer for ant
> > 
> >             Project project=new Project();
> > 
> >             AntServletLogger log=new AntServletLogger();
> >             log.setWriter( out );
> >             project.addBuildListener( log );
> > 
> >             project.init();
> > 
> >             Enumeration argsE=args.propertyNames();
> >             while( argsE.hasMoreElements() ) {
> >                 String k=(String)argsE.nextElement();
> >                 String v=args.getProperty( k );
> >                 if( k!=null && v!= null )
> >                     project.setUserProperty( k, v );
> >             }
> > 
> >             String antFileN=args.getProperty("ant.file");
> >             if( antFileN==null )
> >                 throw new JspException( "ant.file not specified");
> >             File antF=new File(antFileN);
> >             ProjectHelper.configureProject( project,
> >                                            antF );
> > 
> >             // pre-execution properties
> >             Hashtable antProperties=project.getProperties();
> >             argsE=antProperties.keys();
> >             while( argsE.hasMoreElements() ) {
> >                 String k=(String)argsE.nextElement();
> >                 String v=(String)antProperties.get( k );
> >                 if( k!=null && v!= null )
> >                     args.put( k, v ); // includes "revision"
> >             }
> > 
> >             if( targets.size()==0 ) {
> >                 //targets.addElement("client");
> >             }
> > 
> >             project.executeTargets( targets );
> > 
> >             // post-execution properties
> >             antProperties=project.getProperties();
> > 
> >             argsE=antProperties.keys();
> >             while( argsE.hasMoreElements() ) {
> >                 String k=(String)argsE.nextElement();
> >                 String v=(String)antProperties.get( k );
> >                 if( k!=null && v!= null )
> >                     args.put( k, v );
> >             }
> > 
> >         } catch( BuildException ex ) {
> >             if( out==null ) out=new PrintWriter(System.out);
> >             ex.printStackTrace(out);
> >             Throwable ex1=ex.getException();
> >             out.println("Root cause: " );
> >             if( ex1!=null)
> >                 ex1.printStackTrace(out);
> >             out.flush();
> >             throw new JspException( ex.toString() );
> >         } catch( IOException ioex ) {
> >             if( out==null ) out=new PrintWriter(System.out);
> >             ioex.printStackTrace(out);
> >             throw new JspException( ioex.toString() );
> >         }
> >       }
> >   }
> >
> 


Re: cvs commit: jakarta-tomcat/proposals/build2/ant tomcat.jsp

Posted by Casey Lucas <cl...@armassolutions.com>.
Costin,

Web based build will be a nice addition -- cool.

Small comment though.  Keep in mind that I don't have a complete understanding
of all associated code, but at first glance, it appears that AntTag won't work
correctly if tag pooling is being used.  I think the fix is simple though.  Just
reset the list of targets and args at tag start time:


>   1.1                  jakarta-tomcat/proposals/build2/WEB-INF/src/AntTag.java
> 
>   Index: AntTag.java
>   ===================================================================
>   package tadm;
>   import java.util.*;
>   import java.io.*;
>   import java.net.URL;
>   import javax.servlet.http.*;
>   import javax.servlet.*;
> 
>   import javax.servlet.jsp.*;
>   import javax.servlet.jsp.tagext.*;
> 
>   import org.apache.tools.ant.*;
> 
>   /**
>    * This tag will run ant tasks
>    *
>    */
>   public class AntTag extends TagSupport {
> 
>       public AntTag() {}
> 
>       public int doStartTag() throws JspException {

add:

args.clear()
targets.clear() // or removeAllElements() etc.


>         try {
>             pageContext.setAttribute("antProperties",
>                                      args);
>         } catch (Exception ex ) {
>             ex.printStackTrace();
>         }
>         return EVAL_BODY_INCLUDE;
>       }
> 
>       public int doEndTag() throws JspException {
>         runTest();
>         return EVAL_PAGE;
>       }
> 
>       // -------------------- child tag support --------------------
>       Properties args=new Properties();
>       Vector targets=new Vector();
> 
>       public void setProperty( String name, String value ) {
>         System.out.println("Adding property " + name + "=" + value );
>         args.put(name, value );
>       }
> 
>       public String getProperty( String name ) {
>         System.out.println("Getting property " + name  );
>         return args.getProperty(name );
>       }
> 
>       public void addTarget( String n ) {
>         System.out.println("Adding target " + n );
>         targets.addElement( n );
>       }
> 
>       //-------------------- Properties --------------------
> 
>       /** Set the name of the test.xml, relative to the base dir.
>        *  For example, /WEB-INF/test-tomcat.xml
>        */
>       public void setTestFile( String s ) {
>         args.put("ant.file", s);
>       }
> 
>       /** Set the target - a subset of tests to be run
>        */
>       public void setTarget( String s ) {
>         addTarget(s);
>       }
> 
>       public void setDebug( String s ) {
>         args.put( "debug", s);
>       }
> 
>       // -------------------- Implementation methods --------------------
> 
>       private void runTest() throws JspException {
>         PrintWriter out=null;
>         try {
>             out=pageContext.getResponse().getWriter();
>             pageContext.getOut().flush();
>             out.flush(); // we need a writer for ant
> 
>             Project project=new Project();
> 
>             AntServletLogger log=new AntServletLogger();
>             log.setWriter( out );
>             project.addBuildListener( log );
> 
>             project.init();
> 
>             Enumeration argsE=args.propertyNames();
>             while( argsE.hasMoreElements() ) {
>                 String k=(String)argsE.nextElement();
>                 String v=args.getProperty( k );
>                 if( k!=null && v!= null )
>                     project.setUserProperty( k, v );
>             }
> 
>             String antFileN=args.getProperty("ant.file");
>             if( antFileN==null )
>                 throw new JspException( "ant.file not specified");
>             File antF=new File(antFileN);
>             ProjectHelper.configureProject( project,
>                                            antF );
> 
>             // pre-execution properties
>             Hashtable antProperties=project.getProperties();
>             argsE=antProperties.keys();
>             while( argsE.hasMoreElements() ) {
>                 String k=(String)argsE.nextElement();
>                 String v=(String)antProperties.get( k );
>                 if( k!=null && v!= null )
>                     args.put( k, v ); // includes "revision"
>             }
> 
>             if( targets.size()==0 ) {
>                 //targets.addElement("client");
>             }
> 
>             project.executeTargets( targets );
> 
>             // post-execution properties
>             antProperties=project.getProperties();
> 
>             argsE=antProperties.keys();
>             while( argsE.hasMoreElements() ) {
>                 String k=(String)argsE.nextElement();
>                 String v=(String)antProperties.get( k );
>                 if( k!=null && v!= null )
>                     args.put( k, v );
>             }
> 
>         } catch( BuildException ex ) {
>             if( out==null ) out=new PrintWriter(System.out);
>             ex.printStackTrace(out);
>             Throwable ex1=ex.getException();
>             out.println("Root cause: " );
>             if( ex1!=null)
>                 ex1.printStackTrace(out);
>             out.flush();
>             throw new JspException( ex.toString() );
>         } catch( IOException ioex ) {
>             if( out==null ) out=new PrintWriter(System.out);
>             ioex.printStackTrace(out);
>             throw new JspException( ioex.toString() );
>         }
>       }
>   }
>