//
// $Id: DigesterTask.java,v 1.3 2004/07/30 02:23:52 mdb Exp $

package com.threerings.getdown.tools;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

import com.threerings.getdown.data.Application;
import com.threerings.getdown.data.Digest;

/**
 * An ant task used to create a <code>digest.txt</code> for a Getdown
 * application deployment.
 */
public class DigesterTask extends Task
{
    /**
     * Sets the application directory.
     */
    public void setAppdir (File appdir)
    {
        _appdir = appdir;
    }

    /**
     * Performs the actual work of the task.
     */
    public void execute () throws BuildException
    {
        // make sure appdir is set
        if (_appdir == null) {
            String errmsg = "Must specify the path to the application " +
                "directory  via the 'appdir' attribute.";
            throw new BuildException(errmsg);
        }
        File target = new File(_appdir, Digest.DIGEST_FILE);
        System.out.println("Generating digest file '" + target + "'...");

        // create our application and instruct it to parse its business
        Application app = new Application(_appdir);
        try {
            app.init(false);
        } catch (IOException ioe) {
            throw new BuildException("Error parsing getdown.txt: " +
                                     ioe.getMessage(), ioe);
        }

        ArrayList rsrcs = new ArrayList();
        rsrcs.add(app.getConfigResource());
        rsrcs.addAll(app.getCodeResources());
        rsrcs.addAll(app.getResources());

        // now generate the digest file
        try {
            Digest.createDigest(rsrcs, target);
        } catch (IOException ioe) {
            throw new BuildException("Error creating digest: " +
                                     ioe.getMessage(), ioe);
        }
    }

    /** The application directory in which we're creating a digest file. */
    protected File _appdir;
}

@@ -30,28 +30,28 @@
 v 1.
-3
+4
  2004/0
-7/30 02
+8/10 07
 :23:
-5
+1
 2 md
@@ -992,24 +992,421 @@
 );%0A        %7D
+%0A%0A        try %7B%0A            createDigest(_appdir);%0A        %7D catch (IOException ioe) %7B%0A            throw new BuildException(%22Error creating digest: %22 +%0A                                     ioe.getMessage(), ioe);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Creates a digest file in the specified application directory.%0A     */%0A    public static void createDigest (File appdir)%0A        throws IOException%0A    %7B
 %0A        Fil
@@ -1425,17 +1425,16 @@
 ew File(
-_
 appdir, 
@@ -1643,17 +1643,16 @@
 ication(
-_
 appdir);
@@ -1664,218 +1664,24 @@
     
-try %7B%0A            app.init(false);%0A        %7D catch (IOException ioe) %7B%0A            throw new BuildException(%22Error parsing getdown.txt: %22 +%0A                                     ioe.getMessage(), ioe);%0A        %7D
+app.init(false);
 %0A%0A  
@@ -1894,34 +1894,16 @@
 st file%0A
-        try %7B%0A    
         
@@ -1942,180 +1942,8 @@
 t);%0A
-        %7D catch (IOException ioe) %7B%0A            throw new BuildException(%22Error creating digest: %22 +%0A                                     ioe.getMessage(), ioe);%0A        %7D%0A
     

Allow digests to be easily created externally.