dion        02/04/14 00:33:29

  Modified:    src/java/org/apache/maven ChangeLog.java
  Log:
  - Stop ChangeLog aborting when cvs executable isn't present
  - this version works with Win32
  
  Revision  Changes    Path
  1.34      +41 -19    jakarta-turbine-maven/src/java/org/apache/maven/ChangeLog.java
  
  Index: ChangeLog.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/ChangeLog.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ChangeLog.java    8 Apr 2002 22:52:09 -0000       1.33
  +++ ChangeLog.java    14 Apr 2002 07:33:29 -0000      1.34
  @@ -65,6 +65,7 @@
   import java.io.PrintWriter;
   import java.io.UnsupportedEncodingException;
   import java.text.SimpleDateFormat;
  +import java.util.Arrays;
   import java.util.Collection;
   import java.util.Date;
   import java.util.Iterator;
  @@ -94,7 +95,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>dIon Gillard</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefan Bodewig</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Donald</a>
  - * @version $Id: ChangeLog.java,v 1.33 2002/04/08 22:52:09 dion Exp $
  + * @version $Id: ChangeLog.java,v 1.34 2002/04/14 07:33:29 dion Exp $
    */
   public class ChangeLog extends ProjectExecutor implements ExecuteStreamHandler
   {
  @@ -200,9 +201,13 @@
       
       /**
        * Execute task.
  -     * @throws Exception as a catch all in the super class
  +     * @throws FileNotFoundException if {@link ChangeLog#base} doesn't exist
  +     * @throws IOException if there are problems running CVS
  +     * @throws UnsupportedEncodingException if the underlying platform doesn't
  +     *      support UTF-8 encoding
        */
  -    public void doExecute() throws Exception
  +    public void doExecute() throws FileNotFoundException, IOException, 
  +        UnsupportedEncodingException
       {
           if (base == null)
           {
  @@ -219,24 +224,37 @@
               throw new FileNotFoundException(
                   "Cannot find base dir " + base.getAbsolutePath());
           }
  -
  -        Execute exe = new Execute(this);
  -        exe.setCommandline(getCvsLogCommand().getCommandline());
  -        exe.setAntRun(getProject());
  -        exe.setWorkingDirectory(base);
  -        exe.execute();
  -        
  -        log("ChangeLog found: " + getEntries().size() + " entries");
  -
  -        replaceAuthorIdWithName();
  -        
  -        // log messages from stderr
  -        String errors = errorReader.toString().trim();
  -        if (errors.length() > 0)
  +        try 
           {
  -            log(errors);
  +            Execute exe = new Execute(this);
  +            exe.setCommandline(getCvsLogCommand().getCommandline());
  +            exe.setAntRun(getProject());
  +            exe.setWorkingDirectory(base);
  +            exe.execute();
  +
  +            log("ChangeLog found: " + getEntries().size() + " entries");
  +
  +            replaceAuthorIdWithName();
  +
  +            // log messages from stderr
  +            String errors = errorReader.toString().trim();
  +            if (errors.length() > 0)
  +            {
  +                log(errors);
  +            }
  +        }
  +        catch (IOException ioe)
  +        {
  +            if (ioe.getMessage().indexOf("CreateProcess") != -1) 
  +            {
  +                // can't find CVS on Win32
  +                log("Unable to find cvs executable. Changelog will be empty");
  +            }
  +            else
  +            {
  +                throw ioe;
  +            }
           }
  -        
           createDocument();
   
       }
  @@ -357,6 +375,10 @@
        * @return Value of property entries.
        */
       public Collection getEntries() {
  +        if (entries == null) 
  +        {
  +            entries = Arrays.asList(new Object[0]);
  +        }
           return entries;
       }
       
  
  
  


Reply via email to