FileDocCategorySizeDatePackage
DotnetBaseMatchingTask.javaAPI DocApache Ant 1.706298Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.dotnet

DotnetBaseMatchingTask

public class DotnetBaseMatchingTask extends org.apache.tools.ant.taskdefs.MatchingTask
refactoring of some stuff so that different things (like ILASM) can use shared code.

Fields Summary
protected File
outputFile
output file. If not supplied this is derived from the source file
protected Vector
filesets
filesets of file to compile
protected File
srcDir
source directory upon which the search pattern is applied
protected static final boolean
isWindows
Are we running on Windows?
Constructors Summary
Methods Summary
protected voidaddFilesAndExecute(NetCommand command, boolean ignoreTimestamps)
finish off the command by adding all dependent files, execute

param
command the command to update.
param
ignoreTimestamps not used.

        long outputTimestamp = getOutputFileTimestamp();
        Hashtable filesToBuild = new Hashtable();
        int filesOutOfDate = buildFileList(command, filesToBuild, outputTimestamp);

        //now run the command of exe + settings + files
        if (filesOutOfDate > 0) {
            //add the files to the command
            addFilesToCommand(filesToBuild, command);
            command.runCommand();
        } else {
            log("output file is up to date", Project.MSG_VERBOSE);
        }
    
protected voidaddFilesToCommand(java.util.Hashtable filesToBuild, NetCommand command)
add the list of files to a command

param
filesToBuild vector of files
param
command the command to append to

        int count = filesToBuild.size();
        log("compiling " + count + " file" + ((count == 1) ? "" : "s"),
                Project.MSG_VERBOSE);
        Enumeration files = filesToBuild.elements();
        while (files.hasMoreElements()) {
            File file = (File) files.nextElement();
            command.addArgument(file.toString());
        }
    
public voidaddSrc(org.apache.tools.ant.types.FileSet src)
add a new source directory to the compile

param
src a fileset.

        filesets.add(src);
    
protected intbuildFileList(NetCommand command, java.util.Hashtable filesToBuild, long outputTimestamp)
create the list of files

param
command the command to create the files for.
param
filesToBuild vector to add files to
param
outputTimestamp timestamp to compare against
return
number of files out of date

        int filesOutOfDate = 0;
        boolean scanImplicitFileset
            = getSrcDir() != null || filesets.size() == 0;
        if (scanImplicitFileset) {
            //scan for an implicit fileset if there was a srcdir set
            //or there was no srcDir set but there was no contained classes
            if (getSrcDir() == null) {
                //if there is no src dir here, set it
                setSrcDir(getProject().resolveFile("."));
            }
            log("working from source directory " + getSrcDir(),
                    Project.MSG_VERBOSE);
            //get dependencies list.
            DirectoryScanner scanner = getDirectoryScanner(getSrcDir());
            filesOutOfDate = command.scanOneFileset(scanner,
                    filesToBuild, outputTimestamp);
        }
        //get any included source directories
        for (int i = 0; i < filesets.size(); i++) {
            FileSet fs = (FileSet) filesets.elementAt(i);
            filesOutOfDate += command.scanOneFileset(
                    fs.getDirectoryScanner(getProject()),
                    filesToBuild,
                    outputTimestamp);
        }

        return filesOutOfDate;
    
public java.io.FilegetDestFile()
get the destination file

return
the dest file or null for not assigned

        return outputFile;
    
protected longgetOutputFileTimestamp()
determine the timestamp of the output file

return
a timestamp or 0 for no output file known/exists

        long outputTimestamp;
        if (getDestFile() != null && getDestFile().exists()) {
            outputTimestamp = getDestFile().lastModified();
        } else {
            outputTimestamp = 0;
        }
        return outputTimestamp;
    
public java.io.FilegetSrcDir()
Overridden because we need to be able to set the srcDir.

return
the source directory.


    // CheckStyle:ConstantNameCheck ON
    // CheckStyle:VisibilityModifier ON

                       
       
        return this.srcDir;
    
public voidsetDestFile(java.io.File file)
Set the name of exe/library to create.

param
file The new outputFile value

        outputFile = file;
    
public voidsetSrcDir(java.io.File srcDirName)
Set the source directory of the files to be compiled.

param
srcDirName The new SrcDir value

        this.srcDir = srcDirName;