Search in sources :

Example 11 with FileSet

use of org.apache.tools.ant.types.FileSet in project processdash by dtuma.

the class SVGToImage method execute.

public void execute() {
    if (verbose)
        log("Building SVG images");
    for (Iterator it = filesets.iterator(); it.hasNext(); ) {
        FileSet fs = (FileSet) it.next();
        FileScanner scanner = fs.getDirectoryScanner(getProject());
        String[] files = scanner.getIncludedFiles();
        try {
            File basedir = scanner.getBasedir();
            if (verbose)
                log("Scanning " + basedir);
            for (int i = 0; i < files.length; i++) {
                translate(basedir, files[i]);
            }
        } catch (Exception e) {
            throw new BuildException(e);
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) Iterator(java.util.Iterator) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) FileScanner(org.apache.tools.ant.FileScanner)

Example 12 with FileSet

use of org.apache.tools.ant.types.FileSet in project pdfbox by apache.

the class PDFToTextTask method execute.

/**
 * This will perform the execution.
 */
@Override
public void execute() {
    log("PDFToTextTask executing");
    for (FileSet fileSet : fileSets) {
        DirectoryScanner dirScanner = fileSet.getDirectoryScanner(getProject());
        dirScanner.scan();
        String[] files = dirScanner.getIncludedFiles();
        for (String file : files) {
            File f = new File(dirScanner.getBasedir(), file);
            log("processing: " + f.getAbsolutePath());
            String pdfFile = f.getAbsolutePath();
            if (pdfFile.toUpperCase().endsWith(".PDF")) {
                String textFile = pdfFile.substring(0, pdfFile.length() - 3);
                textFile = textFile + "txt";
                try {
                    ExtractText.main(new String[] { pdfFile, textFile });
                } catch (Exception e) {
                    log("Error processing " + pdfFile + e.getMessage());
                }
            }
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) File(java.io.File)

Example 13 with FileSet

use of org.apache.tools.ant.types.FileSet in project mylyn.docs by eclipse.

the class MarkupToXslfoTask method execute.

@Override
public void execute() throws BuildException {
    if (file == null && filesets.isEmpty()) {
        // $NON-NLS-1$
        throw new BuildException(Messages.getString("MarkupToXslfoTask.0"));
    }
    if (file != null && !filesets.isEmpty()) {
        // $NON-NLS-1$
        throw new BuildException(Messages.getString("MarkupToXslfoTask.1"));
    }
    if (file != null) {
        if (!file.exists()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToXslfoTask.2"), file));
        } else if (!file.isFile()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToXslfoTask.3"), file));
        } else if (!file.canRead()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToXslfoTask.4"), file));
        }
    }
    MarkupLanguage markupLanguage = createMarkupLanguage();
    for (FileSet fileset : filesets) {
        File filesetBaseDir = fileset.getDir(getProject());
        DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
        String[] files = ds.getIncludedFiles();
        if (files != null) {
            File baseDir = ds.getBasedir();
            for (String file : files) {
                File inputFile = new File(baseDir, file);
                try {
                    processFile(markupLanguage, filesetBaseDir, inputFile);
                } catch (BuildException e) {
                    throw e;
                } catch (Exception e) {
                    throw new BuildException(MessageFormat.format(// $NON-NLS-1$
                    Messages.getString("MarkupToXslfoTask.5"), // $NON-NLS-1$
                    inputFile, e.getMessage()), e);
                }
            }
        }
    }
    if (file != null) {
        try {
            processFile(markupLanguage, file.getParentFile(), file);
        } catch (BuildException e) {
            throw e;
        } catch (Exception e) {
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToXslfoTask.6"), file, e.getMessage()), // $NON-NLS-1$
            e);
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) File(java.io.File) BuildException(org.apache.tools.ant.BuildException)

Example 14 with FileSet

use of org.apache.tools.ant.types.FileSet in project mylyn.docs by eclipse.

the class HtmlToMarkupTask method execute.

@Override
public void execute() throws BuildException {
    if (file == null && filesets.isEmpty()) {
        // $NON-NLS-1$
        throw new BuildException(Messages.getString("MarkupToHtmlTask.1"));
    }
    if (file != null && !filesets.isEmpty()) {
        // $NON-NLS-1$
        throw new BuildException(Messages.getString("MarkupToHtmlTask.2"));
    }
    if (file != null) {
        if (!file.exists()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.3"), file));
        } else if (!file.isFile()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.4"), file));
        } else if (!file.canRead()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.5"), file));
        }
    }
    MarkupLanguage markupLanguage = createMarkupLanguage();
    for (FileSet fileset : filesets) {
        File filesetBaseDir = fileset.getDir(getProject());
        DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
        String[] files = ds.getIncludedFiles();
        if (files != null) {
            File baseDir = ds.getBasedir();
            for (String file : files) {
                File inputFile = new File(baseDir, file);
                try {
                    processFile(markupLanguage, filesetBaseDir, inputFile);
                } catch (BuildException e) {
                    throw e;
                } catch (Exception e) {
                    throw new BuildException(MessageFormat.format(// $NON-NLS-1$
                    Messages.getString("MarkupToHtmlTask.11"), // $NON-NLS-1$
                    inputFile, e.getMessage()), e);
                }
            }
        }
    }
    if (file != null) {
        try {
            processFile(markupLanguage, file.getParentFile(), file);
        } catch (BuildException e) {
            throw e;
        } catch (Exception e) {
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToHtmlTask.12"), file, e.getMessage()), // $NON-NLS-1$
            e);
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) File(java.io.File) BuildException(org.apache.tools.ant.BuildException)

Example 15 with FileSet

use of org.apache.tools.ant.types.FileSet in project mylyn.docs by eclipse.

the class MarkupToDocbookTask method execute.

@Override
public void execute() throws BuildException {
    if (file == null && filesets.isEmpty()) {
        // $NON-NLS-1$
        throw new BuildException(Messages.getString("MarkupToDocbookTask.1"));
    }
    if (file != null && !filesets.isEmpty()) {
        // $NON-NLS-1$
        throw new BuildException(Messages.getString("MarkupToDocbookTask.2"));
    }
    if (file != null) {
        if (!file.exists()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDocbookTask.3"), file));
        } else if (!file.isFile()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDocbookTask.4"), file));
        } else if (!file.canRead()) {
            // $NON-NLS-1$
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDocbookTask.5"), file));
        }
    }
    MarkupLanguage markupLanguage = createMarkupLanguage();
    for (FileSet fileset : filesets) {
        File filesetBaseDir = fileset.getDir(getProject());
        DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
        String[] files = ds.getIncludedFiles();
        if (files != null) {
            File baseDir = ds.getBasedir();
            for (String file : files) {
                File inputFile = new File(baseDir, file);
                try {
                    processFile(markupLanguage, filesetBaseDir, inputFile);
                } catch (BuildException e) {
                    throw e;
                } catch (Exception e) {
                    throw new BuildException(MessageFormat.format(// $NON-NLS-1$
                    Messages.getString("MarkupToDocbookTask.6"), // $NON-NLS-1$
                    inputFile, e.getMessage()), e);
                }
            }
        }
    }
    if (file != null) {
        try {
            processFile(markupLanguage, file.getParentFile(), file);
        } catch (BuildException e) {
            throw e;
        } catch (Exception e) {
            throw new BuildException(MessageFormat.format(Messages.getString("MarkupToDocbookTask.7"), file, e.getMessage()), // $NON-NLS-1$
            e);
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) File(java.io.File) BuildException(org.apache.tools.ant.BuildException)

Aggregations

FileSet (org.apache.tools.ant.types.FileSet)165 File (java.io.File)124 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)83 BuildException (org.apache.tools.ant.BuildException)49 Test (org.junit.Test)41 IOException (java.io.IOException)36 ArrayList (java.util.ArrayList)29 Project (org.apache.tools.ant.Project)22 Resource (org.apache.tools.ant.types.Resource)12 FileResource (org.apache.tools.ant.types.resources.FileResource)10 URL (java.net.URL)6 Hashtable (java.util.Hashtable)6 ArchiveFileSet (org.apache.tools.ant.types.ArchiveFileSet)6 Path (org.apache.tools.ant.types.Path)6 ResourceCollection (org.apache.tools.ant.types.ResourceCollection)6 PrintStream (java.io.PrintStream)5 HashMap (java.util.HashMap)5 Iterator (java.util.Iterator)5 List (java.util.List)5 ZipFileSet (org.apache.tools.ant.types.ZipFileSet)5