You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2002/09/28 12:37:51 UTC

cvs commit: jakarta-avalon-excalibur/metagenerate/src/xdocs index.xml menu.xml

hammant     2002/09/28 03:37:50

  Added:       metagenerate .cvsignore ant.properties.sample build.xml
                        default.properties
               metagenerate/lib qdox-1.0.jar
               metagenerate/src/java/org/apache/avalon/excalibur/metagenerate
                        MetaGenerateQdoxTask.java XinfoFactory.java
                        XinfoHelper.java
               metagenerate/src/test/org/apache/avalon/excalibur/metagenerate
                        IntegrationTestCase.java TestBlock.java
                        TestNonBlock.java
               metagenerate/src/xdocs index.xml menu.xml
  Log:
  Start of metagenerate
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-excalibur/metagenerate/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  ant.properties
  build
  checkstyle.cache
  distributions
  dist
  excalibur-*
  *.el
  *.ipr
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/ant.properties.sample
  
  Index: ant.properties.sample
  ===================================================================
  # -----------------------------------------------------------------------------
  # Component ant.properties.sample
  #
  # This is an example "ant.properties" file, used to customize the building of
  # the component for your local environment.  It defines the location of all
  # external modules that this component depend on.  Copy this file to
  # "ant.properties" in the source directory, and customize it as needed.
  #
  # The ant.properties values in this directory apply only to this component.
  # It is overridden by ../ant.properties and ~/build.properties
  # It overrides all default.properties files and ~/.ant.properties
  #
  # $Id: ant.properties.sample,v 1.1 2002/09/28 10:37:50 hammant Exp $
  # -----------------------------------------------------------------------------
  
  # ----- Compile Control Flags -----
  build.debug=on
  build.optimize=off
  build.deprecation=off
  #build.compiler=jikes
  
  # ----- Base Directory in which all the packages are stored -----
  base.path=${basedir}/../..
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  
  
  # --------------------------------------------------
  #                OPTIONAL LIBRARIES
  # --------------------------------------------------
  
  # ----- JUnit Unit Test Suite, version 3.7 or later. -----
  #  Not needed if junit.jar is in $ANT_HOME/lib 
  junit.home=${base.path}/junit3.7
  junit.lib=${junit.home}
  junit.jar=${junit.lib}/junit.jar
  
  
  # ----- Checkstyle, version 2.1 or later -----
  # Uncomment the 'do.checkstyle' flag property to enable checkstyle
  # do.checkstyle=
  checkstyle.home=${base.path}/checkstyle-2.1
  checkstyle.lib=${checkstyle.home}
  checkstyle.jar=${checkstyle.lib}/checkstyle-all-2.1.jar
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <project name="Excalibur MetaGenerate" default="main" basedir=".">
  
      <property file="${user.home}/build.properties"/>
      <property file="${basedir}/../ant.properties"/>
      <property file="${basedir}/ant.properties"/>
      <property file="${user.home}/.ant.properties"/>
      <property file="${basedir}/../default.properties"/>
      <property file="${basedir}/default.properties"/>
  
      <!-- Classpath for product -->
      <path id="project.class.path">
          <pathelement location="${build.classes}"/>
          <pathelement location="${checkstyle.jar}"/>
          <pathelement location="${avalon-framework.jar}"/>
          <pathelement location="${qdox.jar}"/>
          <pathelement path="${java.class.path}"/>
      </path>
  
      <path id="tools.class.path">
          <pathelement location="${junit.jar}"/>
          <fileset dir="${jakarta-site.dir}/lib"/>
      </path>
  
      <path id="test.class.path">
          <pathelement location="${build.testclasses}"/>
          <pathelement location="${junit.jar}"/>
          <path refid="project.class.path"/>
      </path>
      <property name="cp" refid="test.class.path"/>
  
      <target name="main" depends="jar" description="Build the project"/>
      <target name="rebuild" depends="clean,main" description="Rebuild the project"/>
  
      <target name="dependencies" description="Check dependencies" unless="skip.dependencies">
          <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkCommon"/>
      </target>
  
      <target name="dependencies-test" depends="dist-jar, dependencies"
          description="Check unit test dependencies" unless="skip.dependencies">
          <!-- Need the jar to prevent recursive deps. -->
  
          <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkJUnit"/>
      </target>
  
  
      <!-- Compiles the source code -->
      <target name="compile" depends="dependencies" description="Compiles the source code">
  
          <mkdir dir="${build.classes}"/>
  
          <!-- Compile all classes excluding the tests. -->
          <javac srcdir="${java.dir}"
              destdir="${build.classes}"
              debug="${build.debug}"
              optimize="${build.optimize}"
              deprecation="${build.deprecation}"
              target="1.2">
              <classpath refid="project.class.path" />
              <include name="**/*.java"/>
          </javac>
  
          <!-- copy resources to same location as .class files -->
          <copy todir="${build.classes}">
              <fileset dir="${java.dir}">
                  <exclude name="**/*.java"/>
                  <exclude name="**/package.html"/>
              </fileset>
          </copy>
  
      </target>
  
      <!-- Compiles the unit test source code -->
      <target name="compile-test" depends="compile, dependencies-test" description="Compiles the source code">
          <mkdir dir="${build.testsrc}"/>
  
          <!-- In case tests do not exist, create the directory -->
          <mkdir dir="${test.dir}"/>
  
          <!-- Copy over all of the tests applying test filters -->
          <copy todir="${build.testsrc}">
              <fileset dir="${test.dir}"/>
          </copy>
  
          <mkdir dir="${build.testclasses}"/>
  
          <!-- Compile all test classes. -->
          <javac srcdir="${build.testsrc}"
              destdir="${build.testclasses}"
              debug="${build.debug}"
              optimize="${build.optimize}"
              deprecation="${build.deprecation}"
              target="1.2">
              <classpath refid="test.class.path" />
              <include name="**/*.java"/>
          </javac>
  
          <copy todir="${build.testclasses}">
              <fileset dir="${test.dir}">
                  <exclude name="**/*.java"/>
                  <exclude name="**/package.html"/>
              </fileset>
          </copy>
  
      </target>
  
      <!-- Copies and filters the license. Used by jar and dist -->
      <target name="prepare-conf">
          <mkdir dir="${build.conf}"/>
          <copy todir="${build.conf}" flatten="true">
              <fileset dir="../" includes="LICENSE.txt"/>
              <filterset>
                  <filter token="year" value="${year}"/>
              </filterset>
          </copy>
      </target>
  
      <!-- Creates all the .jar file -->
      <target name="jar" depends="compile, prepare-conf" description="Generates the jar files">
  
          <mkdir dir="${build.lib}"/>
  
          <jar jarfile="${build.lib}/${jar.name}"
              basedir="${build.classes}"
              compress="${build.compress}">
              <manifest>
                  <attribute name="Extension-Name" value="${name}"/>
                  <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
                  <attribute name="Specification-Version" value="1.0"/>
                  <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
                  <attribute name="Implementation-Version" value="${package-version}"/>
              </manifest>
              <exclude name="**/test/**"/>
              <zipfileset dir="${build.conf}" prefix="META-INF/">
                  <include name="LICENSE.txt"/>
              </zipfileset>
          </jar>
      </target>
  
      <!-- Creates all the Javadocs -->
      <target name="javadocs" depends="compile" description="Generates the javadocs" unless="skip.javadocs">
  
          <mkdir dir="${dist.javadocs}"/>
          <javadoc packagenames="org.apache.*"
              sourcepath="${java.dir}"
              destdir="${dist.javadocs}">
              <classpath refid="project.class.path" />
              <doclet name="com.sun.tools.doclets.standard.Standard">
                  <param name="-author"/>
                  <param name="-version"/>
                  <param name="-doctitle" value="${Name}"/>
                  <param name="-windowtitle" value="${Name} API"/>
                  <param name="-link" value="http://java.sun.com/j2se/1.4/docs/api/"/>
                  <param name="-link" value="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
                  <param name="-link" value="http://jakarta.apache.org/avalon/api/"/>
                  <param name="-bottom"
                      value="&quot;Copyright &#169; ${year} Apache Jakarta Project. All Rights Reserved.&quot;"/>
              </doclet>
          </javadoc>
      </target>
  
      <target name="test" depends="compile-test, test-generate" description="Perform the unit tests" unless="skip.tests">
  
          <echo message="Performing Unit Tests" />
  
          <mkdir dir="${build.tests}"/>
  
          <copy todir="${build.tests}">
              <fileset dir="build/metagenerate">
                  <include name="**/*.xinfo"/>
              </fileset>
          </copy>
  
  
          <junit fork="true"
              haltonfailure="${junit.failonerror}"
              printsummary="yes"
              dir="${build.tests}">
              <classpath refid="test.class.path"/>
  
              <formatter type="xml"/>    <!-- xml reports for junitreport -->
              <formatter type="plain" usefile="false"/>  <!-- text reports for humans     -->
  
              <batchtest todir="${build.tests}">
                  <fileset dir="${build.testclasses}">
                      <include name="**/*TestCase.class"/>
                      <exclude name="**/Abstract*"/>
                  </fileset>
              </batchtest>
          </junit>
  
      </target>
  
      <target name="test-reports" depends="test" description="Generate Reports for the unit tests">
  
          <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkBSF"/>
  
          <mkdir dir="${build.reports}/junit"/>
  
          <junitreport todir="${build.reports}/junit">
              <fileset dir="${build.tests}">
                  <include name="TEST-*.xml"/>
              </fileset>
              <report format="frames" todir="${build.reports}/junit"/>
          </junitreport>
  
          <!-- Clean up the xml reports used by the junitreport task -->
          <!--
          <delete>
              <fileset dir="${build.tests}" includes="TEST-*.xml"/>
              <fileset dir="${build.tests}" includes="TESTS-*.xml"/>
          </delete>
          -->
  
      </target>
  
      <target name="checkstyle" if="do.checkstyle" description="Checkstyle">
  
          <!-- this invocation of checkstyle requires that checkstyle be downloaded and setup -->
          <!-- thats why you are required to define do.checkstyle property to generate the report -->
          <taskdef name="checkstyle"
              classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
              <classpath refid="project.class.path"/>
          </taskdef>
          <checkstyle
              lcurlyType="nl"
              lcurlyMethod="nl"
              lcurlyOther="nl"
              rcurly="ignore"
              allowProtected="false"
              allowPackage="false"
              allowNoAuthor="false"
              maxLineLen="100"
              maxMethodLen="200"
              maxConstructorLen="100"
              memberPattern="^m_[a-z][a-zA-Z0-9]*$"
              staticPattern="^c_[a-z][a-zA-Z0-9]*$"
              constPattern="(^c_[a-z][a-zA-Z0-9]*$)|([A-Z_]*$)"
              ignoreImportLen="true"
              allowTabs="false"
              javadocScope="protected"
              ignoreWhitespace="true"
              cacheFile="checkstyle.cache"
              failOnViolation="false"
              ignoreCastWhitespace="true">
              <fileset dir="${java.dir}">
                  <include name="**/*.java"/>
              </fileset>
              <formatter type="plain"/>
              <formatter type="xml" toFile="${build.dir}/checkstyle-results.xml"/>
          </checkstyle>
      </target>
  
      <target name="checkstyle-report"
          depends="checkstyle"
          if="do.checkstyle"
          description="Generate Checkstyle Report">
  
          <mkdir dir="${build.reports}/checkstyle"/>
          <property name="checkstyle.pathhack" location="."/>
          <style style="${tools.dir}/etc/checkstyle-frames.xsl" in="${build.dir}/checkstyle-results.xml"
              out="${build.reports}/checkstyle/delete-me.html"/>
  
      </target>
  
      <!-- Creates the distribution -->
      <target name="dist"
          depends="dist-jar, test-reports, checkstyle-report, site"
          description="Generates a distribution (jar + docs javadocs + unit tests + checkstyle reports)">
  
          <copy file="${build.conf}/LICENSE.txt" todir="${dist.dir}"/>
          <copy file="../KEYS" todir="${dist.dir}"/>
  
          <zip zipfile="${dist.dir}/src.zip" compress="false">
              <zipfileset dir="src/java"/>
          </zip>
  
          <mkdir dir="${dist.base}"/>
  
          <zip zipfile="${dist.base}/${dist.name}.zip" compress="true">
              <zipfileset dir="${dist.dir}" prefix="${dist.name}"/>
          </zip>
      </target>
  
      <!-- Creates a mini jar-only distribution -->
      <target name="dist-jar" depends="jar">
          <mkdir dir="${dist.dir}"/>
          <copy todir="${dist.dir}">
              <fileset dir="${build.lib}">
                  <include name="*.jar"/>
              </fileset>
          </copy>
      </target>
  
      <!-- Creates a minimal distribution -->
      <target name="dist.lite"
          depends="dist-jar, test, javadocs"
          description="Generates a minimal distribution (jar + javadocs)">
  
          <copy file="../LICENSE.txt" todir="${dist.dir}"/>
          <copy file="../KEYS" todir="${dist.dir}"/>
  
      </target>
  
      <target name="anakia-avail">
          <available classname="org.apache.velocity.anakia.AnakiaTask"
              property="AnakiaTask.present">
              <classpath refid="tools.class.path"/>
          </available>
      </target>
  
      <target name="anakia-check" depends="anakia-avail" unless="AnakiaTask.present">
          <echo>
              AnakiaTask is not present! Please check to make sure that
              velocity.jar is in your classpath. The easiest way to build
              the documentation is to checkout jakarta-site CVS and specify
              jakarta-site.dir property.
          </echo>
      </target>
  
      <target name="docs" depends="anakia-check" description="Generate documentation and website">
          <taskdef name="anakia"
              classname="org.apache.velocity.anakia.AnakiaTask">
              <classpath refid="tools.class.path"/>
          </taskdef>
  
          <anakia basedir="${xdocs.dir}"
              destdir="${docs.dir}"
              style="docs.vsl"
              projectfile="menu.xml"
              includes="**/*.xml"
              excludes="menu.xml"
              velocitypropertiesfile="../site/src/stylesheets/velocity.properties"
              />
  
          <copy todir="${docs.dir}" filtering="off">
              <fileset dir="../site/src" includes="css/*.css" />
              <fileset dir="${xdocs.dir}">
                  <include name="**/images/**"/>
                  <include name="**/*.gif"/>
                  <include name="**/*.jpg"/>
                  <include name="**/*.png"/>
                  <include name="**/*.css"/>
                  <include name="**/*.js"/>
              </fileset>
          </copy>
      </target>
  
      <target name="site" depends="javadocs, docs" description=" Places Docs ready for hosting on website">
  
          <mkdir dir="../site/dist/docs/${dir-name}"/>
          <copy todir="../site/dist/docs/${dir-name}">
              <fileset dir="${docs.dir}">
                  <include name="**"/>
              </fileset>
          </copy>
  
      </target>
  
      <!-- Cleans up build and distribution directories -->
      <target name="clean" description="Cleans up the project">
          <delete file="checkstyle.cache"/>
          <delete dir="${build.dir}" />
          <delete dir="${dist.dir}" />
          <delete dir="${docs.dir}" />
          <delete dir="test" /> <!-- unit testing output directory -->
          <delete>
              <fileset dir="." includes="velocity.*"/>
              <fileset dir="." includes="**/*~" defaultexcludes="no"/>
          </delete>
      </target>
  
      <target name="real-clean" depends="clean" description="Cleans up the project, including distributions">
          <delete dir="${dist.base}" />
      </target>
  
    <target name="test-generate">
  
      <taskdef name="makexinfo" classname="org.apache.avalon.excalibur.metagenerate.MetaGenerateQdoxTask">
          <classpath refid="test.class.path" />
      </taskdef>
  
      <makexinfo dest="build/metagenerate">
        <fileset dir="src/test">
          <include name="**/*.java"/>
        </fileset>
      </makexinfo>
  
    </target>
  
  
  </project>
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/default.properties
  
  Index: default.properties
  ===================================================================
  # -------------------------------------------------------------------
  # B U I L D  P R O P E R T I E S
  # -------------------------------------------------------------------
  # Specifies default property values
  # Overridden by ../default.properties and all ant.properties
  # Not user-editable; use ant.properties files instead
  
  name=excalibur-meta-generate
  Name=Excalibur MetaGenerate
  dir-name=metagenerate
  version=0.7
  package-version=0.7
  year=2002
  
  # --------------------------------------------------
  #                REQUIRED LIBRARIES
  # --------------------------------------------------
  
  
  # --------------------------------------------------
  
  #  Settings used to configure compile environment
  build.debug = on
  build.optimize = off
  build.deprecation = off
  build.compress = false
  junit.failonerror = false
  
  #  location of intermediate products
  build.dir = build
  build.testsrc = ${build.dir}/testsrc
  build.testclasses = ${build.dir}/testclasses
  build.lib = ${build.dir}/lib
  build.conf = ${build.dir}/conf
  build.classes = ${build.dir}/classes
  build.tests = ${build.dir}/tests
  build.reports = ${build.dir}/reports
  
  #  Set the properties for source directories
  src.dir = src
  java.dir = ${src.dir}/java
  conf.dir = ${src.dir}/conf
  test.dir = ${src.dir}/test
  
  #  Set the properties for distribution directories
  dist.dir = dist
  dist.javadocs = ${docs.dir}/api
  
  xdocs.dir = ${src.dir}/xdocs
  docs.dir = ${dist.dir}/docs
  jakarta-site.dir = ../../jakarta-site
  tools.dir = ../../jakarta-avalon/tools
  
  #  name of .zip/.tar.gz/.bz2 files and their top-level directory
  dist.name = ${name}-${version}
  
  #  name of jar file
  jar.name = ${name}-${version}.jar
  
  #  property indicating directory where all distribution archives are placed
  dist.base = distributions
  
  depchecker.prefix=.
  
  qdox.jar = lib/qdox-1.0.jar
  
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/lib/qdox-1.0.jar
  
  	<<Binary file>>
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/java/org/apache/avalon/excalibur/metagenerate/MetaGenerateQdoxTask.java
  
  Index: MetaGenerateQdoxTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.metagenerate;
  
  import com.thoughtworks.qdox.model.JavaClass;
  import com.thoughtworks.qdox.model.DocletTag;
  import com.thoughtworks.qdox.ant.AbstractQdoxTask;
  import org.apache.tools.ant.BuildException;
  
  import java.io.File;
  import java.io.IOException;
  
  import org.apache.avalon.excalibur.metagenerate.XinfoFactory;
  
  /**
   * MetaInfo Generation Ant Taskdef
    * @author Paul Hammant
   */
  public class MetaGenerateQdoxTask extends AbstractQdoxTask {
  
      private File m_destDir;
  
      /**
       * Execute
       */
      public void execute() {
          super.execute();
          try
          {
              m_destDir.mkdirs();
              outputClasses();
          }
          catch (IOException e)
          {
              e.printStackTrace();
              throw new BuildException("IOException " + e.getMessage());
          }
      }
  
      /**
       * Set the desitation
       * @param destinationDir The destination directory
       */
      public void setDest(File destinationDir) {
          m_destDir = destinationDir;
      }
  
      /**
       * Output the classes
       * @throws IOException If a problem writing output
       */
      protected void outputClasses() throws IOException {
          for (int i = 0; i < allClasses.size(); i++) {
              JavaClass javaClass = (JavaClass) allClasses.get(i);
              DocletTag tag = javaClass.getTagByName("phoenix:block");
              if (tag != null)
              {
                  XinfoFactory factory = new XinfoFactory(m_destDir, javaClass);
                  factory.generate();
              }
          }
      }
  
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/java/org/apache/avalon/excalibur/metagenerate/XinfoFactory.java
  
  Index: XinfoFactory.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.metagenerate;
  
  import com.thoughtworks.qdox.model.JavaClass;
  import com.thoughtworks.qdox.model.JavaMethod;
  import com.thoughtworks.qdox.model.DocletTag;
  import com.thoughtworks.qdox.model.Type;
  import com.thoughtworks.qdox.model.JavaParameter;
  
  import java.io.IOException;
  import java.io.File;
  
  /**
   * A Xinfo Factory
    * @author Paul Hammant
   */
  public class XinfoFactory
  {
  
      private JavaClass m_javaClass;
      private File m_destDir;
  
      /**
       * Construct a factory for a class.
       * @param destDir
       * @param javaClass
       */
      public XinfoFactory(File destDir, JavaClass javaClass)
      {
          m_javaClass = javaClass;
          m_destDir = destDir;
      }
  
      /**
       * Generate the class
       * @throws IOException If a problem writing output
       */
      public void generate() throws IOException
      {
          File file = new File(m_destDir,
                  m_javaClass.getFullyQualifiedName().replace('.',File.separatorChar) + ".xinfo");
          file.getParentFile().mkdirs();
          XinfoHelper xinfo = new XinfoHelper(file);
          JavaMethod[] methods = m_javaClass.getMethods();
          for (int j = 0; j < methods.length; j++)
          {
  
              xinfo.writeHeader();
  
              // services
  
              DocletTag[] services = m_javaClass.getTagsByName("phoenix:service");
              for (int i = 0; i < services.length; i++)
              {
                  DocletTag service = services[i];
                  xinfo.writeServiceLines(service.getNamedParameter("name"));
              }
  
              xinfo.writeMidSection();
  
              // dependencies
  
              JavaMethod method = methods[j];
              if (method.getName().equals("service")
                      && method.getReturns().equals(new Type("void",0))
                      && method.getParameters().length == 1
                      && method.getParameters()[0].getType().getValue().equals(
                              "org.apache.avalon.framework.service.ServiceManager"))
              {
                  DocletTag[] dependencies = method.getTagsByName("phoenix:dependency");
                  for (int i = 0; i < dependencies.length; i++)
                  {
                      DocletTag dependency = dependencies[i];
                      xinfo.writeDependencyLines(dependency.getNamedParameter("name"));
                  }
              }
  
              xinfo.writeFooter();
              xinfo.close();
          }
      }
  
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/java/org/apache/avalon/excalibur/metagenerate/XinfoHelper.java
  
  Index: XinfoHelper.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.metagenerate;
  
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.File;
  
  /**
   * A Xinfo Helper.
    * @author Paul Hammant
   */
  public class XinfoHelper
  {
  
      private FileWriter m_output;
  
      private static final String[] HEADER = new String[] {
      "<?xml version=\"1.0\"?>",
      "<!DOCTYPE blockinfo PUBLIC \"-//PHOENIX/Block Info DTD Version 1.0//EN\"",
      "                  \"http://jakarta.apache.org/avalon/dtds/phoenix/blockinfo_1_0.dtd\">",
      "",
      "<blockinfo>",
      "",
      "  <!-- section to describe block -->",
      "  <block>",
      "    <version>1.0</version>",
      "  </block>",
      "",
      "  <!-- services that are offered by this block -->",
      "  <services>" };
  
      private static final String[] SERVICE_LINES = new String[] {
      "    <service name=\"@SERVICE-CLASS@\"/>" };
  
      private static final String[] MID_SECTION = new String[] {
  
      "  </services>",
      "",
      "  <!-- interfaces that may be exported to manange this block -->",
      "  <management-access-points>",
      "  </management-access-points>",
      "",
      "  <!-- services that are required by this block -->",
      "  <dependencies>" };
  
      private static final String[] DEPENDENCY_SECTION = new String[] {
  
      "    <dependency>",
      "      <service name=\"@SERVICE-CLASS@\"/>",
      "    </dependency>" };
  
      private static final String[] FOOTER = new String[] {
  
      "  </dependencies>",
      "</blockinfo>" };
  
      /**
       * Construct
       * @param file The File to create
       * @throws IOException If a problem writing output
       */
      public XinfoHelper(File file) throws IOException
      {
          m_output = new FileWriter(file);
      }
  
      /**
       * Write the header
       * @throws IOException If a problem writing output
       */
      public void writeHeader() throws IOException
      {
          for (int i = 0; i < HEADER.length; i++)
          {
              m_output.write(HEADER[i] + "\n");
          }
      }
  
      /**
       * Write the Service Lines
       * @param service The service name
       * @throws IOException If a problem writing output
       */
      public void writeServiceLines(String service) throws IOException
      {
          for (int i = 0; i < SERVICE_LINES.length; i++)
          {
              String line =  SERVICE_LINES[i];
              int ix = line.indexOf("\"@SERVICE-CLASS@\"");
              if (ix != -1)
              {
                  m_output.write(
                      line.substring(0, ix) +
                      service +
                      line.substring(ix + "\"@SERVICE-CLASS@\"".length(), line.length()) +
                      "\n");
              }
              else
              {
                  m_output.write(line  + "\n");
              }
          }
      }
  
      /**
       * Write the mid section
       * @throws IOException If a problem writing output
       */
      public void writeMidSection() throws IOException
      {
          for (int i = 0; i < MID_SECTION.length; i++)
          {
              m_output.write(MID_SECTION[i] + "\n");
          }
      }
  
      /**
       * Write Dependency Lines
       * @param dependency The Dependency
       * @throws IOException If a problem writing output
       */
      public void writeDependencyLines(String dependency) throws IOException
      {
          for (int i = 0; i < DEPENDENCY_SECTION.length; i++)
          {
              String line =  DEPENDENCY_SECTION[i];
              int ix = line.indexOf("\"@SERVICE-CLASS@\"");
              if (ix != -1)
              {
                  m_output.write(
                      line.substring(0, ix) +
                      dependency +
                      line.substring(ix + "\"@SERVICE-CLASS@\"".length(), line.length()) +
                      "\n");
              }
              else
              {
                  m_output.write(line + "\n");
              }
          }
      }
  
      /**
       * Write footer
       * @throws IOException If a problem writing output
       */
      public void writeFooter() throws IOException
      {
          for (int i = 0; i < FOOTER.length; i++)
          {
              m_output.write(FOOTER[i] + "\n");
          }
      }
  
      /**
       * Close the file.
       * @throws IOException If a problem writing output
       */
      public void close() throws IOException
      {
          m_output.close();
      }
  
  
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/test/org/apache/avalon/excalibur/metagenerate/IntegrationTestCase.java
  
  Index: IntegrationTestCase.java
  ===================================================================
  /*
   * Created by IntelliJ IDEA.
   * User: Administrator
   * Date: 28-Sep-02
   * Time: 11:13:36
   * To change template for new class use 
   * Code Style | Class Templates options (Tools | IDE Options).
   */
  package org.apache.avalon.excalibur.metagenerate;
  
  import junit.framework.TestCase;
  
  import java.io.FileReader;
  import java.io.File;
  import java.io.LineNumberReader;
  import java.io.FileNotFoundException;
  
  public class IntegrationTestCase extends TestCase
  {
      public IntegrationTestCase(String name)
      {
          super(name);
      }
  
      public void testBlockInfoOutput() throws Exception
      {
  
          String fileName
                  = "org/apache/avalon/excalibur/metagenerate/TestBlock.xinfo";
          fileName.replace('\\',File.separatorChar);
          fileName.replace('/',File.separatorChar);
  
          LineNumberReader reader = new LineNumberReader(new FileReader(fileName));
          String line = reader.readLine();
          int ix =0;
          while (line != null)
          {
              assertEquals("Line not expected", line.trim(), XINFO[ix].trim());
              ix++;
              line = reader.readLine();
          }
      }
  
      public void testNonBlockInfoOutput() throws Exception
      {
          String fileName
                  = "org/apache/avalon/excalibur/metagenerate/TestNonBlock.xinfo";
          fileName.replace('\\',File.separatorChar);
          fileName.replace('/',File.separatorChar);
  
          try
          {
              new LineNumberReader(new FileReader(fileName));
              fail("Non Block should not generate an xinfo file");
          }
          catch (FileNotFoundException e)
          {
              // expected.
          }
  
      }
  
      private static final String XINFO[] = new String[] {
      "    <?xml version=\"1.0\"?>",
      "    <!DOCTYPE blockinfo PUBLIC \"-//PHOENIX/Block Info DTD Version 1.0//EN\"",
      "                      \"http://jakarta.apache.org/avalon/dtds/phoenix/blockinfo_1_0.dtd\">",
      "",
      "    <blockinfo>",
      "",
      "      <!-- section to describe block -->",
      "      <block>",
      "        <version>1.0</version>",
      "      </block>",
      "",
      "      <!-- services that are offered by this block -->",
      "      <services>",
      "        <service name=\"blah.BlahService\"/>",
      "      </services>",
      "",
      "      <!-- interfaces that may be exported to manange this block -->",
      "      <management-access-points>",
      "      </management-access-points>",
      "",
      "      <!-- services that are required by this block -->",
      "      <dependencies>",
      "        <dependency>",
      "          <service name=\"blah.OtherBlahService\"/>",
      "        </dependency>",
      "      </dependencies>",
      "    </blockinfo>" };
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/test/org/apache/avalon/excalibur/metagenerate/TestBlock.java
  
  Index: TestBlock.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.metagenerate;
  
  import org.apache.avalon.framework.service.ServiceException;
  import org.apache.avalon.framework.service.ServiceManager;
  import org.apache.avalon.framework.service.Serviceable;
  
  /**
   * Blah!
   *
   * @phoenix:block
   * @phoenix:service name="blah.BlahService"
   *
   */
  public class TestBlock implements Serviceable
  {
      /**
       * @phoenix:dependency name="blah.OtherBlahService"
       */
      public void service( final ServiceManager serviceManager )
          throws ServiceException
      {
  
      }
  
  
  }
  
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/test/org/apache/avalon/excalibur/metagenerate/TestNonBlock.java
  
  Index: TestNonBlock.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.metagenerate;
  
  public class TestNonBlock
  {
      public void service() {
  
      }
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <document>
      <properties>
          <title>Excalibur MetaGenerate - Overview</title>
          <author email="Paul_Hammant@yahoo.com">Paul Hammant</author>
      </properties>
      <body>
          <section name="Introduction">
              <p>
                  Meta Generate generates meta-info for Phoenix, Fortress etc.
              </p>
          </section>
      </body>
  </document>
  
  
  
  1.1                  jakarta-avalon-excalibur/metagenerate/src/xdocs/menu.xml
  
  Index: menu.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <project
  	href="http://jakarta.apache.org/avalon/excalibur/metagenerate/"
      name="Excalibur MetaGenerate">
  
      <title>Excalibur MetaGenerate</title>
      <body>
          <item href="/../index.html" name="Back to Excalibur"/>
          <menu name="About">
              <item name="Overview" href="index.html"/>
              <item name="Excalibur Home" href="http://jakarta.apache.org/avalon/excalibur/index.html"/>
              <item name="Download" href="http://jakarta.apache.org/builds/jakarta-avalon-excalibur/release"/>
              <item name="API Docs" href="api/"/>
          </menu>
      </body>
  </project>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>