hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind/hivebuild dependency.xml clover-report.xml
Date Tue, 16 Nov 2004 19:01:39 GMT
hlship      2004/11/16 11:01:39

  Modified:    hivebuild/src/java/org/apache/hivemind/build Grabber.java
               hivebuild dependency.xml clover-report.xml
  Log:
  Maven downloads no longer have .md5 files, so fix the Grabber to not expect them.
  
  Revision  Changes    Path
  1.4       +7 -117    jakarta-hivemind/hivebuild/src/java/org/apache/hivemind/build/Grabber.java
  
  Index: Grabber.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/hivebuild/src/java/org/apache/hivemind/build/Grabber.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Grabber.java	10 Aug 2004 14:40:18 -0000	1.3
  +++ Grabber.java	16 Nov 2004 19:01:39 -0000	1.4
  @@ -19,14 +19,9 @@
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.io.InputStreamReader;
   import java.io.OutputStream;
  -import java.net.MalformedURLException;
   import java.net.URL;
   import java.net.URLConnection;
  -import java.security.DigestInputStream;
  -import java.security.MessageDigest;
  -import java.security.NoSuchAlgorithmException;
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  @@ -41,14 +36,14 @@
    * <li>Has additional parameter for specifying where the MD5 sum is stored
    * <li>Less verbose --- no output if the file isn't downloaded
    * </ul>
  - *
  + * 
    * @author Howard Lewis Ship
    */
   public class Grabber extends Task
   {
       private URL _src;
  +
       private File _dest;
  -    private URL _md5;
   
       public void execute() throws BuildException
       {
  @@ -68,9 +63,7 @@
                   return;
   
               if (!_dest.canWrite())
  -                throw new BuildException(
  -                    "Can't write to " + _dest.getAbsolutePath(),
  -                    getLocation());
  +                throw new BuildException("Can't write to " + _dest.getAbsolutePath(), getLocation());
           }
   
           try
  @@ -80,10 +73,7 @@
   
               connection.connect();
   
  -            MessageDigest digest = copyConnectionToFile(connection);
  -
  -            if (_md5 != null)
  -                compareMD5(digest);
  +            copyConnectionToFile(connection);
           }
           catch (IOException ex)
           {
  @@ -96,32 +86,12 @@
           return file.length() > 0;
       }
   
  -    private MessageDigest copyConnectionToFile(URLConnection connection) throws IOException
  +    private void copyConnectionToFile(URLConnection connection) throws IOException
       {
           log("Downloading " + _src + " to " + _dest);
   
  -        MessageDigest result = null;
  -
  -        if (_md5 != null)
  -        {
  -            try
  -            {
  -                result = MessageDigest.getInstance("MD5");
  -            }
  -            catch (NoSuchAlgorithmException ex)
  -            {
  -                throw new BuildException(
  -                    "No MD5 message digest provider: " + ex.getMessage(),
  -                    ex,
  -                    getLocation());
  -            }
  -        }
  -
           InputStream is = open(connection);
   
  -        if (result != null)
  -            is = new DigestInputStream(is, result);
  -
           FileOutputStream fos = new FileOutputStream(_dest);
           OutputStream os = new BufferedOutputStream(fos);
   
  @@ -139,52 +109,6 @@
   
           is.close();
           os.close();
  -
  -        return result;
  -    }
  -
  -    private void compareMD5(MessageDigest digest) throws IOException
  -    {
  -        String downloadedDigest = createDigestString(digest);
  -
  -        URLConnection connection = _md5.openConnection();
  -
  -        InputStream is = open(connection);
  -
  -        InputStreamReader reader = new InputStreamReader(is);
  -
  -        StringBuffer buffer = new StringBuffer();
  -
  -        while (true)
  -        {
  -            int ch = reader.read();
  -
  -            if (ch < 0)
  -                break;
  -
  -            buffer.append((char) ch);
  -        }
  -
  -        reader.close();
  -
  -        String recordedDigest = buffer.toString().trim();
  -
  -        // Sometimes a digest has a string identifying the file after the hex string; discard
  -        // that.
  -
  -        int firstSpace = recordedDigest.indexOf(' ');
  -        if (firstSpace > 0)
  -            recordedDigest = recordedDigest.substring(0, firstSpace);
  -
  -        if (downloadedDigest.equals(recordedDigest))
  -            return;
  -
  -        throw new BuildException(
  -            "Downloaded file had an MD5 sum of "
  -                + downloadedDigest
  -                + " but the expected sum was "
  -                + recordedDigest,
  -            getLocation());
       }
   
       private InputStream open(URLConnection connection)
  @@ -202,10 +126,8 @@
               catch (IOException ex)
               {
                   if (i++ == 3)
  -                    throw new BuildException(
  -                        "Unable to open " + _src + ": " + ex.getMessage(),
  -                        ex,
  -                        getLocation());
  +                    throw new BuildException("Unable to open " + _src + ": " + ex.getMessage(),
ex,
  +                            getLocation());
               }
           }
   
  @@ -215,41 +137,9 @@
           return result;
       }
   
  -    private String createDigestString(MessageDigest digest)
  -    {
  -        byte[] bytes = digest.digest();
  -
  -        StringBuffer buffer = new StringBuffer();
  -        for (int i = 0; i < bytes.length; i++)
  -        {
  -            String hex = Integer.toHexString(0x00ff & bytes[i]);
  -            if (hex.length() < 2)
  -                buffer.append("0");
  -
  -            buffer.append(hex);
  -        }
  -
  -        return buffer.toString();
  -    }
  -
       public void setDest(File file)
       {
           _dest = file;
  -    }
  -
  -    public void setMd5(String url)
  -    {
  -        if (url == null || url.length() == 0)
  -            return;
  -
  -        try
  -        {
  -            _md5 = new URL(url);
  -        }
  -        catch (MalformedURLException ex)
  -        {
  -            log("Error in md5: " + ex.getMessage());
  -        }
       }
   
       public void setSrc(URL url)
  
  
  
  1.8       +2 -4      jakarta-hivemind/hivebuild/dependency.xml
  
  Index: dependency.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/hivebuild/dependency.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- dependency.xml	21 Aug 2004 17:43:17 -0000	1.7
  +++ dependency.xml	16 Nov 2004 19:01:39 -0000	1.8
  @@ -27,14 +27,13 @@
     <macrodef name="grab-file">
       <attribute name="src" description="The URL of the file to download."/>
       <attribute name="dest" description="The directory and file to copy to."/>
  -    <attribute name="md5" description="The URL of an MD5 checksum file used to verify
