sanders     01/04/16 23:49:24

  Modified:    cjan     README.txt
  Added:       cjan     .cvsignore build.xml
               cjan/src/conf MANIFEST.MF
               cjan/src/java/org/apache/tools/ant/taskdefs/optional/cjan
                        CJANGet.java CJANSubTask.java CJANSubTask.java~
                        CJANTask.java
  Log:
  various changes
  
   - added .cvsignore
   - created build.xml with a test-cjan target
   - added MANIFEST.MF
   - created the start of a cjan ant task.  Stupidly just copies, but it is a
     start, I think.  I have modified my ant build to include it for testing.
  
  Revision  Changes    Path
  1.3       +75 -1     jakarta-commons-sandbox/cjan/README.txt
  
  Index: README.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cjan/README.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- README.txt        2001/04/13 17:22:09     1.2
  +++ README.txt        2001/04/17 06:49:18     1.3
  @@ -1,6 +1,11 @@
   CJAN - April 12, 2001
   
  -Ideas conceived by many parties
  +Ideas conceived by many parties (my inspiration), including but not limited to:
  +  Peter Donald
  +  Craig McClanahan
  +  Sam Ruby
  +  Jon Stevens
  +
   Formalized and coded by:
     Scott Sanders <[EMAIL PROTECTED]>
   
  @@ -25,3 +30,72 @@
   
   If you are interested in participating in the development of CJAN, just subscribe
   to the jakarta-commons mailing list.
  +
  +
  +The following is an email that defines my vision of CJAN and where to start.
  +When Peter Donald answered the question 'Can you elaborate on CJAN' over on 
  +general@jakarta, I believe that he summed up the idea very well:
  +
  +    It was an idea originally brought up by Jon to implement a system similar
  +    to CPAN but for java not perl. So you would basically have a global
  +    repository where you could download binary snapshots (ie .jar/.war/.ear
  +    files) of products. 
  +
  +    Associated with each product has a list of jars each with a name (and
  +    optionally a flavour) and a version. So you could have
  +    turbine-debug-1.2.3.jar, avalon-4.5.6.jar, log4j-7.8.jar etc
  +
  +    When doing a build you can choose to update your local jars so that the
  +    required versions are stored in a system wide, workspace wide or project
  +    wide repository.
  +
  +    For instance in the Avalon projects I currently have a temporary hack till
  +    CJAN arrives that installs the jars into a location specified by cjan.home.
  +    So I set cjan.home in "${user.home}/.ant.properties". The binaries are
  +    installed into systemwide /opt/apps/cjan in my case and other projects
  +    directly reference it from there.
  +
  +    When full CJAN comes about the system will look something like this
  +
  +    <target name="cjan-update">
  +        <cjan-get category="xml/parser" name="xerces" version="1.2"/>
  +    </target>
  +
  +    This will first check your local repositories for appropriate jar. In my
  +    case it would check the following locations
  +
  +    /opt/apps/cjan/xml/parser/xerces-1.2[.*].jar
  +    /opt/Repositories/avalon/lib/xml/parser/xerces-1.2[.*].jar
  +    /opt/Repositories/avalon/jakarta-avalon/lib/xml/parser/xerces-1.2[.*].jar
  +
  +    (or you could elide category directories - xml/parser - if it looked better).
  +
  +    It would detect that I don't have xerces around with correct version and
  +    download the appropriate jar from CJAN repository
  +
  +    ie http://www.cjan.org/directory/xml/parser/xerces-1.2[.*].jar
  +
  +    It would then install it into a local system specific place dependening on
  +    permissions and settings. I would choose for it to be installed at
  +    workspace level - namely
  +
  +    /opt/Repositories/avalon/lib/xml/parser/xerces-1.2[.*].jar
  +
  +    It would then set the property xerces.jar to the location of the jar. 
  +
  +    A bit further on you go 
  +
  +    <classpath id="project.class.path">
  +        <pathelement location="${xerces.jar}" />
  +        ...
  +    </classpath>
  +
  +    Subsequent runs would not need to download jar but instead could use this
  +    one directly.
  +
  +    This would allow each project to depend on particular versions, be easy for
  +    end user and remove need for binaries in CVS. 
  +    Cheers,
  +
  +    Pete
  +
  
  
  
  1.1                  jakarta-commons-sandbox/cjan/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  build
  build.properties
  target
  
  
  1.1                  jakarta-commons-sandbox/cjan/build.xml
  
  Index: build.xml
  ===================================================================
  <project name="CJAN" default="compile" basedir=".">
  
  
  <!--
          "CJAN" component of the Jakarta Commons Subproject
          $Id: build.xml,v 1.1 2001/04/17 06:49:18 sanders Exp $
          Author: Scott Sanders <[EMAIL PROTECTED]>
  -->
  
  
  <!-- ========== Initialize Properties ===================================== -->
  
  
    <property file="build.properties"/>                <!-- Component local   -->
    <property file="../build.properties"/>             <!-- Commons local     -->
    <property file="${user.home}/build.properties"/>   <!-- User local        -->
  
  <!-- ========== External Dependencies ===================================== -->
  
  
    <!-- The directories corresponding to your necessary dependencies 
         Note that JAXP is required to be version 1.1 or greater
         Note that JUnit is required to be version 3.5 or greater
    -->
    <property name="ant.home"                value="/usr/local/ant"/>
    <property name="jaxp.home"               value="/usr/local/jaxp1.1"/>
    <property name="junit.home"              value="/usr/local/junit3.5"/>
    <property name="commons.home"            value="../../jakarta-commons"/>
    <property name="sandbox.home"            value="../../jakarta-commons-sanbox"/>
    <property name="digester.home"           value="${sandbox.home}/digester"/>
    <property name="beanutils.home"          value="${commons.home}/beanutils"/>
    <property name="collections.home"        value="${commons.home}/collections"/>
  
  
  <!-- ========== Derived Values ============================================ -->
  
  
    <!-- The locations of necessary jar files -->
    <property name="ant.jar"                 value="${ant.home}/lib/ant.jar"/>
    <property name="ant.optional.jar"        value="${ant.home}/lib/optional.jar"/>
    <property name="jaxp.jaxp.jar"           value="${jaxp.home}/jaxp.jar"/>
    <property name="jaxp.parser.jar"         value="${jaxp.home}/crimson.jar"/>
    <property name="junit.jar"               value="${junit.home}/junit.jar"/>
    <property name="digester.jar"            
