Search in sources :

Example 16 with DirectoryScanner

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

the class SchemaUpdateTask method collectFiles.

private String[] collectFiles() {
    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)

Example 17 with DirectoryScanner

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

the class SchemaValidatorTask method collectFiles.

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

Example 18 with DirectoryScanner

use of org.apache.tools.ant.DirectoryScanner in project jangaroo-tools by CoreMedia.

the class ExmlcTask method execute.

/**
   * Executes the task.
   */
public void execute() throws BuildException {
    checkParameters();
    resetFileLists();
    sourcepath = "";
    // scan source directories and dest directory to build up
    // compile lists
    String[] list = src.list();
    for (String aList : list) {
        File srcDir = getProject().resolveFile(aList);
        if (!srcDir.exists()) {
            throw new BuildException("srcdir \"" + srcDir.getPath() + "\" does not exist!", getLocation());
        }
        if (!sourcepath.isEmpty()) {
            sourcepath += File.pathSeparator;
        }
        sourcepath += srcDir.getAbsolutePath();
        DirectoryScanner ds = this.getDirectoryScanner(srcDir);
        String[] files = ds.getIncludedFiles();
        scanDir(srcDir, destDir != null ? destDir : srcDir, files);
    }
    compile();
}
Also used : DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) File(java.io.File)

Example 19 with DirectoryScanner

use of org.apache.tools.ant.DirectoryScanner in project jangaroo-tools by CoreMedia.

the class JoodocTask method parsePackages.

/**
     * Add the directories matched by the nested dirsets to the Vector
     * and the base directories of the dirsets to the Path.  It also
     * handles the packages and excludepackages attributes and
     * elements.
     *
     * @since 1.5
     */
private void parsePackages(Vector pn, Path sp) {
    Vector addedPackages = new Vector();
    Vector dirSets = (Vector) packageSets.clone();
    // and nested excludepackage elements
    if (sourcePath != null && packageNames.size() > 0) {
        PatternSet ps = new PatternSet();
        Enumeration e = packageNames.elements();
        while (e.hasMoreElements()) {
            PackageName p = (PackageName) e.nextElement();
            String pkg = p.getName().replace('.', '/');
            if (pkg.endsWith("*")) {
                pkg += "*";
            }
            ps.createInclude().setName(pkg);
        }
        e = excludePackageNames.elements();
        while (e.hasMoreElements()) {
            PackageName p = (PackageName) e.nextElement();
            String pkg = p.getName().replace('.', '/');
            if (pkg.endsWith("*")) {
                pkg += "*";
            }
            ps.createExclude().setName(pkg);
        }
        String[] pathElements = sourcePath.list();
        for (int i = 0; i < pathElements.length; i++) {
            DirSet ds = new DirSet();
            ds.setDefaultexcludes(useDefaultExcludes);
            ds.setDir(new File(pathElements[i]));
            ds.createPatternSet().addConfiguredPatternset(ps);
            dirSets.addElement(ds);
        }
    }
    Enumeration e = dirSets.elements();
    while (e.hasMoreElements()) {
        DirSet ds = (DirSet) e.nextElement();
        File baseDir = ds.getDir(getProject());
        log("scanning " + baseDir + " for packages.", Project.MSG_DEBUG);
        DirectoryScanner dsc = ds.getDirectoryScanner(getProject());
        String[] dirs = dsc.getIncludedDirectories();
        boolean containsPackages = false;
        for (int i = 0; i < dirs.length; i++) {
            // are there any java files in this directory?
            File pd = new File(baseDir, dirs[i]);
            String[] files = pd.list(new FilenameFilter() {

                public boolean accept(File dir1, String name) {
                    if (name.endsWith(".java")) {
                        return true;
                    }
                    // ignore dirs
                    return false;
                }
            });
            if (files.length > 0) {
                containsPackages = true;
                String packageName = dirs[i].replace(File.separatorChar, '.');
                if (!addedPackages.contains(packageName)) {
                    addedPackages.addElement(packageName);
                    pn.addElement(packageName);
                }
            }
        }
        if (containsPackages) {
            // We don't need to care for duplicates here,
            // Path.list does it for us.
            sp.createPathElement().setLocation(baseDir);
        } else {
            log(baseDir + " doesn\'t contain any packages, dropping it.", Project.MSG_VERBOSE);
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) Enumeration(java.util.Enumeration) DirSet(org.apache.tools.ant.types.DirSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) Vector(java.util.Vector) PatternSet(org.apache.tools.ant.types.PatternSet) File(java.io.File)

Example 20 with DirectoryScanner

use of org.apache.tools.ant.DirectoryScanner in project jangaroo-tools by CoreMedia.

the class JoocTask method execute.

/**
   * Executes the task.
   */
public void execute() throws BuildException {
    checkParameters();
    resetFileLists();
    sourcepath = "";
    // scan source directories and dest directory to build up
    // compile lists
    String[] list = src.list();
    for (String aList : list) {
        File srcDir = getProject().resolveFile(aList);
        if (!srcDir.exists()) {
            throw new BuildException("srcdir \"" + srcDir.getPath() + "\" does not exist!", getLocation());
        }
        if (!sourcepath.isEmpty()) {
            sourcepath += File.pathSeparator;
        }
        sourcepath += srcDir.getAbsolutePath();
        DirectoryScanner ds = this.getDirectoryScanner(srcDir);
        String[] files = ds.getIncludedFiles();
        scanDir(srcDir, destDir != null ? destDir : srcDir, files);
    }
    compile();
}
Also used : DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) File(java.io.File)

Aggregations

DirectoryScanner (org.apache.tools.ant.DirectoryScanner)57 File (java.io.File)52 BuildException (org.apache.tools.ant.BuildException)26 FileSet (org.apache.tools.ant.types.FileSet)26 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)12 GroovyClassLoader (groovy.lang.GroovyClassLoader)4 FileInputStream (java.io.FileInputStream)4 FilenameFilter (java.io.FilenameFilter)4 Project (org.apache.tools.ant.Project)4 DirSet (org.apache.tools.ant.types.DirSet)4 PatternSet (org.apache.tools.ant.types.PatternSet)4 LinkedList (java.util.LinkedList)3 Path (org.apache.tools.ant.types.Path)3 AbstractProject (hudson.model.AbstractProject)2 VirtualChannel (hudson.remoting.VirtualChannel)2 OutputStream (java.io.OutputStream)2 URI (java.net.URI)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2