vmassol     01/07/05 05:11:33

  Modified:    cactus/build build-servletapi.xml build.xml
  Added:       cactus/src/ant/org/apache/commons/cactus/ant
                        ArgListProperty.java ArgListTask.java
  Log:
  refactored Ant build porition for running the functional tests by writing a custom 
Ant task (the reason was also because it seemed it was not running correctly on unix 
systems as was evidenced by the GUMP nightly build failure)
  
  Revision  Changes    Path
  1.14      +30 -107   jakarta-commons/cactus/build/build-servletapi.xml
  
  Index: build-servletapi.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cactus/build/build-servletapi.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- build-servletapi.xml      2001/06/30 16:48:45     1.13
  +++ build-servletapi.xml      2001/07/05 12:11:29     1.14
  @@ -162,6 +162,17 @@
                These files do not need to be redistributed to end-users. It is
                only needed to put the javadoc online to the Cactus web site. -->
           <property name="dist.javadoc.name" 
value="${out.root.dir}/${javadoc.name}-${DSTAMP}"/>
  +
  +        <!-- Custom Ant task definition used in the test targets below.
  +             It is used for computing the "-D" parameter list
  +             for home directories of defined servlet engines. If a given
  +             property is not defined, it won't be added to the list -->
  +        <taskdef name="argsList" 
classname="org.apache.commons.cactus.ant.ArgListTask">
  +            <classpath>
  +                <pathelement location="${final.jar.ant.name}"/>
  +                <pathelement path="${java.class.path}"/>
  +            </classpath>
  +        </taskdef>
                 
       </target>
   
  @@ -527,67 +538,17 @@
            Run the functional tests
          ========================================================================
       -->
  -    <target name="tests-functional22-resin12-if" if="resin.home.12">
  -        <property name="resin.flag.12" value="-Dresin.home.12=${resin.home.12}"/>
  -    </target>
  -    <target name="tests-functional22-resin12-else" unless="resin.home.12">
  -        <property name="resin.flag.12" value=""/>
  -    </target>
  -    <target name="tests-functional22-resin20-if" if="resin.home.20">
  -        <property name="resin.flag.20" value="-Dresin.home.20=${resin.home.20}"/>
  -    </target>
  -    <target name="tests-functional22-resin20-else" unless="resin.home.20">
  -        <property name="resin.flag.20" value=""/>
  -    </target>
  -    <target name="tests-functional22-tomcat32-if" if="tomcat.home.32">
  -        <property name="tomcat.flag.32" value="-Dtomcat.home.32=${tomcat.home.32}"/>
  -    </target>
  -    <target name="tests-functional22-tomcat32-else" unless="tomcat.home.32">
  -        <property name="tomcat.flag.32" value=""/>
  -    </target>
  -    <target name="tests-functional22-tomcat33-if" if="tomcat.home.33">
  -        <property name="tomcat.flag.33" value="-Dtomcat.home.33=${tomcat.home.33}"/>
  -    </target>
  -    <target name="tests-functional22-tomcat33-else" unless="tomcat.home.33">
  -        <property name="tomcat.flag.33" value=""/>
  -    </target>
  -    <target name="tests-functional22-orion14-if" if="orion.home.14">
  -        <property name="orion.flag.14" value="-Dorion.home.14=${orion.home.14}"/>
  -    </target>
  -    <target name="tests-functional22-orion14-else" unless="orion.home.14">
  -        <property name="orion.flag.14" value=""/>
  -    </target>
  -    <target name="tests-functional22-weblogic51-if" if="weblogic.home.51">
  -        <property name="weblogic.flag.51" 
value="-Dweblogic.home.51=${weblogic.home.51}"/>
  -    </target>
  -    <target name="tests-functional22-weblogic51-else" unless="weblogic.home.51">
  -        <property name="weblogic.flag.51" value=""/>
  -    </target>
  -    <target name="tests-functional22-enhydra31-if" if="enhydra.home.31">
  -        <property name="enhydra.flag.31" 
