Search in sources :

Example 91 with FileSet

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

the class AntWebAppContext method getClassPathFiles.

/**
     * @return a list of classpath files (libraries and class directories).
     */
public List<File> getClassPathFiles() {
    List<File> classPathFiles = new ArrayList<File>();
    Iterator classesIterator = classes.iterator();
    while (classesIterator.hasNext()) {
        FileSet clazz = (FileSet) classesIterator.next();
        classPathFiles.add(clazz.getDirectoryScanner(project).getBasedir());
    }
    Iterator iterator = libraries.iterator();
    while (iterator.hasNext()) {
        FileSet library = (FileSet) iterator.next();
        String[] includedFiles = library.getDirectoryScanner(project).getIncludedFiles();
        File baseDir = library.getDirectoryScanner(project).getBasedir();
        for (int i = 0; i < includedFiles.length; i++) {
            classPathFiles.add(new File(baseDir, includedFiles[i]));
        }
    }
    return classPathFiles;
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) File(java.io.File)

Example 92 with FileSet

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

the class AbstractProcessTask method getFiles.

protected Collection getFiles() {
    Map fileMap = new HashMap();
    Project p = getProject();
    for (int i = 0; i < filesets.size(); i++) {
        FileSet fs = (FileSet) filesets.elementAt(i);
        DirectoryScanner ds = fs.getDirectoryScanner(p);
        String[] srcFiles = ds.getIncludedFiles();
        File dir = fs.getDir(p);
        for (int j = 0; j < srcFiles.length; j++) {
            File src = new File(dir, srcFiles[j]);
            fileMap.put(src.getAbsolutePath(), src);
        }
    }
    return fileMap.values();
}
Also used : Project(org.apache.tools.ant.Project) FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) File(java.io.File)

Example 93 with FileSet

use of org.apache.tools.ant.types.FileSet 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 94 with FileSet

use of org.apache.tools.ant.types.FileSet 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 95 with FileSet

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

the class PackageLaunchProfile method calculateContentToken.

private String calculateContentToken() throws IOException {
    List<File> files = new ArrayList<File>();
    for (FileSet fs : filesets) {
        DirectoryScanner ds = fs.getDirectoryScanner(getProject());
        for (String name : ds.getIncludedFiles()) files.add(new File(ds.getBasedir(), name));
    }
    if (files.isEmpty())
        throw new BuildException("You must designate at least one file " + "to include in the launch profile.");
    Collections.sort(files, FILENAME_SORTER);
    Checksum ck = new Adler32();
    for (File f : files) calcChecksum(f, ck);
    return Long.toString(Math.abs(ck.getValue()), Character.MAX_RADIX);
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) Checksum(java.util.zip.Checksum) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) ArrayList(java.util.ArrayList) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) Adler32(java.util.zip.Adler32)

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