Author: jsong
Date: Mon Aug  9 13:27:02 2004
New Revision: 36129

Added:
   incubator/beehive/trunk/controls/test/tools/mantis/
   incubator/beehive/trunk/controls/test/tools/mantis/README
   incubator/beehive/trunk/controls/test/tools/mantis/build.xml
   incubator/beehive/trunk/controls/test/tools/mantis/config/
   incubator/beehive/trunk/controls/test/tools/mantis/config/mantis.properties
   incubator/beehive/trunk/controls/test/tools/mantis/lib/
   incubator/beehive/trunk/controls/test/tools/mantis/lib/tchschema.jar   
(contents, props changed)
   incubator/beehive/trunk/controls/test/tools/mantis/lib/xbean-1.0.2.jar   
(contents, props changed)
   incubator/beehive/trunk/controls/test/tools/mantis/mantis.xml
   incubator/beehive/trunk/controls/test/tools/mantis/src/
   incubator/beehive/trunk/controls/test/tools/mantis/src/org/
   incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/
   incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/AbstractMantisProcessor.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/MantisFactory.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/MantisTask.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/TchProcessor.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Desc.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Freq.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/FreqVals.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Misc.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Status.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/StatusVals.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/test/
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/test/CheckinTest.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/test/DetailedTest.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/utils/
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/utils/FileTypes.java
   
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/utils/MantisFileInfo.java
Modified:
   incubator/beehive/trunk/controls/test/tools/tch/setenv.sh
Log:
Contributed by Jamie Zyskowski: an extensible annotation processor framework. 
Currently supports creating tch xml files from annotated junit source

Added: incubator/beehive/trunk/controls/test/tools/mantis/README
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/mantis/README   Mon Aug  9 
13:27:02 2004
@@ -0,0 +1,27 @@
+#####################################
+MANTIS ANNOTATION PROCESSOR FRAMEWORK
+#####################################
+
+Mantis is an annotation processor framework invoked by APT. It's purpose is to 
provide
+an extensible framwwork for annotations and corresponding processors. It 
currently has one 
+built-in processor that will generate TCH (Test Case Harness) test xml files
+based on annotated junit source code. 
+
+#############
+EXTENSIBILITY
+#############
+Mantis is extensible. To write your own
+mantis processor, simply extend AbstractMantisProcessor.java. Mantis processors
+are required to "play nice" with other mantis processors. Any files a processor
+creates must be "registered" so they are available to other processors. In 
this way, 
+processors can be used by other processors, by themselves, or in a chain. Once
+you have your own mantis processor, you can add an entry to mantis' 
configuation
+file (mantis.properties), which maps annotation package names to the processor
+class. Only one processor is allowed per annotation package. In the future, 
mantis
+will support the creation of junit source code based on an annotated class. 
+
+#####
+USAGE
+#####
+Please refer to the javadocs:
+ant doc

Added: incubator/beehive/trunk/controls/test/tools/mantis/build.xml
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/mantis/build.xml        Mon Aug 
 9 13:27:02 2004
@@ -0,0 +1,115 @@
+<!-- build file -->
+<project name="mantis-build" default="usage">
+
+       <target name="usage">
+               <echo>
+Usage:
+[re]build - [re]builds mantis and mantis tests
+redeploy - rebuild mantis, mantis tests, and then the mantis.jar
+clean - delete mantis build and mantis tests
+deploy - builds the mantis.jar into the deploy dir
+drt - calls "ant -f mantis.xml drt"
+doc - generate javadoc documentation
+tch.schema.build - utility target that rebuilds the xbean schema jar for tch's 
schema
+               </echo>
+       </target>
+
+       <!-- load up shared beehive properties -->
+       <property environment="os"/>
+       <property file="${os.BEEHIVE_HOME}/beehive.properties"/>
+       <property 
file="${os.BEEHIVE_HOME}/controls/test/common/path.properties"/>
+
+       <!-- mantis properties -->      
+       <property name="mantis.root" value="${basedir}"/>
+       <property name="src.dir" value="${mantis.root}/src"/>
+       <property name="build.dir" value="${mantis.root}/build"/>
+       <property name="deploy.dir" value="${mantis.root}/deploy"/>
+       <property name="doc.dir" value="${mantis.root}/build/doc"/>
+       <property name="temp.dir" value="${mantis.root}/temp"/>
+       <property name="lib.dir" value="${mantis.root}/lib"/>
+       <property name="mantis.jar" value="${deploy.dir}/mantis.jar"/>
+       <property name="tchschema.jar" value="${lib.dir}/tchschema.jar"/>
+       <property name="mantis.xbean.jar" value="${lib.dir}/xbean-1.0.2.jar"/>
+
+       <!--************-->
+       <!-- CLASSPATHS -->
+       <!--************-->
+       <path id="classpath">
+               <pathelement path="${tchschema.jar}"/>
+               <pathelement path="${mantis.xbean.jar}"/>
+               <pathelement path="${ant.jar}"/>
+               <pathelement path="${junit.jar}"/>
+               <pathelement path="${tools.jar}"/>
+       </path>
+
+       <!--************************-->
+       <!-- TCH SCHEMA COMPILATION -->
+       <!--************************-->
+       <target name="tch.schema.build" >
+               <delete dir="${temp.dir}"/>
+               <mkdir dir="${temp.dir}"/>
+               <delete file="${tchschema.jar}"/>
+               <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler"
+                                       fork="true"
+                                       dir="${mantis.root}"
+                                       classpathref="classpath">
+                       <arg line="-out ${tchschema.jar}"/>
+                       <arg line="-d ${temp.dir}"/>
+                       <arg line="${tch.home}/schema/everything-suite.xsd"/>
+               </java>
+               <delete dir="${temp.dir}"/>
+       </target>
+
+       <!--***************-->
+       <!-- BUILD TARGETS -->                          
+       <!--***************-->
+       <target name="doc">
+               <delete dir="${doc.dir}"/>
+               <mkdir dir="${doc.dir}"/>
+               <javadoc
+                       sourcepath="${src.dir}"
+                       destdir="${doc.dir}"
+                       source="1.5"
+                       packagenames="org.apache.beehive.mantis.*"
+                       classpathref="classpath"
+               />
+       </target>
+
+       <target name="build">
+               <mkdir dir="${build.dir}"/>
+               <javac srcdir="${src.dir}"
+                       destdir="${build.dir}"
+                       debug="on"
+                       fork="yes"
+                       memoryMaximumSize="1000M"
+                       compiler="modern"
+                       executable="${os.JAVA_HOME}/bin/javac"
+                       classpathref="classpath"
+                       source="1.5">
+               </javac>
+       </target>
+
+       <target name="deploy">
+               <delete dir="${deploy.dir}"/>
+               <mkdir dir="${deploy.dir}"/>
+               <jar destfile="${mantis.jar}"
+                                basedir="${build.dir}"
+                                excludes="**/test/**"/>
+       </target>
+
+       <target name="clean">
+               <delete dir="${build.dir}"/>
+               <delete dir="${deploy.dir}"/>
+       </target>
+
+       <target name="rebuild" depends="clean,build"/>
+       <target name="redeploy" depends="rebuild,deploy"/>
+
+       <!--*****-->
+       <!-- DRT -->
+       <!--*****-->
+       <target name="drt">
+               <ant antfile="${mantis.root}/mantis.xml" target="drt"/>
+       </target>
+
+</project>

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/config/mantis.properties
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/mantis/config/mantis.properties 
Mon Aug  9 13:27:02 2004
@@ -0,0 +1 @@
+org.apache.beehive.mantis.annotations.tch=org.apache.beehive.mantis.TchProcessor

