You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by Zachary Smith <zs...@bea.com> on 2004/10/08 02:12:21 UTC

Refactoring Some Controls Test build infrastructure

In reference to the emails I sent out earlier today about building
controls with Checkers and clients I have made some changes to the
Controls Test infrastructure to make migrating the control/test code to
other build systems easier.  This change creates an 'aux' directory
where Checkers and Controls Interfaces can live and then moves the
existing Checkers and Interfaces there.

See inline diff:

Index:
src/controls/org/apache/beehive/controls/test/controls/checker/HelloChec
ker.java
===================================================================
---
src/controls/org/apache/beehive/controls/test/controls/checker/HelloChec
ker.java	(revision 54034)
+++
src/controls/org/apache/beehive/controls/test/controls/checker/HelloChec
ker.java	(working copy)
@@ -1,35 +0,0 @@
-package org.apache.beehive.controls.test.controls.checker;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.FieldDeclaration;
-
-import org.apache.beehive.controls.api.bean.ControlChecker;
-
-public class HelloChecker implements ControlChecker
-{
-    public void check(Declaration decl, AnnotationProcessorEnvironment
env)
-    {
-        // Just refer to the public interface in some way to test
-        // this kind of dep.
-        HelloChecked.GenderType gt = HelloChecked.GenderType.NEUTRAL;
-
-        if ( decl instanceof TypeDeclaration )
-        {
-            env.getMessager().printNotice(decl.getPosition(),
-                    "HelloChecker: found type decl=" + decl);
-        }
-        else if ( decl instanceof FieldDeclaration )
-        {
-            env.getMessager().printNotice(decl.getPosition(),
-                    "HelloChecker: found field decl=" + decl);
-        }
-        else
-        {
-            env.getMessager().printNotice(decl.getPosition(),
-                    "HelloChecker: found decl=" + decl);
-        }
-    }
-}
-
Index:
src/controls/org/apache/beehive/controls/test/controls/checker/HelloChec
ked.java
===================================================================
---
src/controls/org/apache/beehive/controls/test/controls/checker/HelloChec
ked.java	(revision 54034)
+++
src/controls/org/apache/beehive/controls/test/controls/checker/HelloChec
ked.java	(working copy)
@@ -1,45 +0,0 @@
-package org.apache.beehive.controls.test.controls.checker;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.beehive.controls.api.bean.ControlInterface;
-import org.apache.beehive.controls.api.properties.PropertySet;
-
-@ControlInterface( checkerClass=HelloChecker.class )
-public interface HelloChecked
-{
-    //
-    // A simple enumerated type used to customize the greeting by
gender
-    //
-    public enum GenderType
-    {
-        NEUTRAL, MALE, FEMALE
-    }
-
-    public @interface Gender
-    {
-        GenderType value();
-    }
-
-    /**
-     * Declare a simple PropertySet, that allows the salutation used by
the custom
-     * control to be customized.
-     */
-    @PropertySet
-    @Target( {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}
)
-    @Retention(RetentionPolicy.RUNTIME)
-    public @interface Greeting
-    {
-        String salutation() default "Hello";
-        Gender gender() default @Gender(GenderType.NEUTRAL);
-    }
-
-    java.lang.String hello(java.lang.String name);
-
-    java.lang.String lastVisitor();
-
-    int visitorCount();
-}
Index: build.xml
===================================================================
--- build.xml	(revision 54034)
+++ build.xml	(working copy)
@@ -24,11 +24,13 @@
     <property name="controls.test.units"
location="${controls.test.src}/units"/>
     <property name="controls.test.drivers"
location="${controls.test.src}/drivers"/>
     <property name="controls.test.controls"
location="${controls.test.src}/controls"/>
+    <property name="controls.test.auxilaries"
location="${controls.test.src}/aux"/>
     <property name="build.dir" location="${basedir}/build"/>
     <property name="build.classes" location="${build.dir}/classes"/>
     <property name="build.beans"
location="${build.dir}/classes/beans"/>
     <property name="build.tests"
location="${build.dir}/classes/tests"/>
     <property name="build.drivers"
location="${build.dir}/classes/drivers"/>
+    <property name="build.auxilaries"
location="${build.dir}/classes/aux"/>
     <property name="build.beansrc" location="${build.dir}/beansrc"/>
     <property name="build.jars" location="${build.dir}/jars"/>
     <property name="controlstestbeans.jar"