value="-Denhydra.home.31=${enhydra.home.31}"/>
  -    </target>
  -    <target name="tests-functional22-enhydra31-else" unless="enhydra.home.31">
  -        <property name="enhydra.flag.31" value=""/>
  -    </target>
  +    <target name="tests-functional22" depends="sample">
   
  -    <target name="tests-functional22-checks"
  -        depends="tests-functional22-resin12-if,
  -                 tests-functional22-resin12-else,
  -                 tests-functional22-resin20-if,
  -                 tests-functional22-resin20-else,
  -                 tests-functional22-tomcat32-if,
  -                 tests-functional22-tomcat32-else,
  -                 tests-functional22-tomcat33-if,
  -                 tests-functional22-tomcat33-else,
  -                 tests-functional22-orion14-if,
  -                 tests-functional22-orion14-else,
  -                 tests-functional22-weblogic51-if,
  -                 tests-functional22-weblogic51-else,
  -                 tests-functional22-enhydra31-if,
  -                 tests-functional22-enhydra31-else">
  -    </target>
  -
  -    <target name="tests-functional22" depends="sample,tests-functional22-checks">
  +        <argsList property="test22.args.list">
  +            <property name="resin.home.12"/>
  +            <property name="resin.home.20"/>
  +            <property name="tomcat.home.32"/>
  +            <property name="tomcat.home.33"/>
  +            <property name="orion.home.14"/>
  +            <property name="weblogic.home.51"/>
  +            <property name="enhydra.home.31"/>
  +        </argsList>
   
           <java classname="org.apache.tools.ant.Main"
               dir="${out.sample.build.dir}" fork="yes" failonerror="yes">
  @@ -600,13 +561,7 @@
               <arg value="-Dlog4j.jar=${log4j.jar}"/>
   
               <!-- Pass all servlet engine properties -->
  -            <arg value="${resin.flag.12}"/>
  -            <arg value="${resin.flag.20}"/>
  -            <arg value="${tomcat.flag.32}"/>
  -            <arg value="${tomcat.flag.33}"/>
  -            <arg value="${orion.flag.14}"/>
  -            <arg value="${weblogic.flag.51}"/>
  -            <arg value="${enhydra.flag.31}"/>
  +            <arg line="${test22.args.list}"/>
               <arg value="tests_all"/>
   
               <classpath>            
  @@ -616,44 +571,15 @@
           </java>
           
       </target>
  -
  -    <target name="tests-functional23-resin13-if" if="resin.home.13">
  -        <property name="resin.flag.13" value="-Dresin.home.13=${resin.home.13}"/>
  -    </target>
  -    <target name="tests-functional23-resin13-else" unless="resin.home.13">
  -        <property name="resin.flag.13" value=""/>
  -    </target>
  -    <target name="tests-functional23-resin20-if" if="resin.home.20">
  -        <property name="resin.flag.20" value="-Dresin.home.20=${resin.home.20}"/>
  -    </target>
  -    <target name="tests-functional23-resin20-else" unless="resin.home.20">
  -        <property name="resin.flag.20" value=""/>
  -    </target>
  -    <target name="tests-functional23-tomcat40-if" if="tomcat.home.40">
  -        <property name="tomcat.flag.40" value="-Dtomcat.home.40=${tomcat.home.40}"/>
  -    </target>
  -    <target name="tests-functional23-tomcat40-else" unless="tomcat.home.40">
  -        <property name="tomcat.flag.40" value=""/>
  -    </target>
  -    <target name="tests-functional23-orion14-if" if="orion.home.14">
  -        <property name="orion.flag.14" value="-Dorion.home.14=${orion.home.14}"/>
  -    </target>
  -    <target name="tests-functional23-orion14-else" unless="orion.home.14">
  -        <property name="orion.flag.14" value=""/>
  -    </target>
   
  -    <target name="tests-functional23-checks"
  -        depends="tests-functional23-resin13-if,
  -                 tests-functional23-resin13-else,
  -                 tests-functional23-resin20-if,
  -                 tests-functional23-resin20-else,
  -                 tests-functional23-orion14-if,
  -                 tests-functional23-orion14-else,
  -                 tests-functional23-tomcat40-if,
  -                 tests-functional23-tomcat40-else">
  -    </target>
  +    <target name="tests-functional23" depends="sample">
   
  -    <target name="tests-functional23" depends="sample,tests-functional23-checks">
  +        <argsList property="test23.args.list">
  +            <property name="resin.home.13"/>
  +            <property name="resin.home.20"/>
  +            <property name="tomcat.home.40"/>
  +            <property name="orion.home.14"/>
  +        </argsList>
   
           <java classname="org.apache.tools.ant.Main"
               dir="${out.sample.build.dir}" fork="yes" failonerror="yes">
  @@ -666,10 +592,7 @@
               <arg value="-Dlog4j.jar=${log4j.jar}"/>
   
               <!-- Pass all servlet engine properties -->
  -            <arg value="${resin.flag.13}"/>
  -            <arg value="${resin.flag.20}"/>
  -            <arg value="${orion.flag.14}"/>
  -            <arg value="${tomcat.flag.40}"/>
  +            <arg line="${test23.args.list}"/>
               <arg value="tests_all"/>
   
               <classpath>            
  
  
  
  1.17      +4 -1      jakarta-commons/cactus/build/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cactus/build/build.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- build.xml 2001/06/26 16:29:03     1.16
  +++ build.xml 2001/07/05 12:11:30     1.17
  @@ -287,7 +287,7 @@
           </ant>        
       </target>
   
  -    <target name="jar" depends="jar.22,jar.23">
  +    <target name="jar.ant" depends="init">
   
           <!-- Copy source files to apply tokens -->
           <mkdir dir="${out.src.ant.dir}"/>
  @@ -319,6 +319,9 @@
           <jar jarfile="${final.jar.ant.name}" basedir="${out.classes.ant.dir}"
               manifest="${out.conf.ant.dir}/manifest"/>
   
  +    </target>
  +
  +    <target name="jar" depends="jar.ant,jar.22,jar.23">
       </target>
   
       <!-- 
  
  
  
  1.1                  
jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/ArgListProperty.java
  
  Index: ArgListProperty.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.cactus.ant;
  
  import java.io.*;
  import java.util.*;
  import java.text.*;
  import java.net.*;
  
  import org.apache.tools.ant.*;
  import org.apache.tools.ant.taskdefs.*;
  import org.apache.tools.ant.types.*;
  
  /**
   * Placeholder for properties to check
   */
  public class ArgListProperty
  {
      private String m_Name;
  
      public void setName(String theName)
      {
          m_Name = theName;
      }
  
      public String getName()
      {
          return m_Name;
      }
  }
  
  
  1.1                  
jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/ArgListTask.java
  
  Index: ArgListTask.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.commons.cactus.ant;
  
  import java.io.*;
  import java.util.*;
  import java.text.*;
  import java.net.*;
  
  import org.apache.tools.ant.*;
  import org.apache.tools.ant.taskdefs.*;
  import org.apache.tools.ant.types.*;
  
  /**
   * Compute a string (returned as an Ant property) that contains a list of
   * args (in the format [-Dname=value]*) that can be used on a java command line.
   *
   * Example :<br>
   * <pre><code>
   * <property name="property1" value="value1"/>
   * <property name="property3" value="value3"/>
   *
   * <argList property="result">
   *   <property name="property1"/>
   *   <property name="property2"/>
   *   <property name="property3"/>
    * </argList>
   *
   * <echo message="${result}"/>
   * </code></pre>
   * <br>
   * will print "<code>-Dproperty1=value1 -Dproperty3=value3</code>".
   *
   * @version @version@
   */
  public class ArgListTask extends Task
  {
      /**
       * List of Ant properties to check for inclusing in the arg list
       */
      private Vector m_Properties = new Vector();
  
      /**
       * Name of Ant property that will be set and which will contain the arg
       * list
       */
      private String m_NewProperty;
  
      /**
       * Add a new property to the list of properties to check
       */
      public void addProperty(ArgListProperty theProperty)
      {
          m_Properties.addElement(theProperty);
      }
  
      /**
       * Set the name of the new Ant property that will contain the arg list.
       */
      public void setProperty(String theNewProperty)
      {
          m_NewProperty = theNewProperty;
      }
  
      /**
       * Execute task. Check all specified Ant properties for existence and if
       * they exist add them to the arg list ("-Dname=value" format).
       */
      public void execute() throws BuildException
      {
          StringBuffer argBuffer = new StringBuffer();
          boolean isEmpty = true;
  
          // Build the arg list ("-D" separated string).
          Enumeration args = m_Properties.elements();
          while (args.hasMoreElements()) {
  
              String propertyName = ((ArgListProperty)args.nextElement()).getName();
  
              // Check if this property is defined
              String value = getProject().getProperty(propertyName);
              if (value == null) {
                  value = getProject().getUserProperty(propertyName);
                  if (value == null) {
                      continue;
                  }
              }
  
              // Yes, add the property the list of args
              if (isEmpty) {
                  argBuffer.append("-D" + propertyName + "=" + value);
                  isEmpty = false;
              } else {
                  argBuffer.append(" -D" + propertyName + "=" + value);
              }
          }
  
          // Set the new property
          getProject().setProperty(m_NewProperty, argBuffer.toString());
      }
  
  }
  
  
  

Reply via email to