Search in sources :

Example 86 with DirectoryScanner

use of org.apache.tools.ant.DirectoryScanner in project processing by processing.

the class AppBundlerTask method copyClassPathEntries.

private void copyClassPathEntries(File javaDirectory) throws IOException {
    for (FileSet fileSet : classPath) {
        File classPathDirectory = fileSet.getDir();
        DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
        String[] includedFiles = directoryScanner.getIncludedFiles();
        for (String includedFile : includedFiles) {
            File source = new File(classPathDirectory, includedFile);
            File destination = new File(javaDirectory, new File(includedFile).getName());
            copy(source, destination);
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) File(java.io.File)

Example 87 with DirectoryScanner

use of org.apache.tools.ant.DirectoryScanner in project poi by apache.

the class TestAllFiles method files.

@Parameters(name = "{index}: {0} using {1}")
public static Iterable<Object[]> files() {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setBasedir(ROOT_DIR);
    scanner.setExcludes(SCAN_EXCLUDES);
    scanner.scan();
    System.out.println("Handling " + scanner.getIncludedFiles().length + " files");
    List<Object[]> files = new ArrayList<Object[]>();
    for (String file : scanner.getIncludedFiles()) {
        // ... failures/handlers lookup doesn't work on windows otherwise
        file = file.replace('\\', '/');
        if (IGNORED.contains(file)) {
            System.out.println("Ignoring " + file);
            continue;
        }
        FileHandler handler = HANDLERS.get(getExtension(file));
        files.add(new Object[] { file, handler });
        // for some file-types also run OPCFileHandler
        if (handler instanceof XSSFFileHandler || handler instanceof XWPFFileHandler || handler instanceof XSLFFileHandler || handler instanceof XDGFFileHandler) {
            files.add(new Object[] { file, new OPCFileHandler() });
        }
        if (handler instanceof HSSFFileHandler || handler instanceof HSLFFileHandler || handler instanceof HWPFFileHandler || handler instanceof HDGFFileHandler) {
            files.add(new Object[] { file, new HPSFFileHandler() });
        }
    }
    return files;
}
Also used : XDGFFileHandler(org.apache.poi.stress.XDGFFileHandler) XSSFFileHandler(org.apache.poi.stress.XSSFFileHandler) HPSFFileHandler(org.apache.poi.stress.HPSFFileHandler) ArrayList(java.util.ArrayList) XWPFFileHandler(org.apache.poi.stress.XWPFFileHandler) OPCFileHandler(org.apache.poi.stress.OPCFileHandler) POIFSFileHandler(org.apache.poi.stress.POIFSFileHandler) HSLFFileHandler(org.apache.poi.stress.HSLFFileHandler) HDGFFileHandler(org.apache.poi.stress.HDGFFileHandler) HMEFFileHandler(org.apache.poi.stress.HMEFFileHandler) AbstractFileHandler(org.apache.poi.stress.AbstractFileHandler) XSSFBFileHandler(org.apache.poi.stress.XSSFBFileHandler) HWPFFileHandler(org.apache.poi.stress.HWPFFileHandler) HSMFFileHandler(org.apache.poi.stress.HSMFFileHandler) XSLFFileHandler(org.apache.poi.stress.XSLFFileHandler) XWPFFileHandler(org.apache.poi.stress.XWPFFileHandler) FileHandler(org.apache.poi.stress.FileHandler) HSSFFileHandler(org.apache.poi.stress.HSSFFileHandler) HPBFFileHandler(org.apache.poi.stress.HPBFFileHandler) XDGFFileHandler(org.apache.poi.stress.XDGFFileHandler) XSSFFileHandler(org.apache.poi.stress.XSSFFileHandler) HPSFFileHandler(org.apache.poi.stress.HPSFFileHandler) OPCFileHandler(org.apache.poi.stress.OPCFileHandler) HSLFFileHandler(org.apache.poi.stress.HSLFFileHandler) HWPFFileHandler(org.apache.poi.stress.HWPFFileHandler) XSLFFileHandler(org.apache.poi.stress.XSLFFileHandler) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) HDGFFileHandler(org.apache.poi.stress.HDGFFileHandler) HSSFFileHandler(org.apache.poi.stress.HSSFFileHandler) Parameters(org.junit.runners.Parameterized.Parameters)

Example 88 with DirectoryScanner

use of org.apache.tools.ant.DirectoryScanner in project bnd by bndtools.

the class WrapTask method addConfiguredFileSet.

public void addConfiguredFileSet(FileSet list) {
    DirectoryScanner scanner = list.getDirectoryScanner(getProject());
    String[] files = scanner.getIncludedFiles();
    for (int i = 0; i < files.length; i++) {
        File f = getFile(scanner.getBasedir(), files[i]);
        this.jars.add(f);
    }
}
Also used : DirectoryScanner(org.apache.tools.ant.DirectoryScanner) File(java.io.File)

Example 89 with DirectoryScanner

use of org.apache.tools.ant.DirectoryScanner in project bnd by bndtools.

the class DeployTask method execute.

@Override
public void execute() throws BuildException {
    try {
        Project project = Workspace.getProject(getProject().getBaseDir());
        // Deploy the files that need to be released
        for (FileSet fileset : filesets) {
            DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
            String[] files = ds.getIncludedFiles();
            if (files.length == 0)
                logger.debug("No files included");
            for (int i = 0; i < files.length; i++) {
                File file = new File(ds.getBasedir(), files[i]);
                try {
                    if (file.isFile() && file.getName().endsWith(".jar")) {
                        if (deployRepo != null)
                            project.deploy(deployRepo, file);
                        else
                            project.deploy(file);
                    } else
                        messages.NotAJarFile_(file);
                } catch (Exception e) {
                    messages.FailedToDeploy_Exception_(file, e);
                }
            }
        }
        report(project);
        if (project.getErrors().size() > 0)
            throw new BuildException("Deploy failed");
    } catch (Throwable t) {
        t.printStackTrace();
        throw new BuildException(t);
    }
}
Also used : Project(aQute.bnd.build.Project) FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) BuildException(org.apache.tools.ant.BuildException)

