You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by db...@apache.org on 2005/12/08 10:10:18 UTC

svn commit: r355049 - in /geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent: GZipUtils.java LogFailedBuildsExtension.java

Author: dblevins
Date: Thu Dec  8 01:10:17 2005
New Revision: 355049

URL: http://svn.apache.org/viewcvs?rev=355049&view=rev
Log:
Write a descriptive header to the top of the build output file

Modified:
    geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/GZipUtils.java
    geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/LogFailedBuildsExtension.java

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/GZipUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/GZipUtils.java?rev=355049&r1=355048&r2=355049&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/GZipUtils.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/GZipUtils.java Thu Dec  8 01:10:17 2005
@@ -89,4 +89,32 @@
             IOUtil.close(in);
         }
     }
+
+    /**
+     * Writes data to a file. The file will be created if it does not exist.
+     *
+     * @param file  The name of the file to write.
+     * @param bytes The GZipped content to write to the file.
+     */
+    public static void fileAppend(File file, byte[] bytes) throws IOException {
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+
+        GZIPInputStream in = new GZIPInputStream(bais);
+
+        FileOutputStream out = null;
+
+        try {
+            out = new FileOutputStream(file, true);
+            int count;
+            byte[] b = new byte[512];
+            while ((count = in.read(b)) > 0) {
+                out.write(b, 0, count);
+            }
+        }
+        finally {
+            IOUtil.close(out);
+            IOUtil.close(in);
+        }
+    }
 }

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/LogFailedBuildsExtension.java
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/LogFailedBuildsExtension.java?rev=355049&r1=355048&r2=355049&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/LogFailedBuildsExtension.java (original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/LogFailedBuildsExtension.java Thu Dec  8 01:10:17 2005
@@ -24,6 +24,7 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.FileUtils;
 
 import java.io.File;
 import java.io.IOException;
@@ -31,6 +32,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.net.InetAddress;
 
 /**
  * @version $Rev$ $Date$
@@ -55,6 +57,7 @@
     private String dateFormat;
     private SimpleDateFormat dateFormatter;
 
+    private StringTemplate header = new StringTemplate("#   Date: {date}\n#   Project: {project.name}-{project.version}\n#   OS: {os.name} - {os.version}\n#   Java: {java.version} - {java.vendor}\n#   Host: {host-name} {host-address}\n#   Contributor: {contributor} {admin-address}\n");
 
     public void start() throws StartingException {
         template = new StringTemplate(fileNameTemplate);
@@ -122,9 +125,12 @@
 
         parent.mkdirs();
 
-
         try {
-            GZipUtils.fileWrite(file, bytes);
+
+            FileUtils.fileWrite(file.getAbsolutePath(), header.apply(map));
+
+            GZipUtils.fileAppend(file, bytes);
+
         } catch (IOException e) {
             getLogger().error("Could not write to file " + file.getAbsolutePath(), e);
         }