Search in sources :

Example 26 with FileSet

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

the class Attrib method setFile.

/**
 * A file to be attribed.
 * @param src a file
 */
public void setFile(File src) {
    FileSet fs = new FileSet();
    fs.setFile(src);
    addFileset(fs);
}
Also used : FileSet(org.apache.tools.ant.types.FileSet)

Example 27 with FileSet

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

the class AbstractJarSignerTask method createUnifiedSources.

/**
 * clone our filesets vector, and patch in the jar attribute as a new
 * fileset, if is defined
 * @return a vector of FileSet instances
 */
protected Vector<FileSet> createUnifiedSources() {
    Vector<FileSet> sources = new Vector<>(filesets);
    if (jar != null) {
        // we create a fileset with the source file.
        // this lets us combine our logic for handling output directories,
        // mapping etc.
        FileSet sourceJar = new FileSet();
        sourceJar.setProject(getProject());
        sourceJar.setFile(jar);
        sources.add(sourceJar);
    }
    return sources;
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) Vector(java.util.Vector)

Example 28 with FileSet

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

the class FTPTest method testGetWithSelector.

@Test
public void testGetWithSelector() {
    buildRule.executeTarget("ftp-get-with-selector");
    assertContains("selectors are not supported in remote filesets", buildRule.getLog());
    FileSet fsDestination = buildRule.getProject().getReference("fileset-destination-without-selector");
    DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(buildRule.getProject());
    dsDestination.scan();
    String[] sortedDestinationDirectories = dsDestination.getIncludedDirectories();
    String[] sortedDestinationFiles = dsDestination.getIncludedFiles();
    for (int counter = 0; counter < sortedDestinationDirectories.length; counter++) {
        sortedDestinationDirectories[counter] = sortedDestinationDirectories[counter].replace(File.separatorChar, '/');
    }
    for (int counter = 0; counter < sortedDestinationFiles.length; counter++) {
        sortedDestinationFiles[counter] = sortedDestinationFiles[counter].replace(File.separatorChar, '/');
    }
    FileSet fsSource = buildRule.getProject().getReference("fileset-source-without-selector");
    DirectoryScanner dsSource = fsSource.getDirectoryScanner(buildRule.getProject());
    dsSource.scan();
    compareFiles(dsSource, sortedDestinationFiles, sortedDestinationDirectories);
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) Test(org.junit.Test)

Example 29 with FileSet

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

the class FTPTest method testGetFollowSymlinksFalse.

@Test
public void testGetFollowSymlinksFalse() {
    Assume.assumeTrue("System does not support Symlinks", supportsSymlinks);
    Assume.assumeTrue(loginFailureMessage, loginSucceeded);
    Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir));
    buildRule.getProject().executeTarget("ftp-get-directory-no-symbolic-link");
    FileSet fsDestination = buildRule.getProject().getReference("fileset-destination-without-selector");
    DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(buildRule.getProject());
    dsDestination.scan();
    compareFiles(dsDestination, new String[] {}, new String[] {});
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) Test(org.junit.Test)

Example 30 with FileSet

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

the class ScriptDefTest method testNestedByClassName.

@Test
public void testNestedByClassName() {
    buildRule.executeTarget("nestedbyclassname");
    // get the fileset and its basedir
    Project p = buildRule.getProject();
    FileSet fileset = p.getReference("testfileset");
    File baseDir = fileset.getDir(p);
    String log = buildRule.getLog();
    assertTrue("Expecting attribute value to be printed", log.contains("Attribute attr1 = test"));
    assertTrue("Expecting nested element value to be printed", log.contains("Fileset basedir = " + baseDir.getAbsolutePath()));
}
Also used : Project(org.apache.tools.ant.Project) FileSet(org.apache.tools.ant.types.FileSet) File(java.io.File) Test(org.junit.Test)

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