Example 90 with DirectoryScanner

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

the class GenerateTranslator method execute.

public void execute() throws BuildException {
    validate();
    DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
    String[] srcFilenames = ds.getIncludedFiles();
    if (srcFilenames.length == 0)
        throw new BuildException("You must designate at least one input properties file.");
    File[] srcFiles = new File[srcFilenames.length];
    for (int j = 0; j < srcFiles.length; j++) srcFiles[j] = new File(ds.getBasedir(), srcFilenames[j]);
    try {
        openProperties(srcFiles);
    } catch (IOException e) {
        throw new BuildException("Could not read properties files.");
    }
    File lexerFile = getLexFileName();
    try {
        writeOutput(lexerFile);
    } catch (IOException ioe) {
        throw new BuildException("Cannot create file '" + lexerFile + "'.");
    }
    try {
        JLex.Main.main(new String[] { lexerFile.getAbsolutePath() });
    } catch (IOException ioe) {
        throw new BuildException("Cannot create file '" + lexerFile + ".java'");
    }
    if (!keepLexerFile)
        lexerFile.delete();
}
Also used : DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) File(java.io.File)

Aggregations

DirectoryScanner (org.apache.tools.ant.DirectoryScanner)150 File (java.io.File)122 FileSet (org.apache.tools.ant.types.FileSet)84 BuildException (org.apache.tools.ant.BuildException)73 IOException (java.io.IOException)38 ArrayList (java.util.ArrayList)32 Project (org.apache.tools.ant.Project)14 Resource (org.apache.tools.ant.types.Resource)11 Test (org.junit.Test)11 FileResource (org.apache.tools.ant.types.resources.FileResource)8 HashMap (java.util.HashMap)7 Path (org.apache.tools.ant.types.Path)7 Hashtable (java.util.Hashtable)6 PatternSet (org.apache.tools.ant.types.PatternSet)6 FileWriter (java.io.FileWriter)5 LinkedList (java.util.LinkedList)5 List (java.util.List)5 StringTokenizer (java.util.StringTokenizer)5 Vector (java.util.Vector)5 DirSet (org.apache.tools.ant.types.DirSet)5