location="${build.dir}/controlstestbeans.jar"/>
@@ -127,43 +129,44 @@
     <!--
==================================================================== -->
 
     <target name="build" depends="dirs">
-        <ant target="build-beans" />
+        <ant target="build-test-auxilaries"/>
+        <ant target="build-test-beans" />
         <ant target="build-test-drivers" />
-        <ant target="build-java-tests" />
+        <ant target="build-test-units" />
+        <ant target="mantis" />
     </target>
 
     <target name="dirs">
         <mkdir dir="${build.classes}" />
         <mkdir dir="${build.beans}" />
         <mkdir dir="${build.drivers}" />
+        <mkdir dir="${build.auxilaries}" />
         <mkdir dir="${build.tests}" />
         <mkdir dir="${build.beansrc}" />
         <mkdir dir="${build.jars}" />
         <mkdir dir="${test.logs}" />
     </target>
 
-    <target name="build-beans" depends="dirs">
-        <!-- Build checkers first so they can be dynamically loaded
-        during build of control extensions.  Checkers may dep on public
interfaces,
-        which we need to make sure get pulled in by apt -->
-        <apt srcdir="${controls.test.controls}"
destdir="${build.beans}" gendir="${build.beansrc}"
-             classpathref="test.classpath" >
-            <include name="**/checker/*.java"/>
-        </apt>
+    <target name="build-test-beans"
depends="dirs,build-test-auxilaries">
 
         <!-- Build the InnerControl controls used by composition tests.
This is only
              necessary because the bean types are needed to compile a
public interface -->
+        <echo message="** Phase One **"/>
         <apt srcdir="${controls.test.controls}"
destdir="${build.beans}" gendir="${build.beansrc}"
              classpathref="test.classpath" compileByExtension="true"
              srcExtensions="*.java,*.jcx,*.jcs" >
             <include name="**/composition/InnerControl*"/>
         </apt>
 
+        <echo message="** Phase Two **"/>
         <apt srcdir="${controls.test.controls}"
destdir="${build.beans}" gendir="${build.beansrc}"
-             classpathref="test.classpath" compileByExtension="true"
+             compileByExtension="true"
+             classpathref="test.classpath"
              srcExtensions="*.java,*.jcx,*.jcs" >
         </apt>
+
         <!-- Do control assembly. -->
+        <echo message="** Assembly **"/>
         <assemble moduleDir="${build.beans}"
                   srcOutputDir="${build.beansrc}"
 
contextFactoryClassname="org.apache.beehive.controls.runtime.assembly.EJ
BAssemblyContext$Factory">
@@ -178,8 +181,27 @@
         <control-jar destfile="${controlstestbeans.jar}"
basedir="${build.beans}" />
     </target>
 
+    <!-- Aux files are those needed for tests but which must be built
before beans/drivers
+         like Checkers.  Files in 'aux' should only have dependecies on
the existing classpath and 
+         have NO DEPENDENCIES on artifacts from this build process! -->
+    <target name="build-test-auxilaries"
unless="_build.test.auxilaries.ran" depends="dirs">
+        <echo message="Building Test Auxilary Files into
${build.beans}"/>
 
-    <target name="build-test-drivers" depends="build-beans"
unless="_build.test.drivers.ran">
+        <apt srcdir="${controls.test.auxilaries}"
+            destdir="${build.beans}"
+            gendir="${build.beansrc}"
+            classpathref="test.classpath"
+            debug="on"  
+            verbose="false"
+            failonerror="true"
+            compileByExtension="true"
+            srcExtensions="*.java"/>
+
+        <property name="_build.test.auxilaries.ran" value="true"/>
+
+    </target>
+							  
+    <target name="build-test-drivers" depends="build-test-beans"
unless="_build.test.drivers.ran">
 	<echo>build helper class for testing controls</echo>
         <!-- Build the test source directory -->
         <javac srcdir="${controls.test.drivers}"
@@ -199,7 +221,7 @@
     </target>
 
 
-    <target name="build-java-tests" depends="build-test-drivers"
unless="_build.java.tests.ran">
+    <target name="build-test-units" depends="build-test-drivers"
unless="_build.java.tests.ran">
         <!-- Build the test source directory -->
         <apt srcdir="${controls.test.units}"
             destdir="${build.tests}"
@@ -293,7 +315,7 @@
 	<antcall target="run"/>
     </target>
 
-    <target name="run" depends="mantis">
+    <target name="run">
 
         <gethostname/> <!-- set ${hostname} -->