jvanzyl     02/04/10 23:22:23

  Modified:    src/java/org/apache/maven AntUtils.java BaseProjectTask.java
                        GetList.java
  Added:       src/java/org/apache/maven CreateClasspath.java
                        CreatePatternSet.java ListTask.java
  Log:
  A few more refactorings:
  
  Broke some of the functionality in ProjectProperties into AntUtils. I
  needed to be able to make a classpath and patternset from a list of
  JARs in a file so make the bootstrap maintainable.
  
  Added a few simple ant tasks that are now required by the bootstrap
  process.
  
  The upshot is almost all of the hardcoding has been removed from the
  bootstrap process.
  
  Revision  Changes    Path
  1.2       +2 -2      jakarta-turbine-maven/src/java/org/apache/maven/AntUtils.java
  
  Index: AntUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/AntUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntUtils.java     10 Apr 2002 03:10:27 -0000      1.1
  +++ AntUtils.java     11 Apr 2002 06:22:23 -0000      1.2
  @@ -68,7 +68,7 @@
    * sets of values.
    *
    * @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: AntUtils.java,v 1.1 2002/04/10 03:10:27 jvanzyl Exp $
  + * @version $Id: AntUtils.java,v 1.2 2002/04/11 06:22:23 jvanzyl Exp $
    */
   public class AntUtils
   {
  @@ -78,7 +78,7 @@
       public static void createClasspathReference(Project project, 
                                                   String reference,
                                                   List list,
  -                                                String baseDir)
  +                                                File baseDir)
       {
           Path classpath = new Path(project);
   
  
  
  
  1.3       +17 -2     
jakarta-turbine-maven/src/java/org/apache/maven/BaseProjectTask.java
  
  Index: BaseProjectTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/BaseProjectTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseProjectTask.java      5 Mar 2002 04:12:57 -0000       1.2
  +++ BaseProjectTask.java      11 Apr 2002 06:22:23 -0000      1.3
  @@ -72,7 +72,7 @@
    * An ant task for creating an xml schema from an sql schema
    *
    * @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
  - * @version $Id: BaseProjectTask.java,v 1.2 2002/03/05 04:12:57 jvanzyl Exp $
  + * @version $Id: BaseProjectTask.java,v 1.3 2002/04/11 06:22:23 jvanzyl Exp $
    */
   public class BaseProjectTask
       extends TexenTask
  @@ -93,14 +93,28 @@
       protected Project mavenProject;
   
       /**
  +     * The list of JARs used to create the maven classpath
  +     * which is used internally by Maven.
  +     */
  +    protected File listFile;
  +
  +    /**
        * Set the project descriptor file. This file must exist.
        */
  -    public void setProjectDescriptor (File projectDescriptor)
  +    public void setProjectDescriptor(File projectDescriptor)
       {
           this.projectDescriptor = projectDescriptor;
       }
   
       /**
  +     * Set the project descriptor file. This file must exist.
  +     */
  +    public void setListFile(File listFile)
  +    {
  +        this.listFile = listFile;
  +    }
  +
  +    /**
        * Execute the task.
        *
        * @throws BuildException
  @@ -119,6 +133,7 @@
               context.put("buildElements", new ArrayList());
               context.put("delegators", new HashMap());
               context.put("project", mavenProject);
  +            context.put("jars", ListTask.getList(listFile));
               return context;
           }
           catch (Exception e)
  
  
  
  1.2       +2 -45     jakarta-turbine-maven/src/java/org/apache/maven/GetList.java
  
  Index: GetList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/GetList.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetList.java      10 Apr 2002 02:36:58 -0000      1.1
  +++ GetList.java      11 Apr 2002 06:22:23 -0000      1.2
  @@ -76,9 +76,8 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    */
   public class GetList
  -    extends Task
  +    extends ListTask
   {
  -    private File list;
       private File dest;
       private boolean verbose = false;
       private boolean useTimestamp = true;
  @@ -98,11 +97,6 @@
           this.dest = dest;
       }
   
  -    public void setList(File list)
  -    {
  -        this.list = list;
  -    }        
  -    
       /**
        * Sets the baseUrl attribute of the Get object
        */
  @@ -151,7 +145,7 @@
               throw new BuildException("Can't write to " + dest.getAbsolutePath());
           }
   
  -        for (Iterator j = getList(list).iterator(); j.hasNext(); )
  +        for (Iterator j = getList(getListFile()).iterator(); j.hasNext(); )
           {
               try
               {
  @@ -167,43 +161,6 @@
                   throw new BuildException(e);
               }
           }
  -    }
  -
  -    public List getList(File f)
  -    {
  -        List list = new ArrayList();
  -        String line;
  -        
  -        try
  -        {
  -            BufferedReader in = new BufferedReader(new FileReader(f));
  -            while ((line=in.readLine()) != null)
  -            {
  -                line = line.trim();
  -                
  -                // Allow comments to be placed in the payload
  -                // descriptor.
  -                if (line.startsWith("#") || line.startsWith("--") || line.length() 
< 1)
  -                {
  -                    continue;
  -                }
  -                
  -                // The name of the non-dist JAR is the key, and the value is the
  -                // location where the user can find it.
  -                list.add(line);
  -            }
  -        }
  -        catch (Exception e)
  -        {
  -        }
  -        
  -        return list;
  -    }
  -
  -    // We need to move to the commons-logging goodies here.
  -    private static void logx(String message)
  -    {
  -        System.out.println(message);
       }
   
       /**
  
  
  
  1.1                  
jakarta-turbine-maven/src/java/org/apache/maven/CreateClasspath.java
  
  Index: CreateClasspath.java
  ===================================================================
  package org.apache.maven;
  
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 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/>.
   */
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.BufferedReader;
  import java.io.FileReader;
  
  import java.net.URL;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Iterator;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  /**
   * Get a list of resources from a website.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
   */
  public class CreateClasspath
      extends ListTask
  {
      /**
       * Ant project reference for the patternset.
       */
      private String reference;
  
      /**
       * Base directory from which to build the classpath.
       */
      private File baseDir;
  
      /**
       * Set the name of the reference.
       */
      public void setReference(String reference)
      {
          this.reference = reference;
      }
  
      /**
       * Set the name of the reference.
       */
      public void setBaseDir(File baseDir)
      {
          this.baseDir = baseDir;
      }
  
      /**
       * Does the work.
       *
       * @exception Exception Thrown in unrecoverable error.
       */
      public void execute()
          throws BuildException
      {
          AntUtils.createClasspathReference(project, reference, 
getList(getListFile()), baseDir);
      }
  }
  
  
  
  1.4       +38 -130   