value="${digester.home}/build/commons-digester.jar"/>
    <property name="beanutils.jar"           
value="${beanutils.home}/build/commons-beanutils.jar"/>
    <property name="collections.jar"         
value="${collections.home}/build/commons-collections.jar"/>
  
  
  <!-- ========== Component Declarations ==================================== -->
  
  
    <!-- The name of this component -->
    <property name="component.name"          value="cjan"/>
  
    <!-- The title of this component -->
    <property name="component.title"         value="XML to Java object configuration"/>
  
    <!-- The current version number of this component -->
    <property name="component.version"       value="0.1-dev"/>
  
    <!-- The base directory for compilation targets -->
    <property name="build.home"              value="target"/>
  
    <!-- The base directory for component configuration files -->
    <property name="conf.home"               value="src/conf"/>
  
    <!-- The base directory for distribution targets -->
    <property name="dist.home"               value="build"/>
  
    <!-- The base directory for component sources -->
    <property name="source.home"             value="src/java"/>
  
    <!-- The base directory for unit test sources -->
    <property name="test.home"               value="src/test"/>
  
  
  <!-- ========== Compiler Defaults ========================================= -->
  
  
    <!-- Should Java compilations set the 'debug' compiler option? -->
    <property name="compile.debug"           value="true"/>
  
    <!-- Should Java compilations set the 'deprecation' compiler option? -->
    <property name="compile.deprecation"     value="false"/>
  
    <!-- Should Java compilations set the 'optimize' compiler option? -->
    <property name="compile.optimize"        value="true"/>
  
    <!-- Construct compile classpath -->
    <path id="compile.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${jaxp.jaxp.jar}"/>
      <pathelement location="${jaxp.parser.jar}"/>
      <pathelement location="${ant.jar}"/>
      <pathelement location="${ant.optional.jar}"/>
      <pathelement location="${digester.jar}"/>
      <pathelement location="${beanutils.jar}"/>
      <pathelement location="${collections.jar}"/>
      <pathelement location="${junit.jar}"/>
    </path>
  
  
  <!-- ========== Test Execution Defaults =================================== -->
  
  
    <!-- Construct unit test classpath -->
    <path id="test.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${build.home}/tests"/>
      <pathelement location="${junit.jar}"/>
    </path>
  
    <!-- Should all tests fail if one does? -->
    <property name="test.failonerror"        value="true"/>
  
    <!-- The test runner to execute -->
    <property name="test.runner"             value="junit.textui.TestRunner"/>
  
  
  <!-- ========== Executable Targets ======================================== -->
  
  
    <target name="init"
     description="Initialize and evaluate conditionals">
      <echo message="-------- ${component.name} ${component.version} --------"/>
      <filter  token="name"                  value="${component.name}"/>
      <filter  token="version"               value="${component.version}"/>
    </target>
  
  
    <target name="prepare" depends="init"
     description="Prepare build directory">
      <mkdir dir="${build.home}"/>
      <mkdir dir="${build.home}/classes"/>
      <mkdir dir="${build.home}/conf"/>
      <mkdir dir="${build.home}/javadoc"/>
      <mkdir dir="${build.home}/tests"/>
    </target>
  
  
    <target name="static" depends="prepare"
     description="Copy static files to build directory">
      <tstamp/>
      <copy  todir="${build.home}/conf" filtering="on">
        <fileset dir="${conf.home}" includes="*.MF"/>
      </copy>
    </target>
  
  
    <target name="compile" depends="static"
     description="Compile shareable components">
      <javac  srcdir="${source.home}"
             destdir="${build.home}/classes"
               debug="${compile.debug}"
         deprecation="${compile.deprecation}"
            optimize="${compile.optimize}">
        <classpath refid="compile.classpath"/>
      </javac>
      <copy    todir="${build.home}/classes" filtering="on">
        <fileset dir="${source.home}" excludes="**/*.java"/>
      </copy>
    </target>
  
  
    <target name="compile.tests" depends="compile"
     description="Compile unit test cases">
      <javac  srcdir="${test.home}"
             destdir="${build.home}/tests"
               debug="${compile.debug}"
         deprecation="${compile.deprecation}"
            optimize="${compile.optimize}">
        <classpath refid="test.classpath"/>
      </javac>
      <copy    todir="${build.home}/tests" filtering="on">
        <fileset dir="${test.home}" excludes="**/*.java"/>
      </copy>
    </target>
  
  
    <target name="clean"
     description="Clean build and distribution directories">
      <delete    dir="${build.home}"/>
      <delete    dir="${dist.home}"/>
    </target>
  
  
    <target name="all" depends="clean,compile"
     description="Clean and compile all components"/>
  
  
    <target name="javadoc" depends="compile"
     description="Create component Javadoc documentation">
      <mkdir      dir="${dist.home}"/>
      <mkdir      dir="${dist.home}/javadoc"/>
      <javadoc sourcepath="${source.home}"
                  destdir="${dist.home}/javadoc"
             packagenames="org.apache.*"
                   author="true"
                  private="true"
                  version="true"
                 doctitle="&lt;h1&gt;${component.title}&lt;/h1&gt;"
              windowtitle="${component.title} (Version ${component.version})"
                   bottom="Copyright (c) 2001 - Apache Software Foundation"/>
    </target>
  
  
    <target name="dist" depends="compile,javadoc"
     description="Create binary distribution">
      <!-- TODO: top level files like LICENSE and README -->
      <mkdir      dir="${dist.home}"/>
      <jar    jarfile="${dist.home}/commons-${component.name}.jar"
              basedir="${build.home}/classes"
             manifest="${build.home}/conf/MANIFEST.MF"/>
      <mkdir      dir="${dist.home}/src"/>
      <copy     todir="${dist.home}/src" filtering="on">
        <fileset  dir="${source.home}"/>
      </copy>
    </target>
  
  
  <!-- ========== Unit Test Targets ========================================= -->
  
  
    <target name="test"  depends="compile.tests,
                                  test.property,
                                  test.bean
                                 "
     description="Run all unit test cases">
    </target>
  
  
    <target name="test.property">
      <echo message="Running PropertyUtils tests ..."/>
      <java classname="${test.runner}" fork="yes"
          failonerror="${test.failonerror}">
        <arg value="org.apache.commons.beanutils.PropertyUtilsTestCase"/>
        <classpath refid="test.classpath"/>
      </java>
    </target>
  
   <target name="test.bean">
      <echo message="Running BeanUtils tests ..."/>
      <java classname="${test.runner}" fork="yes"
          failonerror="${test.failonerror}">
        <arg value="org.apache.commons.beanutils.BeanUtilsTestCase"/>
        <classpath refid="test.classpath"/>
      </java>
    </target>
  
    <target name="test-cjan">
      <echo message="Testing cjan..."/>
  <!--    <cjan localRepository="${cjan.repository.local}" 
