FileDocCategorySizeDatePackage
AntResolver.javaAPI DocApache Ant 1.703370Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.extension.resolvers

AntResolver

public class AntResolver extends Object implements org.apache.tools.ant.taskdefs.optional.extension.ExtensionResolver
Resolver that just returns s specified location.

Fields Summary
private File
antfile
private File
destfile
private String
target
Constructors Summary
Methods Summary
public java.io.Fileresolve(org.apache.tools.ant.taskdefs.optional.extension.Extension extension, org.apache.tools.ant.Project project)
Returns the resolved file

param
extension the extension
param
project the project
return
the file resolved
throws
BuildException if the file cannot be resolved

        validate();

        final Ant ant = new Ant();
        ant.setProject(project);
        ant.setInheritAll(false);
        ant.setAntfile(antfile.getName());

        try {
            final File dir =
                antfile.getParentFile().getCanonicalFile();
            ant.setDir(dir);
        } catch (final IOException ioe) {
            throw new BuildException(ioe.getMessage(), ioe);
        }

        if (null != target) {
            ant.setTarget(target);
        }

        ant.execute();

        return destfile;
    
public voidsetAntfile(java.io.File antfile)
Sets the ant file

param
antfile the ant file to set

        this.antfile = antfile;
    
public voidsetDestfile(java.io.File destfile)
Sets the destination file

param
destfile the destination file

        this.destfile = destfile;
    
public voidsetTarget(java.lang.String target)
Sets the target

param
target the target

        this.target = target;
    
public java.lang.StringtoString()
Returns a string representation

return
the string representation

        return "Ant[" + antfile + "==>" + destfile + "]";
    
private voidvalidate()

        if (null == antfile) {
            final String message = "Must specify Buildfile";
            throw new BuildException(message);
        }

        if (null == destfile) {
            final String message = "Must specify destination file";
            throw new BuildException(message);
        }