jakarta-turbine-maven/src/java/org/apache/maven/CreatePatternSet.java
  
  
  
  
  1.1                  jakarta-turbine-maven/src/java/org/apache/maven/ListTask.java
  
  Index: ListTask.java
  ===================================================================
  package org.apache.maven;
  
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 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/>.
   */
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.BufferedReader;
  import java.io.FileReader;
  
  import java.util.List;
  import java.util.ArrayList;
  import java.util.Iterator;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  /**
   * Get a list of resources from a website.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
   */
  public abstract class ListTask
      extends Task
  {
      /**
       * The file containing the list of values to process.
       */
      private File listFile;
  
      /**
       * Set the list of values to process.
       */
      public void setListFile(File listFile)
      {
          this.listFile = listFile;
      }        
  
      /**
       * Get the list of values to process.
       */
      public File getListFile()
      {
          return listFile;
      }        
  
      /**
       * Does the work.
       *
       * @exception Exception Thrown in unrecoverable error.
       */
      public abstract void execute() throws BuildException;
  
      /**
       * Read the file that contains the list of values into
       * a List.
       */
      public static List getList(File f)
      {
          List list = new ArrayList();
          String line;
          
          try
          {
              BufferedReader in = new BufferedReader(new FileReader(f));
              while ((line=in.readLine()) != null)
              {
                  line = line.trim();
                  
                  // Allow comments to be placed in the payload
                  // descriptor.
                  if (line.startsWith("#") || line.startsWith("--") || line.length() < 
1)
                  {
                      continue;
                  }
                  
                  list.add(line);
              }
          }
          catch (Exception e)
          {
          }
          
          return list;
      }
  
      // We need to move to the commons-logging goodies here.
      protected static void logx(String message)
      {
          System.out.println(message);
      }
  }
  
  
  


Reply via email to