remoteRepository="test-remote">
      both of the repository values are assumed to be set in some properties file -->
      <cjan> 
        <get jar="xerces-1.3.1.jar" property="xerces.jar"/>
        <get jar="xalan-2.0.1.jar" property="xalan.jar"/>
        <get jar="junit-3.5.jar" property="junit.jar"/>
      </cjan>
      <echo message="property 'xerces.jar' is ${xerces.jar}"/>
      <echo message="property 'xalan.jar' is ${xalan.jar}"/>
      <echo message="property 'junit.jar' is ${junit.jar}"/>
      <echo message="Finished testing cjan."/>
    </target>
  
  </project>
  
  
  1.1                  jakarta-commons-sandbox/cjan/src/conf/MANIFEST.MF
  
  Index: MANIFEST.MF
  ===================================================================
  Extension-Name: @name@
  Specification-Vendor: Apache Software Foundation
  Specification-Version: 1.0
  Implementation-Vendor: Apache Software Foundation
  Implementation-Version: @version@
  
  
  
  
  1.1                  
jakarta-commons-sandbox/cjan/src/java/org/apache/tools/ant/taskdefs/optional/cjan/CJANGet.java
  
  Index: CJANGet.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.tools.ant.taskdefs.optional.cjan;
  
  
  import java.io.File;
  import java.net.URL;
  import java.io.InputStream;
  import java.io.FileOutputStream;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Task;
  
  /**
   * Class to provide get functionality for CJAN.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Scott Sanders</a>
   * @version $Revision: 1.1 $
   */
  public class CJANGet extends Object implements CJANSubTask
  {
      private String localRepo = null;
      private String remoteRepo = null;
      private Project project = null;
      private Task task = null;
      private String jar  = null;
      private String property  = null;
  
      public void execute(Project p, Task t, String local, String remote) throws 
BuildException
      {
          localRepo = local;
          remoteRepo = remote;
          project = p;
          task = t;
          String localFileName = localRepo + "/" + jar;
  
        project.log(task, "Checking for local file: " + 
                     localFileName, Project.MSG_ERR);
  
          File localFile = new File(localFileName);
  
          if (localFile.canRead())
          {
              project.log(task, "File: " + localFileName + 
                         " already exists.  No need to download.", 
                         Project.MSG_ERR);
        } else {
            try
          {
                URL remoteFile = new URL(remoteRepo + "/" + jar);
                project.log(task, "Attempting to download " + remoteFile.toString() + 
                            " to local repository.", Project.MSG_ERR);
        
                FileOutputStream out = new FileOutputStream(localFileName);
                InputStream in = remoteFile.openStream();
                
                byte[] buffer = new byte[8 * 1024];
                int count = 0;
                do {
                    out.write(buffer, 0, count);
                    count = in.read(buffer, 0, buffer.length);
                } while (count != -1);
  
                in.close();
                out.close();
                
          } catch (Exception e) {
              e.printStackTrace(System.out);
          }
        }
          if (project.getProperty(property) == null)
        {
              project.log(task, "Setting property " + property + 
                         " to " + localFileName, Project.MSG_ERR);
              project.setProperty(property, localFileName);
        }
      }
          
      /**
       *  Sets the jar name to get, if necessary
      */
      public void setJar(String j) 
      { 
          jar = j; 
      }
  
      /**
       *  Sets the name of the property to contain the path to the file
       */
      public void setProperty(String p)
      { 
          property = p; 
      }
  
  }
  
  
  
  
  
  
  
  
  
  
  1.1                  