Added: incubator/beehive/trunk/controls/test/tools/mantis/lib/tchschema.jar
==============================================================================
Binary file. No diff available.

Added: incubator/beehive/trunk/controls/test/tools/mantis/lib/xbean-1.0.2.jar
==============================================================================
Binary file. No diff available.

Added: incubator/beehive/trunk/controls/test/tools/mantis/mantis.xml
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/mantis/mantis.xml       Mon Aug 
 9 13:27:02 2004
@@ -0,0 +1,97 @@
+<project name="mantis-run" default="usage">
+
+       <target name="usage">
+               <echo>
+Usage:
+run.mantis - runs mantis with it's built-in tch processor over test src
+run.tch - runs tch with the mantis-generated tch test files
+               </echo>
+       </target>
+
+       <!-- load up shared beehive properties -->
+       <property environment="os"/>
+       <property file="${os.BEEHIVE_HOME}/beehive.properties"/>
+       <property 
file="${os.BEEHIVE_HOME}/controls/test/common/path.properties"/>
+
+       <!-- mantis properties -->      
+       <property name="mantis.root" value="${basedir}"/>
+       <property name="mantis.jar" value="${mantis.root}/deploy/mantis.jar"/>
+       <property name="src.dir" value="${mantis.root}/src"/>
+       <property name="mantis.build.dir" value="${mantis.root}/build"/>
+       <property name="mantis.srcgen.dir" value="${mantis.root}/srcgen"/>
+       <property name="mantis.bingen.dir" value="${mantis.root}/bingen"/>
+       <property name="mantis.log.dir" value="${mantis.root}/log"/>
+       <property name="mantis.config" 
value="${mantis.root}/config/mantis.properties"/>
+       <property name="lib.dir" value="${mantis.root}/lib"/>
+       <property name="tchschema.jar" value="${lib.dir}/tchschema.jar"/>
+       <property name="mantis.xbean.jar" value="${lib.dir}/xbean-1.0.2.jar"/>
+
+       <!--************-->
+       <!-- CLASSPATHS -->
+       <!--************-->
+       <path id="mantis.run.classpath">
+               <pathelement path="${mantis.jar}"/>
+               <pathelement path="${tchschema.jar}"/>
+               <pathelement path="${mantis.xbean.jar}"/>
+               <pathelement path="${ant.jar}"/>
+               <pathelement path="${junit.jar}"/>
+       </path>
+
+       <path id="tch.run.classpath">
+               <pathelement path="${mantis.build.dir}"/>
+               <pathelement path="${junit.jar}"/>
+               <pathelement path="${tch.jar}"/>
+               <pathelement path="${ant.jar}"/>
+               <pathelement path="${ant.home}/lib/ant-launcher.jar"/>
+               <pathelement path="${jakarta.jar}"/>
+               <pathelement path="${xerces.jar}"/>
+       </path>
+
+       <!--********-->
+       <!-- MANTIS -->
+       <!--********-->
+       <taskdef name="mantis" classname="org.apache.beehive.mantis.MantisTask" 
classpathref="mantis.run.classpath"/>
+       <property name="mantis.run.classpath" refid="mantis.run.classpath"/>
+       <target name="run.mantis">
+               <delete dir="${mantis.srcgen.dir}"/>
+               <delete dir="${mantis.bingen.dir}"/>
+               <mantis srcdir="${src.dir}"
+                                               includes="**/test/**.java"
+                                               srcgen="${mantis.srcgen.dir}"
+                                               bingen="${mantis.bingen.dir}"
+                                               
classpath="${mantis.run.classpath}"
+                                               logdir="${mantis.log.dir}"
+                                               config="${mantis.config}"
+                                               
aptcommand="${os.JAVA_HOME}/bin/apt"
+               />
+       </target>
+
+
+       <!--**************-->
+       <!-- TCH TARGETS  -->
+       <!--**************-->
+       <taskdef name="tch" 
classname="org.apache.beehive.test.tools.tch.TchVMTask" 
classpathref="tch.run.classpath"/> 
+       <target name="run.tch">
+               <tch
+                       classpathref="tch.run.classpath"
+                       testfile="${mantis.srcgen.dir}/root.xml"
+                       tchHome="${tch.home}"
+                       failOnError="true"
+                       failureproperty="run.failed"
+                       fork="true">
+                       <arg value="-emacs"/>
+                       <property name="tch.log.date-format" value=""/>
+                       <property name="tch.log.debug-level" value="0"/>
+                       <property name="tch.replication.entry-point" value="ant 
-f ${mantis.root}/mantis.xml run.tch"/>
+               </tch>
+               <echo message="MANTIS EXPECTED RESULT FOR TCH RUN: Total 3, 
Pass 1, Fail 2"/>
+               <fail if="run.failed" message="The test run had one or more 
test failures"/>
+       </target>
+       
+       <!--*****-->
+       <!-- DRT -->
+       <!--*****-->
+       <target name="drt" depends="run.mantis,run.tch"/>
+
+
+</project>

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/AbstractMantisProcessor.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/AbstractMantisProcessor.java
       Mon Aug  9 13:27:02 2004
