You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Brett Porter <bp...@f2network.com.au> on 2003/01/08 23:42:13 UTC

[PATCH] bug MAVEN-115

Attached is a patch to two files so that an exception is printed if the 
plugin directory is not writable.

Also, I have patched maven startup script to take MAVEN_OPTS out of the 
environment. Useful for creating a "start in JPDA debug mode" script.

All are against CVS HEAD.

Cheers,
Brett

aargh Re: [PATCH] bug MAVEN-115

Posted by Brett Porter <bp...@f2network.com.au>.
Sorry, I worked on this at home and just realised I had a sticky tag to 
beta 7. This patch probably isn't very useful anymore.

- Brett

Brett Porter wrote:
> Attached is a patch to two files so that an exception is printed if the 
> plugin directory is not writable.
> 
> Also, I have patched maven startup script to take MAVEN_OPTS out of the 
> environment. Useful for creating a "start in JPDA debug mode" script.
> 
> All are against CVS HEAD.
> 
> Cheers,
> Brett
> 
> 
> ------------------------------------------------------------------------
> 
> Index: Expand.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-maven/src/java/org/apache/maven/app/Attic/Expand.java,v
> retrieving revision 1.2
> diff -c -r1.2 Expand.java
> *** Expand.java	17 Jul 2002 15:14:05 -0000	1.2
> --- Expand.java	8 Jan 2003 22:24:59 -0000
> ***************
> *** 67,72 ****
> --- 67,75 ----
>   import java.util.zip.ZipInputStream;
>   import java.util.zip.ZipEntry;
>   
> + import org.apache.commons.logging.Log;
> + import org.apache.commons.logging.LogFactory;
> + 
>   /**
>    * Unzip a file.
>    *
> ***************
> *** 78,83 ****
> --- 81,91 ----
>    */
>   public class Expand
>   {
> +     /**
> +      * Log.
> +      */
> +     private final static Log log = LogFactory.getLog(Expand.class);
> + 
>       private File dest;//req
>       private File source;// req
>       private boolean overwrite = true;
> ***************
> *** 85,94 ****
>       /**
>        * Do the work.
>        *
> !      * @exception BuildException Thrown in unrecoverable error.
>        */
> !     public void execute()
> !         throws Exception
>       {
>           FileUtils fileUtils = FileUtils.newFileUtils();
>           expandFile(fileUtils, source, dest);
> --- 93,101 ----
>       /**
>        * Do the work.
>        *
> !      * @exception IOException Thrown in unrecoverable error.
>        */
> !     public void execute() throws IOException
>       {
>           FileUtils fileUtils = FileUtils.newFileUtils();
>           expandFile(fileUtils, source, dest);
> ***************
> *** 100,106 ****
>       /**
>        * Description of the Method
>        */
> !     protected void expandFile(FileUtils fileUtils, File srcF, File dir)
>       {
>           ZipInputStream zis = null;
>           try
> --- 107,113 ----
>       /**
>        * Description of the Method
>        */
> !     protected void expandFile(FileUtils fileUtils, File srcF, File dir) throws IOException
>       {
>           ZipInputStream zis = null;
>           try
> ***************
> *** 116,127 ****
>                       ze.isDirectory());
>               }
>   
> !             //log("expand complete", Project.MSG_VERBOSE);
> !         }
> !         catch (IOException ioe)
> !         {
> !             //throw new BuildException("Error while expanding " + srcF.getPath(),
> !               //  ioe);
>           }
>           finally
>           {
> --- 123,129 ----
>                       ze.isDirectory());
>               }
>   
> !             log.info("expand complete");
>           }
>           finally
>           {
> ***************
> *** 147,211 ****
>           throws IOException
>       {
>           File f = fileUtils.resolveFile(dir, entryName);
> !         try
>           {
> !             if (!overwrite && f.exists()
> !                  && f.lastModified() >= entryDate.getTime())
> !             {
> !                 //log("Skipping " + f + " as it is up-to-date",
> !                   //  Project.MSG_DEBUG);
> !                 return;
> !             }
>   
> !             //log("expanding " + entryName + " to " + f,
> !               //  Project.MSG_VERBOSE);
> !             // create intermediary directories - sometimes zip don't add them
> !             File dirF = f.getParentFile();
> !             //File dirF = fileUtils.getParentFile(f);
> !             dirF.mkdirs();
>   
> !             if (isDirectory)
> !             {
> !                 f.mkdirs();
> !             }
> !             else
>               {
> !                 byte[] buffer = new byte[1024];
> !                 int length = 0;
> !                 FileOutputStream fos = null;
> !                 try
> !                 {
> !                     fos = new FileOutputStream(f);
>   
> !                     while ((length =
> !                         compressedInputStream.read(buffer)) >= 0)
> !                     {
> !                         fos.write(buffer, 0, length);
> !                     }
> ! 
> !                     fos.close();
> !                     fos = null;
>                   }
> !                 finally
>                   {
> !                     if (fos != null)
>                       {
> !                         try
> !                         {
> !                             fos.close();
> !                         }
> !                         catch (IOException e)
> !                         {}
>                       }
>                   }
>               }
> - 
> -             fileUtils.setFileLastModified(f, entryDate.getTime());
>           }
> !         catch (FileNotFoundException ex)
> !         {
> !         }
> ! 
>       }
>   
>       /**
> --- 149,203 ----
>           throws IOException
>       {
>           File f = fileUtils.resolveFile(dir, entryName);
> !         if (!overwrite && f.exists()
> !              && f.lastModified() >= entryDate.getTime())
>           {
> !             log.debug("Skipping " + f + " as it is up-to-date");
> !             return;
> !         }
>   
> !         log.info("expanding " + entryName + " to " + f);
> !         // create intermediary directories - sometimes zip don't add them
> !         File dirF = f.getParentFile();
> !         //File dirF = fileUtils.getParentFile(f);
> !         dirF.mkdirs();
>   
> !         if (isDirectory)
> !         {
> !             f.mkdirs();
> !         }
> !         else
> !         {
> !             byte[] buffer = new byte[1024];
> !             int length = 0;
> !             FileOutputStream fos = null;
> !             try
>               {
> !                 fos = new FileOutputStream(f);
>   
> !                 while ((length =
> !                     compressedInputStream.read(buffer)) >= 0)
> !                 {
> !                     fos.write(buffer, 0, length);
>                   }
> ! 
> !                 fos.close();
> !                 fos = null;
> !             }
> !             finally
> !             {
> !                 if (fos != null)
>                   {
> !                     try
>                       {
> !                         fos.close();
>                       }
> +                     catch (IOException e)
> +                     {}
>                   }
>               }
>           }
> !         fileUtils.setFileLastModified(f, entryDate.getTime());
>       }
>   
>       /**
> 
> 
> ------------------------------------------------------------------------
> 
> Index: PluginManager.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-maven/src/java/org/apache/maven/app/Attic/PluginManager.java,v
> retrieving revision 1.33
> diff -c -r1.33 PluginManager.java
> *** PluginManager.java	30 Sep 2002 04:12:56 -0000	1.33
> --- PluginManager.java	8 Jan 2003 22:24:43 -0000
> ***************
> *** 85,90 ****
> --- 85,91 ----
>   import com.werken.forehead.Forehead;
>   
>   import org.apache.maven.MavenUtils;
> + import org.apache.maven.MavenException;
>   import org.apache.maven.CreateDependencyClasspath;
>   import org.apache.maven.project.Dependency;
>   import org.apache.maven.project.Project;
> ***************
> *** 189,198 ****
>                   
>                   if (!unzipDir.exists())
>                   {
> !                     Expand unzipper = new Expand();
> !                     unzipper.setSrc(files[i]);
> !                     unzipper.setDest(unzipDir);
> !                     unzipper.execute();
>                   }                    
>               }
>           }
> --- 190,207 ----
>                   
>                   if (!unzipDir.exists())
>                   {
> !                     try {
> !                         Expand unzipper = new Expand();
> !                         unzipper.setSrc(files[i]);
> !                         unzipper.setDest(unzipDir);
> !                         unzipper.execute();
> !                     }
> !                     catch (IOException e) {
> !                         log.error("can't unzip plugin", e);
> !                         throw new MavenException("Unable to extract plugin: "
> !                            + files[i] + 
> !                            ". The plugin directory is not writable.", e);
> !                     }
>                   }                    
>               }
>           }
> 
> 
> ------------------------------------------------------------------------
> 
> Index: src/bin/maven
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-maven/src/bin/maven,v
> retrieving revision 1.16
> diff -c -r1.16 maven
> *** src/bin/maven	8 Sep 2002 03:57:58 -0000	1.16
> --- src/bin/maven	8 Jan 2003 22:27:49 -0000
> ***************
> *** 5,11 ****
>   
>   FOREHEAD_VERSION=1.0-beta-4
>   
> ! MAVEN_OPTS="-Xmx128m"
>   
>   if [ -f "$HOME/.mavenrc" ] ; then 
>     . $HOME/.mavenrc
> --- 5,11 ----
>   
>   FOREHEAD_VERSION=1.0-beta-4
>   
> ! MAVEN_OPTS="$MAVEN_OPTS -Xmx128m"
>   
>   if [ -f "$HOME/.mavenrc" ] ; then 
>     . $HOME/.mavenrc
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>