jakarta-commons-sandbox/cjan/src/java/org/apache/tools/ant/taskdefs/optional/cjan/CJANSubTask.java
  
  Index: CJANSubTask.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.tools.ant.taskdefs.optional.cjan;
  
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Task;
  
  /**
   * Interface for all CJAN sub tasks.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Scott Sanders</a>
   * @version $Revision: 1.1 $
   */
  public interface CJANSubTask {
  
      public void execute(Project p, Task t, String localRepo, String remoteRepo) 
throws BuildException;
  
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/cjan/src/java/org/apache/tools/ant/taskdefs/optional/cjan/CJANSubTask.java~
  
  Index: CJANSubTask.java~
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.tools.ant.taskdefs.optional.cjan;
  
  
  import org.apache.tools.ant.BuildException;
  
  /**
   * Interface for all CJAN sub tasks.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Scott Sanders</a>
   * @version $Revision: 1.1 $
   */
  public interface CJANSubTask {
  
      public void execute() throws BuildException;
  
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/cjan/src/java/org/apache/tools/ant/taskdefs/optional/cjan/CJANTask.java
  
  Index: CJANTask.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.tools.ant.taskdefs.optional.cjan;
  
  
  import java.util.Enumeration;
  import java.util.Vector;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.DirectoryScanner;
  import org.apache.tools.ant.taskdefs.MatchingTask;
  import org.apache.tools.ant.BuildException;
  
  /**
   * Class to provide automated jar file download ala CPAN
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Scott Sanders</a>
   * @version $Revision: 1.1 $
   */
  
  public class CJANTask extends Task {
      
  
      public CJANTask()
      {
          super();
      }
  
      private void setDefaults()
      {
          if (getProject() != null)
          {
              if (localRepo == null)
            {
                  localRepo = getProject().getProperty("cjan.repository.local");
            }
              if (remoteRepo == null)
            {
                  remoteRepo = getProject().getProperty("cjan.repository.remote");
            }
        }        
        //System.err.println("localRepo in setDefaults is: " + localRepo);
          //System.err.println("remoteRepo in setDefaults is: " + remoteRepo);
      }
  
      /**
       *  The home directory of the local CJAN repository
       */
      private String localRepo  = null;
  
      /**
       *  The url of the remote repository
       */
      private String remoteRepo  = null;
  
      /**
       *  The list of read/write commands for this task
       */
      private Vector cjanTasks = new Vector();
  
      /** 
       *  Verify that all parameters are included. 
       *  Verify existence of local repoistory.
       *  Iterate through the list of gets 
       */
      public void execute() throws BuildException 
      {
          setDefaults();
          /**  A localRepo is required to continue */
          if (localRepo == null)
              throw new BuildException("No Local Repository Specified. Please set the 
cjan.repository.local property or set the localRepository attribute.");
  
          /**  A remoteRepo is required to continue */
          if (remoteRepo == null)
              throw new BuildException("No Remote Repository Specified. Please set the 
cjan.repository.remote property or set the remoteRepository attribute.");
  
          /**  Process each sub command */
          Enumeration tasksToRun = cjanTasks.elements();
          while (tasksToRun != null && tasksToRun.hasMoreElements())
          {
              CJANSubTask task = (CJANSubTask) tasksToRun.nextElement();
              task.execute(getProject(), (Task)this, localRepo, remoteRepo);
          }
      }
  
      /**
       *  Set the local repository attribute 
       */
      public void setLocalRepository(String r) { this.localRepo = r; }
  
      /**
       *  Set the remote repository attribute 
       */
      public void setRemoteRepository(String r) { this.remoteRepo = r; }
  
      /**
       *  A subTask &lt;get&gt; tag was found.  Create the object, 
       *  save it in our list, and return it.
       */
      public CJANSubTask createGet()
      {
          CJANSubTask task = new CJANGet();
          cjanTasks.addElement(task);
          return task;
      }
  
  }
  
  
  

Reply via email to