@@ -0,0 +1,74 @@
+package org.apache.beehive.mantis;
+
+// mirror apis
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.apt.Filer;
+import com.sun.mirror.declaration.PackageDeclaration;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
+import com.sun.mirror.declaration.AnnotationValue;
+import com.sun.mirror.declaration.TypeDeclaration;
+import com.sun.mirror.declaration.ClassDeclaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.AnnotationMirror;
+
+// java utils
+import java.io.PrintWriter;
+import java.io.IOException;
+import java.io.File;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.ArrayList;
+
+// mantis annotations
+//import org.apache.beehive.mantis.annotations.*;
+
+import org.apache.beehive.mantis.utils.FileTypes;
+import org.apache.beehive.mantis.utils.MantisFileInfo;
+
+// tch schema types
+//import org.apache.xmlbeans.XmlAnySimpleType;
+//import org.apache.xmlbeans.XmlAnySimpleType.Factory;
+//import noNamespace.ProjectDocument.*;
+//import noNamespace.*;
+
+public abstract class AbstractMantisProcessor implements AnnotationProcessor
+{
+  private HashSet<MantisFileInfo> _fileinfos;
+  protected Set<AnnotationTypeDeclaration> _atds;
+  protected AnnotationProcessorEnvironment _env;
+  protected String _srctree;
+  protected String _classtree;
+
+  abstract public void process();
+
+  public void init(Set<AnnotationTypeDeclaration> p_atds,
+                   AnnotationProcessorEnvironment p_env)
+  {
+    this._atds = p_atds;
+    this._env = p_env;
+    _fileinfos = new HashSet<MantisFileInfo>();
+
+    // initialize the file gen dir strings
+    Map<String,String> opts = _env.getOptions();
+    _srctree = opts.get("-s");
+    _classtree = opts.get("-d");
+  }
+
+  protected void registerFile(String url, String creatingClassname, FileTypes 
type)
+  {
+    MantisFileInfo finfo = new MantisFileInfo(url,
+                                              creatingClassname,
+                                              type);
+    _fileinfos.add(finfo);
+  } 
+
+  public HashSet<MantisFileInfo> getFileInfo()
+  {
+    return _fileinfos;
+  }
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/MantisFactory.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/MantisFactory.java
 Mon Aug  9 13:27:02 2004
@@ -0,0 +1,203 @@
+package org.apache.beehive.mantis;
+
+import com.sun.mirror.apt.*;
+import com.sun.mirror.declaration.*;
+import com.sun.mirror.type.*;
+import com.sun.mirror.util.*;
+
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.lang.StringBuffer;
+import java.lang.ClassNotFoundException;
+import java.lang.InstantiationException;
+import java.lang.IllegalAccessException;
+import java.util.Collection;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+import static java.util.Collections.*;
+
+
+public class MantisFactory implements AnnotationProcessorFactory
+{
+  // map of annotation package to processor name
+  private HashMap<String,String> _processorMap;
+
+  // claim that all annotations are handled by this factory
+  // at runtime the mantis config is loaded in getProcessorFor()
+  private static final Collection<String> _supportedAnnotations
+    = unmodifiableCollection(Arrays.asList("*"));
+
+  // options passed to apt at runtime
+  private Map<String,String> _options;
+
+  // options that are supported
+  private final Collection<String> _supportedOptions;
+
+
+  public MantisFactory()
+  {
+    this._supportedOptions = initSupportedOptions();
+  }
+
+
+  public Collection<String> supportedAnnotationTypes(){return 
_supportedAnnotations;}
+
+  public Collection<String> supportedOptions(){return _supportedOptions;}
+
+  public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> 
p_atds,
+                                             AnnotationProcessorEnvironment 
p_env)
+  {    
+    // parse the command line args
+    // TODO: when apt gives proper key=value pairs, chage to fit.
+    // TODO: for now, everything is in the key
+    String configurl = null;
+    String processorName = null;
+    Set<String> keys = p_env.getOptions().keySet();
+    Iterator it = keys.iterator();
+    while(it.hasNext())
+    {
+      String curr = (String) it.next();
+      String[] val = curr.split("=");
+      if(val[0].equalsIgnoreCase("-Aprocessor"))
+        processorName = val[1];
+      else if(val[0].equalsIgnoreCase("-Aconfig"))
+        configurl = val[1];
+    }
+    it = null;
+
+    // initiialize the configuration
+    initProcessorMap(configurl);
+
+    // initialize the processor(s)
+    // if no command line override - return a composite 
+    // of all processors that map the the annotations present
+    HashSet<AnnotationProcessor> processors = new 
HashSet<AnnotationProcessor>();    
+    if(null == processorName)
+    {
+
+      // first loop through the annotation types and collect the
+      // set of unique annotation package names
+      it = p_atds.iterator();
+      HashSet<String> annotationPackages = new HashSet<String>();
+      while(it.hasNext())
+      {
+        AnnotationTypeDeclaration atd = (AnnotationTypeDeclaration)it.next();
+        annotationPackages.add(atd.getPackage().getQualifiedName());
+      }
+      it = null;
+
+      // loop through the unique annotation package names
+      // and initialize a uniqe set of processor names
+      // (processors may register for more than one annotation pkg)
+      HashSet<String> activeProcessors = new HashSet<String>();
+      for(String pkg : annotationPackages)
+      {
+        if(_processorMap.containsKey(pkg))
+        {
+          activeProcessors.add(_processorMap.get(pkg));
+        }
+        else
+          System.out.println("WARNING: no processor for annotation package 
"+pkg);
+      }
+
+      // loop through the unique processor names
+      // and instantiate them
+      for(String procname : activeProcessors)
+      {
+        // reflectivly new up the processor
+        processors.add(instantiateProcessor(procname,p_atds,p_env));
+      }
+    }
+    else
+    {
+      // processor override provided - just new up this one
+      processors.add(instantiateProcessor(processorName,p_atds,p_env));
+    }
+
+    System.out.println("config="+configurl);
+    System.out.println("num processor(s) initialized="+processors.size());
+    
+    // create a composite of processors to return
+    AnnotationProcessors util = new AnnotationProcessors();
+    return util.getCompositeAnnotationProcessor(processors);
+  }
+
+  private Collection<String> initSupportedOptions()
+  {
+    HashSet<String> supportedOpts = new HashSet<String>();
+    supportedOpts.add("-Aconfig");
+    supportedOpts.add("-Aprocessor");
+    return supportedOpts;
+  }
+
+  private void initProcessorMap(String configurl)
+  {
+
+    try
+    {
+      FileReader reader = new FileReader(configurl);
+      int c;
+      StringBuffer buff = new StringBuffer();
+      while( (c=reader.read()) != -1)
+      {
+        buff.append((char)c);
+      }
+      String[] values = 
buff.toString().split(System.getProperty("line.separator"));
+
+      _processorMap = new HashMap<String,String>();
+      for(int i=0; i<values.length; i++)
+      {
+        // if the line is commented out - skip it
+        if(values[i].startsWith("#"))
+           continue;
+        String[] val = values[i].split("=");
+        if(_processorMap.containsKey(val[0]))
+           System.out.println("WARNING: duplicate mappings for annotation 
package: "+val[0]);
+        _processorMap.put(val[0],val[1]);
+      }
+    }
+    catch(FileNotFoundException fnfe)
+    {
+      fnfe.printStackTrace();
+    }
+    catch(IOException ioe)
+    {
+      ioe.printStackTrace();
+    }
+  }
+
+  private AnnotationProcessor instantiateProcessor(String p_procname,
+                                                   
Set<AnnotationTypeDeclaration> p_atds,
+                                                   
AnnotationProcessorEnvironment p_env)
+  {
+    // instantiate the specified processors
+    try
+    {
+      Class definition = Class.forName(p_procname);
+      AbstractMantisProcessor proc = (AbstractMantisProcessor) 
definition.newInstance();
+      proc.init(p_atds,p_env);
+      return (AnnotationProcessor) proc;
+    }
+    catch(ClassNotFoundException cnfe)
+    {
+      cnfe.printStackTrace();
+      return null;
+    }
+    catch(InstantiationException ie)
+    {
+      ie.printStackTrace();
+      return null;
+    }
+    catch(IllegalAccessException iae)
+    {
+      iae.printStackTrace();
+      return null;
+    }
+  }
+ 
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/MantisTask.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/MantisTask.java
    Mon Aug  9 13:27:02 2004
@@ -0,0 +1,185 @@
+package org.apache.beehive.mantis;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.lang.InterruptedException;
+
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+
+public class MantisTask extends MatchingTask
+{
+  private final String P = System.getProperty("file.separator");
+
+  // required attributes
+  private String _srcdir = null;
+  private String _srcgen = null;
+  private String _bingen = null;
+  private String _classpath = null;
+  private String _config = null;
+  private String _aptcommand = null;
+  // optional attributes
+  private boolean _compile = false;
+  private String _processor = null;
+  private int _timeout = 30000;
+  // use _srcgen if not provided
+  private String _logdir = null;
+
+  // setters for attributes
+  public void setSrcdir(String p_srcdir)
+  {
+    _srcdir = p_srcdir;
+    fileset.setDir(new File(_srcdir));
+  }
+
+  public void setSrcgen(String p_srcgen)
+  {
+    _srcgen = p_srcgen;
+  }
+
+  public void setBingen(String p_bingen)
+  {
+    _bingen = p_bingen;
+  }
+
+  public void setClasspath(String p_classpath)
+  {
+    _classpath = p_classpath;
+  }
+
+  public void setConfig(String p_config)
+  {
+    _config = p_config;
+  }
+
+  public void setAptcommand(String p_aptcommand)
+  {
+    _aptcommand = p_aptcommand;
+  }
+
+  public void setCompile(boolean p_compile)
+  {
+    _compile = p_compile;
+  }
+
+  public void setProcessor(String p_processor)
+  {
+    _processor = p_processor;
+  }
+
+  public void setLogdir(String p_logdir)
+  {
+    _logdir = p_logdir;
+  }
+
+  public void execute() throws BuildException
+  {
+    // create the file of all files to process
+    // this will allow processing on win32 given it's
+    // limitation on command-line length
+    File fSrcgen = new File(_srcgen);
+    fSrcgen.mkdirs();
+    DirectoryScanner scanner = getDirectoryScanner(new File(_srcdir));
+    String[] files = scanner.getIncludedFiles();
+    String filename = _srcgen+P+"files.txt";
+    try
+    {
+      FileWriter writer = new FileWriter(new File(filename));
+      for(int i=0; i<files.length; i++)
+      {
+        writer.write(_srcdir+P+files[i]);
+        if(i != files.length)
+          writer.write("\n");
+      }
+      writer.flush();
+      writer.close();
+    }
+    catch(IOException ioe)
+    {
+      ioe.printStackTrace();
+      System.out.println("ERROR: IOException caught trying to create file 
listing file");
+      return;
+    }
+
+    // create the command line to call
+    StringBuffer cmd = new StringBuffer();
+    cmd.append(_aptcommand+" ");
+    if(!_compile)
+      cmd.append(" -nocompile ");
+    cmd.append("-classpath "+_classpath+" ");
+    cmd.append("-s "+_srcgen+" ");
+    if(null != _bingen)
+      cmd.append("-d "+_bingen+" ");
+    cmd.append("-factory org.apache.beehive.mantis.MantisFactory ");
+    cmd.append("-Aconfig="+_config+" ");
+    if(null != _processor)
+      cmd.append("-Aprocessor="+_processor+" ");
+    cmd.append("@"+filename+" ");
+
+    System.out.println("running command:\n"+cmd.toString());
+
+    // capture mantis stderr/stdout to log file
+    // while executing the command line apt call
+    BufferedInputStream stdout = null;
+    BufferedInputStream stderr = null;
+    try
+    {
+      Process p = Runtime.getRuntime().exec(cmd.toString());
+      stdout = new BufferedInputStream(p.getInputStream());
+      stderr = new BufferedInputStream(p.getErrorStream());
+      int returnval = p.waitFor();
+      logStreams(stdout,stderr);
+      System.out.println("RETURN: "+returnval);
+    }
+    catch(IOException ioe)
+    {
+      ioe.printStackTrace();
+      System.out.println("ERROR: IOException during apt execution");
+    }
+    catch(InterruptedException ie)
+    {
+      ie.printStackTrace();
+      System.out.println("ERROR: InterruptedException during apt execution");
+      try
+      {
+        logStreams(stdout,stderr);
+      }
+      catch(IOException ioe){ioe.printStackTrace();}
+    }
+
+  }
+
+  private void logStreams(BufferedInputStream p_stdout, BufferedInputStream 
p_stderr) throws IOException
+  {
+    int c;
+    // capture stdout
+    if(null == _logdir)
+      _logdir = _srcgen;
+    else
+    {
+      File fLogdir = new File(_logdir);
+      fLogdir.mkdirs();
+    }
+    FileWriter stdoutWriter = new FileWriter(new File(_logdir+P+"mantis.out"));
+    while( (c=p_stdout.read()) != -1)
+    {
+      stdoutWriter.write(c);
+    }
+    stdoutWriter.flush();
+    stdoutWriter.close();
+
+    // capture stderr
+    FileWriter stderrWriter = new FileWriter(new File(_logdir+P+"mantis.err"));
+    while( (c = p_stderr.read()) != -1)
+    {
+      stderrWriter.write(c);
+    }
+    stderrWriter.flush();
+    stderrWriter.close();
+  }
+
+
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/TchProcessor.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/TchProcessor.java
  Mon Aug  9 13:27:02 2004
@@ -0,0 +1,272 @@
+package org.apache.beehive.mantis;
+
+// mirror apis
+import com.sun.mirror.apt.AnnotationProcessor;
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import com.sun.mirror.apt.Filer;
+import com.sun.mirror.declaration.PackageDeclaration;
+import com.sun.mirror.declaration.AnnotationTypeDeclaration;
+import com.sun.mirror.declaration.AnnotationTypeElementDeclaration;
+import com.sun.mirror.declaration.AnnotationValue;
+import com.sun.mirror.declaration.TypeDeclaration;
+import com.sun.mirror.declaration.ClassDeclaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.AnnotationMirror;
+
+// java utils
+import java.io.PrintWriter;
+import java.io.IOException;
+import java.io.File;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.ArrayList;
+
+// mantis annotations
+import org.apache.beehive.mantis.annotations.tch.*;
+import org.apache.beehive.mantis.utils.FileTypes;
+import org.apache.beehive.mantis.utils.MantisFileInfo;
+
+// tch schema types
+import org.apache.xmlbeans.XmlAnySimpleType;
+import org.apache.xmlbeans.XmlAnySimpleType.Factory;
+import noNamespace.ProjectDocument.*;
+import noNamespace.*;
+
+public class TchProcessor extends AbstractMantisProcessor
+{
+  protected HashSet<PackageDeclaration> _pkgdecls;
+  private Filer _filer;
+
+  public void init(Set<AnnotationTypeDeclaration> p_atds,
+                   AnnotationProcessorEnvironment p_env)
+  {
+    super.init(p_atds,p_env);
+    this._pkgdecls = new HashSet();
+    this._filer = _env.getFiler();
+
+    // init the package list
+    Collection<TypeDeclaration> tdecls = 
+      _env.getSpecifiedTypeDeclarations();
+    for(TypeDeclaration tdecl : tdecls)
+    {
+      _pkgdecls.add(tdecl.getPackage());
+    }
+  }
+
+  public void process()
+  {
+    // creates an xml file for each package
+    for(PackageDeclaration pkg : _pkgdecls)
+    {
+      processPackage(pkg);
+    }
+
+    // create the root xml file
+    createRootTCH();
+
+    // print out some info about the files created during this process
+    System.out.println("created "+getFileInfo().size()+" files:");
+    for(MantisFileInfo mfi : getFileInfo())
+    {
+      System.out.println(mfi.getUrl());
+      System.out.println(mfi.getCreatingClassname());
+      if(mfi.getFileType() == FileTypes.AUX)
+        System.out.println("AUX");
+      else if(mfi.getFileType() == FileTypes.SRC)
+        System.out.println("SRC");
+      else if(mfi.getFileType() == FileTypes.BIN)
+        System.out.println("BIN");
+      System.out.println();
+    }
+
+  }
+
+  // process a package
+  private void processPackage(PackageDeclaration p_pkgdecl)
+  {
+    // create a new project document (one per package)
+    ProjectDocument pdoc = ProjectDocument.Factory.newInstance();
+    Project project = pdoc.addNewProject();
+    project.setName("tch");
+    project.setDefault("suite");
+
+    // create and init the test suite
+    TargetType target = project.addNewTarget();
+    target.setName("suite");
+    TestSuiteType suite = target.addNewTestSuite();
+    // the . char is illegal for a test name in tch
+    suite.setTestunit(p_pkgdecl.getQualifiedName().replace('.','-'));
+
+    // add the suite-level metadata
+    TestMetadataType sMeta = suite.addNewTestMetadata();
+    sMeta.setDescription("mantis-generated test suite file");
+    
+
+    // loop through the classes in this package allowing them to 
+    // add test cases to the test suite
+    Collection<ClassDeclaration> classdecls = p_pkgdecl.getClasses();
+    for(ClassDeclaration classdecl : classdecls )
+    {
+      processClass(classdecl, suite);
+    }
+
+    // create the tch xml file for this package
+    PrintWriter pw = null;
+    try
+    {
+      String filename = p_pkgdecl.getQualifiedName().replace('.','-')+".xml";
+      pw = _filer.createTextFile(Filer.Location.SOURCE_TREE,
+                                 "",
+                                 new File(filename),
+                                 null);
+      pw.print(pdoc.toString());
+      registerFile("file://"+_srctree+"/"+filename,
+                   this.getClass().getName(),
+                   FileTypes.AUX);
+    }
+    catch(IOException ioe)
+    {
+      ioe.printStackTrace();
+    }
+    finally
+    {
+      if(null != pw)
+      {
+        pw.flush();
+        pw.close();
+      }
+    }
+
+  }
+
+  private void processClass(ClassDeclaration p_cdecl, TestSuiteType p_suite)
+  {
+    // get the class-level annotation values
+    Freq cfreq = (Freq) p_cdecl.getAnnotation(Freq.class);
+    Status cstatus = (Status) p_cdecl.getAnnotation(Status.class);
+    Desc cdesc = (Desc) p_cdecl.getAnnotation(Desc.class);
+    Misc cmisc = (Misc) p_cdecl.getAnnotation(Misc.class);
+
+    // loop through the methods
+    Collection<? extends MethodDeclaration> methods = p_cdecl.getMethods();
+    Iterator mit = methods.iterator();
+    while(mit.hasNext())
+    {
+      MethodDeclaration methDecl = (MethodDeclaration) mit.next();
+      processMethod(methDecl, p_suite, cfreq, cstatus, cdesc, cmisc);
+    }
+
+  }
+
+  private void processMethod(MethodDeclaration p_methdecl, 
+                             TestSuiteType suite,
+                             Freq p_cfreq,
+                             Status p_cstatus,
+                             Desc p_cdesc,
+                             Misc p_cmisc)
+  {
+    // only process methods that start with 'test' (junit)
+    // TODO: may need to add more logic for different tch runners
+    if(! p_methdecl.getSimpleName().startsWith("test"))
+      return;
+
+    // add the test to the suite
+    TestType test = suite.addNewTest();
+    
test.setName(p_methdecl.getDeclaringType().getSimpleName()+"-"+p_methdecl.getSimpleName());
+    JavatestType junit = test.addNewJunit();
+    junit.setTestclass(p_methdecl.getDeclaringType().getQualifiedName());
+    junit.setMethodnames(p_methdecl.getSimpleName());
+    
+    // get the annotaions on the methods
+    Freq mfreq = (Freq) p_methdecl.getAnnotation(Freq.class);
+    Status mstatus = (Status) p_methdecl.getAnnotation(Status.class);
+    Desc mdesc = (Desc) p_methdecl.getAnnotation(Desc.class);
+    Misc mmisc = (Misc) p_methdecl.getAnnotation(Misc.class);
+
+    // if not present on the method use the class-level value
+    if(null == mfreq) mfreq = p_cfreq;
+    if(null == mstatus) mstatus = p_cstatus;
+    if(null == mdesc) mdesc = p_cdesc;
+    if(null == mmisc) mmisc = p_cmisc;
+
+    // add metadata to the test
+    // leave out if null
+    TestMetadataType sMeta = test.addNewTestMetadata();
+    if(null != mfreq)
+    {
+      ArrayList<String> alFreq = new ArrayList<String>();
+      alFreq.add(mfreq.value());
+      sMeta.setFreq(alFreq);
+    }
+
+    if(null != mstatus)
+    {
+      ArrayList<String> alStatus = new ArrayList<String>();
+      alStatus.add(mstatus.value());
+      sMeta.setStatus(alStatus);
+    }
+
+    if(null != mdesc)
+      sMeta.setDescription(mdesc.value());
+
+    if(null != mmisc)
+      sMeta.setMisc(mmisc.value());
+  }
+
+  private void createRootTCH()
+  {
+    // create the root xmlbean
+    ProjectDocument pdoc = ProjectDocument.Factory.newInstance();
+    Project project = pdoc.addNewProject();
+    project.setName("tch");
+    project.setDefault("suite");
+
+    // create and init the test suite
+    TargetType target = project.addNewTarget();
+    target.setName("suite");
+    TestSuiteType suite = target.addNewTestSuite();
+    // the . char is illegal for a test name in tch
+    suite.setTestunit("root");
+
+    // add a call to each package's test suite
+    for(PackageDeclaration pkgdecl : _pkgdecls)
+    {
+      XmlAnySimpleType testfile = XmlAnySimpleType.Factory.newInstance();
+      
testfile.setStringValue(pkgdecl.getQualifiedName().replace('.','-')+".xml");
+      TestSuiteCallType call = suite.addNewTestSuiteCall();
+      call.setTestfile(testfile);
+    }
+
+    // create the file on disk
+    PrintWriter pw = null;
+    try
+    {
+      String filename = "root.xml";
+      pw = _filer.createTextFile(Filer.Location.SOURCE_TREE,
+                                 "",
+                                 new File(filename),
+                                 null);
+      pw.print(pdoc.toString());
+      registerFile("file://"+_srctree+"/"+filename,
+                   this.getClass().getName(),
+                   FileTypes.AUX);
+    }
+    catch(IOException ioe)
+    {
+      ioe.printStackTrace();
+    }
+    finally
+    {
+      if(null != pw)
+      {
+        pw.flush();
+        pw.close();
+      }
+    }
+
+  }
+
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Desc.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Desc.java
  Mon Aug  9 13:27:02 2004
@@ -0,0 +1,6 @@
+package org.apache.beehive.mantis.annotations.tch;
+
+public @interface Desc
+{
+  String value();
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Freq.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Freq.java
  Mon Aug  9 13:27:02 2004
@@ -0,0 +1,6 @@
+package org.apache.beehive.mantis.annotations.tch;
+
+public @interface Freq
+{
+       String value() default FreqVals.CHECKIN; 
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/FreqVals.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/FreqVals.java
      Mon Aug  9 13:27:02 2004
@@ -0,0 +1,7 @@
+package org.apache.beehive.mantis.annotations.tch;
+
+public class FreqVals
+{
+  public static final String CHECKIN = "checkin";
+  public static final String DETAILED = "detailed";
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Misc.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Misc.java
  Mon Aug  9 13:27:02 2004
@@ -0,0 +1,6 @@
+package org.apache.beehive.mantis.annotations.tch;
+
+public @interface Misc
+{
+  String value();
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Status.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/Status.java
        Mon Aug  9 13:27:02 2004
@@ -0,0 +1,6 @@
+package org.apache.beehive.mantis.annotations.tch;
+
+public @interface Status
+{
+  String value() default StatusVals.ACTIVE;
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/StatusVals.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/annotations/tch/StatusVals.java
    Mon Aug  9 13:27:02 2004
@@ -0,0 +1,7 @@
+package org.apache.beehive.mantis.annotations.tch;
+
+public class StatusVals
+{
+  public static final String ACTIVE = "active";
+  public static final String INACTIVE = "inactive";
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/test/CheckinTest.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/test/CheckinTest.java
      Mon Aug  9 13:27:02 2004
@@ -0,0 +1,35 @@
+package org.apache.beehive.mantis.test;
+
+import junit.framework.TestCase;
+import org.apache.beehive.mantis.annotations.tch.*;
+
+
[EMAIL PROTECTED](FreqVals.CHECKIN)
[EMAIL PROTECTED](StatusVals.ACTIVE)
[EMAIL PROTECTED]("a class desc")
[EMAIL PROTECTED]("a class misc")
+public class CheckinTest extends TestCase
+{
+       public CheckinTest(String name) throws Exception
+       {
+               super(name);
+       }
+
+  @Freq(FreqVals.DETAILED)
+  @Status(StatusVals.INACTIVE)
+  @Desc("a method desc")
+  @Misc("a method misc")
+       public void testPass() throws Exception
+       {
+       }
+
+       public void testFail() throws Exception
+       {
+    assertTrue(false);
+       }
+
+  public void notATest() throws Exception
+  {
+  }
+
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/test/DetailedTest.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/test/DetailedTest.java
     Mon Aug  9 13:27:02 2004
@@ -0,0 +1,31 @@
+package org.apache.beehive.mantis.test;
+
+import junit.framework.TestCase;
+import org.apache.beehive.mantis.annotations.tch.*;
+
+
+public class DetailedTest extends TestCase
+{
+       public DetailedTest(String name) throws Exception
+       {
+               super(name);
+       }
+
+  @Freq(FreqVals.DETAILED)
+  @Status(StatusVals.ACTIVE)
+  @Desc("a method desc")
+  @Misc("a method misc")
+       public void testPass() throws Exception
+       {
+       }
+
+       public void testFail() throws Exception
+       {
+               assertTrue(false);
+       }
+
+  public void notATest() throws Exception
+  {
+  }
+
+}

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/utils/FileTypes.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/utils/FileTypes.java
       Mon Aug  9 13:27:02 2004
@@ -0,0 +1,3 @@
+package org.apache.beehive.mantis.utils;
+
+public enum FileTypes {SRC,BIN,AUX};

Added: 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/utils/MantisFileInfo.java
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/controls/test/tools/mantis/src/org/apache/beehive/mantis/utils/MantisFileInfo.java
  Mon Aug  9 13:27:02 2004
@@ -0,0 +1,22 @@
+package org.apache.beehive.mantis.utils;
+
+public class MantisFileInfo
+{
+  private final String _url;
+  private final String _creatingClassname;
+  private final FileTypes _type;
+
+  public MantisFileInfo(String url, 
+                        String classname, 
+                        FileTypes type)
+  {
+    this._url = url;
+    this._creatingClassname = classname;
+    this._type = type;
+  }
+
+  public String getUrl(){return _url;}
+  public String getCreatingClassname(){return _creatingClassname;}
+  public FileTypes getFileType(){return _type;}
+
+}

Modified: incubator/beehive/trunk/controls/test/tools/tch/setenv.sh
==============================================================================
--- incubator/beehive/trunk/controls/test/tools/tch/setenv.sh   (original)
+++ incubator/beehive/trunk/controls/test/tools/tch/setenv.sh   Mon Aug  9 
13:27:02 2004
@@ -1,95 +1,95 @@
-#!/bin/sh
-
-TCH_HOME=`pwd`
-export TCH_HOME
-
-TCH_SRC="${TCH_HOME}/src"
-export TCH_SRC
-
-echo "$TCH_HOME"
-
-# read version file, will be used when generating tch.version
-TCH_VERSION=`cat version`
-echo "version: ${TCH_VERSION}"
-export TCH_VERSION
-
-# should probably provide a default
-JAVA_HOME=${JAVA_HOME:-$JAVAHOME}
-
-
-EXTERNAL_DIR=${BEEHIVE_HOME}/external
-ANT_HOME=${ANT_HOME:-${BEEHIVE_HOME}/installed/apache-ant-1.6.1}
-ANT_JAR=${ANT_JAR:-$ANT_HOME/lib/ant.jar}
-ANT_LAUNCHER_JAR=${ANT_LAUNCHER_JAR:-$ANT_HOME/lib/ant-launcher.jar}
-JUNIT_JAR=${JUNIT_JAR:-${EXTERNAL_DIR}/junit/junit.jar}
-XERCES_JAR=${EXTERNAL_DIR}/xerces/xerces-1.4.4.jar
-CRIMSON_JAR=${EXTERNAL_DIR}/crimson/crimson-1.1.jar
-JAKARTA_JAR=${EXTERNAL_DIR}/jakarta/jakarta-regexp-1.2.jar
-JAXP_JAR=${EXTERNAL_DIR}/jaxp/jaxp.jar
-
-PATHSEP=":"
-myos=`uname`
-case "$myos" in
-  Window*)
-  PATHSEP=";"
-  ;;
-esac
-
-
-cd ${TCH_HOME}/3rdparty
-THIRDPARTY_DIR=`pwd`
-for A in \
-j2ee12.jar 
-do
-  echo "Adding ${THIRDPARTY_DIR}/$A to CLASSPATH"
-  CLASSPATH="${THIRDPARTY_DIR}/$A${PATHSEP}$CLASSPATH"
-done
-echo ""
-cd $TCH_HOME
-
-
-echo "Adding ${JUNIT_JAR} to CLASSPATH"
-CLASSPATH="${JUNIT_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${ANT_JAR} to CLASSPATH"
-CLASSPATH="${ANT_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${ANT_LAUNCHER_JAR} to CLASSPATH"
-CLASSPATH="${ANT_LAUNCHER_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${XERCES_JAR} to CLASSPATH"
-CLASSPATH="${XERCES_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${CRIMSON_JAR} to CLASSPATH"
-CLASSPATH="${CRIMSON_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${JAKARTA_JAR} to CLASSPATH"
-CLASSPATH="${JAKARTA_JAR}${PATHSEP}$CLASSPATH"
-
-echo "Adding ${JAXP_JAR} to CLASSPATH"
-CLASSPATH="${JAXP_JAR}${PATHSEP}$CLASSPATH"
-
-
-
-
-
-echo "Adding $JAVA_HOME/lib/tools.jar to CLASSPATH"
-CLASSPATH="$JAVA_HOME/lib/tools.jar${PATHSEP}$CLASSPATH"
-echo ""
-
-export CLASSPATH
-
-echo "Adding ${JAVA_HOME}/bin to PATH"
-PATH="$JAVA_HOME/bin/${PATHSEP}$PATH"
-ANT_SCRIPT="${TCH_HOME}/"
-echo "Adding ${ANT_SCRIPT} to PATH"
-PATH="${ANT_SCRIPT}${PATHSEP}$PATH"
-
-rm -f $TCH_HOME/buildenv.properties
-echo TCH_HOME=${TCH_HOME} >> $TCH_HOME/buildenv.properties
-echo >> $TCH_HOME/buildenv.properties
-echo optimize=false >> $TCH_HOME/buildenv.properties
-echo debug=true >> $TCH_HOME/buildenv.properties
-
-unset TCH_HOME optimize debug ANT_SCRIPT
-echo ""
+#!/bin/sh
+
+TCH_HOME=`pwd`
+export TCH_HOME
+
+TCH_SRC="${TCH_HOME}/src"
+export TCH_SRC
+
+echo "$TCH_HOME"
+
+# read version file, will be used when generating tch.version
+TCH_VERSION=`cat version`
+echo "version: ${TCH_VERSION}"
+export TCH_VERSION
+
+# should probably provide a default
+JAVA_HOME=${JAVA_HOME:-$JAVAHOME}
+
+
+EXTERNAL_DIR=${BEEHIVE_HOME}/external
+ANT_HOME=${ANT_HOME:-${BEEHIVE_HOME}/installed/apache-ant-1.6.1}
+ANT_JAR=${ANT_JAR:-$ANT_HOME/lib/ant.jar}
+ANT_LAUNCHER_JAR=${ANT_LAUNCHER_JAR:-$ANT_HOME/lib/ant-launcher.jar}
+JUNIT_JAR=${JUNIT_JAR:-${EXTERNAL_DIR}/junit/junit.jar}
+XERCES_JAR=${EXTERNAL_DIR}/xerces/xerces-1.4.4.jar
+CRIMSON_JAR=${EXTERNAL_DIR}/crimson/crimson-1.1.jar
+JAKARTA_JAR=${EXTERNAL_DIR}/jakarta/jakarta-regexp-1.2.jar
+JAXP_JAR=${EXTERNAL_DIR}/jaxp/jaxp.jar
+
+PATHSEP=":"
+myos=`uname`
+case "$myos" in
+  Window*)
+  PATHSEP=";"
+  ;;
+esac
+
+
+cd ${TCH_HOME}/3rdparty
+THIRDPARTY_DIR=`pwd`
+for A in \
+j2ee12.jar
+do
+  echo "Adding ${THIRDPARTY_DIR}/$A to CLASSPATH"
+  CLASSPATH="${THIRDPARTY_DIR}/$A${PATHSEP}$CLASSPATH"
+done
+echo ""
+cd $TCH_HOME
+
+
+echo "Adding ${JUNIT_JAR} to CLASSPATH"
+CLASSPATH="${JUNIT_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${ANT_JAR} to CLASSPATH"
+CLASSPATH="${ANT_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${ANT_LAUNCHER_JAR} to CLASSPATH"
+CLASSPATH="${ANT_LAUNCHER_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${XERCES_JAR} to CLASSPATH"
+CLASSPATH="${XERCES_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${CRIMSON_JAR} to CLASSPATH"
+CLASSPATH="${CRIMSON_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${JAKARTA_JAR} to CLASSPATH"
+CLASSPATH="${JAKARTA_JAR}${PATHSEP}$CLASSPATH"
+
+echo "Adding ${JAXP_JAR} to CLASSPATH"
+CLASSPATH="${JAXP_JAR}${PATHSEP}$CLASSPATH"
+
+
+
+
+
+echo "Adding $JAVA_HOME/lib/tools.jar to CLASSPATH"
+CLASSPATH="$JAVA_HOME/lib/tools.jar${PATHSEP}$CLASSPATH"
+echo ""
+
+export CLASSPATH
+
+echo "Adding ${JAVA_HOME}/bin to PATH"
+PATH="$JAVA_HOME/bin/${PATHSEP}$PATH"
+ANT_SCRIPT="${TCH_HOME}/"
+echo "Adding ${ANT_SCRIPT} to PATH"
+PATH="${ANT_SCRIPT}${PATHSEP}$PATH"
+
+rm -f $TCH_HOME/buildenv.properties
+echo TCH_HOME=${TCH_HOME} >> $TCH_HOME/buildenv.properties
+echo >> $TCH_HOME/buildenv.properties
+echo optimize=false >> $TCH_HOME/buildenv.properties
+echo debug=true >> $TCH_HOME/buildenv.properties
+
+unset TCH_HOME optimize debug ANT_SCRIPT
+echo ""

Reply via email to