Search in sources :

Example 1 with FileSet

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

the class AntWebAppContext method getLibrariesConfiguration.

/**
     * @return a <code>FileMatchingConfiguration</code> object describing the
     *         configuration of all libraries added to this particular web app
     *         (both classes and libraries).
     */
public FileMatchingConfiguration getLibrariesConfiguration() {
    FileMatchingConfiguration config = new FileMatchingConfiguration();
    Iterator classesIterator = classes.iterator();
    while (classesIterator.hasNext()) {
        FileSet clazz = (FileSet) classesIterator.next();
        config.addDirectoryScanner(clazz.getDirectoryScanner(project));
    }
    Iterator librariesIterator = libraries.iterator();
    while (librariesIterator.hasNext()) {
        FileSet library = (FileSet) librariesIterator.next();
        config.addDirectoryScanner(library.getDirectoryScanner(project));
    }
    return config;
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) Iterator(java.util.Iterator) FileMatchingConfiguration(org.eclipse.jetty.ant.types.FileMatchingConfiguration)

Example 2 with FileSet

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

the class SignCode method execute.

@Override
public void execute() throws BuildException {
    List<File> filesToSign = new ArrayList<>();
    // signed.
    for (FileSet fileset : filesets) {
        DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
        File basedir = ds.getBasedir();
        String[] files = ds.getIncludedFiles();
        if (files.length > 0) {
            for (int i = 0; i < files.length; i++) {
                File file = new File(basedir, files[i]);
                filesToSign.add(file);
            }
        }
    }
    try {
        String signingSetID = makeSigningRequest(filesToSign);
        downloadSignedFiles(filesToSign, signingSetID);
    } catch (SOAPException | IOException e) {
        throw new BuildException(e);
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) SOAPException(javax.xml.soap.SOAPException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) File(java.io.File)

Example 3 with FileSet

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

the class Zipper method getSourceFileSet.

private FileSet getSourceFileSet() {
    File f = new File(source);
    FileSet fs = new FileSet();
    fillFileSetAttributes(fs, f);
    return fs;
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) File(java.io.File)

Example 4 with FileSet

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

the class WebUpToDate method eval.

/**
	 * Evaluate (all) target and source file(s) to
	 * see if the target(s) is/are up-to-date.
	 * @return true if the target(s) is/are up-to-date
	 */
public boolean eval() {
    if (sourceFileSets.size() == 0 && sourceResources.size() == 0 && sourceFile == null) {
        throw new BuildException("At least one srcfile or a nested <srcfiles> or <srcresources> element must be set.");
    }
    if ((sourceFileSets.size() > 0 || sourceResources.size() > 0) && sourceFile != null) {
        throw new BuildException("Cannot specify both the srcfile attribute and a nested <srcfiles> or <srcresources> element.");
    }
    if (urlbase == null) {
        throw new BuildException("The urlbase attribute must be set.");
    }
    // if the source file isn't there, throw an exception
    if (sourceFile != null && !sourceFile.exists()) {
        throw new BuildException(sourceFile.getAbsolutePath() + " not found.");
    }
    boolean upToDate = true;
    if (sourceFile != null) {
        Resource fileResource = new FileResource(sourceFile);
        upToDate = isUpToDate(fileResource);
    }
    if (upToDate) {
        Enumeration e = sourceFileSets.elements();
        while (upToDate && e.hasMoreElements()) {
            FileSet fs = (FileSet) e.nextElement();
            Iterator it = fs.iterator();
            while (upToDate && it.hasNext()) {
                Resource r = (Resource) it.next();
                upToDate = isUpToDate(r);
            }
        }
    }
    if (upToDate) {
        Resource[] r = sourceResources.listResources();
        for (int i = 0; upToDate && i < r.length; i++) {
            upToDate = isUpToDate(r[i]);
        }
    }
    return upToDate;
}
Also used : Enumeration(java.util.Enumeration) FileSet(org.apache.tools.ant.types.FileSet) Resource(org.apache.tools.ant.types.Resource) FileResource(org.apache.tools.ant.types.resources.FileResource) URLResource(org.apache.tools.ant.types.resources.URLResource) FileResource(org.apache.tools.ant.types.resources.FileResource) Iterator(java.util.Iterator) BuildException(org.apache.tools.ant.BuildException)

Example 5 with FileSet

use of org.apache.tools.ant.types.FileSet in project hibernate-orm by hibernate.

the class SchemaExportTask method getFiles.

private String[] getFiles() {
    List<String> files = new LinkedList<String>();
    for (FileSet fileSet : fileSets) {
        final DirectoryScanner ds = fileSet.getDirectoryScanner(getProject());
        final String[] dsFiles = ds.getIncludedFiles();
        for (String dsFileName : dsFiles) {
            File f = new File(dsFileName);
            if (!f.isFile()) {
                f = new File(ds.getBasedir(), dsFileName);
            }
            files.add(f.getAbsolutePath());
        }
    }
    return ArrayHelper.toStringArray(files);
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) File(java.io.File) LinkedList(java.util.LinkedList)

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