that the file was downloaded without errors." default=""/>
       <sequential>
         <mkdir dir="${hivebuild.classes.dir}"/>
         <javac includeantruntime="yes"
           srcdir="${hivebuild.src.dir}"
           destdir="${hivebuild.classes.dir}"/>
       	<taskdef classname="org.apache.hivemind.build.Grabber" name="grabber" classpathref="grabber.classpath"/>
  -      <grabber src="@{src}" dest="@{dest}" md5="@{md5}"/>
  +      <grabber src="@{src}" dest="@{dest}"/>
       </sequential>
     </macrodef>
   
  @@ -108,8 +107,7 @@
   
   			<grab-file
   				dest="${external.lib.dir}/@{artifact}-@{version}.jar"
  -				src="${maven.ibiblio.url}/@{group}/jars/@{artifact}-@{version}.jar" 
  -				md5="${maven.ibiblio.url}/@{group}/jars/@{artifact}-@{version}.jar.md5"
  +				src="${maven.ibiblio.url}/@{group}/jars/@{artifact}-@{version}.jar"
   				/>
   
         <module-lib-copy 
  
  
  
  1.3       +1 -2      jakarta-hivemind/hivebuild/clover-report.xml
  
  Index: clover-report.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/hivebuild/clover-report.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- clover-report.xml	28 Jul 2004 19:19:35 -0000	1.2
  +++ clover-report.xml	16 Nov 2004 19:01:39 -0000	1.3
  @@ -14,8 +14,7 @@
   	<target name="-check-for-clover" unless="clover.available">
   		<antcall target="-display-download-warning"/>
   		<grab-file dest="${ant.home}/lib/${clover.jar}"
  -			src="${maven.ibiblio.url}/clover/jars/${clover.jar}"
  -			md5="${maven.ibiblio.url}/clover/jars/${clover.jar}.md5" />
  +			src="${maven.ibiblio.url}/clover/jars/${clover.jar}" />
   		<echo><![CDATA[
   		
   *** Clover has been installed into ${ant.home}/lib. 
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message