/** * Fulfill the ResourceCollection contract. * @return an Iterator of Resources. * @since Ant 1.7 */ @Override public Iterator<Resource> iterator() { if (isReference()) { return ((FileSet) getRef(getProject())).iterator(); } return new FileResourceIterator(getProject(), getDir(getProject()), getDirectoryScanner(getProject()).getIncludedFiles()); }
/** * Grabs all included files and directors from the FileSet and * returns them as an array of (relative) file names. * @param fs the fileset to operate on. * @return a list of the filenames. * @since Ant 1.7 */ protected static String[] getFileNames(final FileSet fs) { final DirectoryScanner ds = fs.getDirectoryScanner(fs.getProject()); final String[] directories = ds.getIncludedDirectories(); final String[] filesPerSe = ds.getIncludedFiles(); final String[] files = new String[directories.length + filesPerSe.length]; System.arraycopy(directories, 0, files, 0, directories.length); System.arraycopy(filesPerSe, 0, files, directories.length, filesPerSe.length); return files; }
/** * Fulfill the ResourceCollection contract. * @return number of elements as int. * @since Ant 1.7 */ @Override public int size() { if (isReference()) { return ((FileSet) getRef(getProject())).size(); } return getDirectoryScanner(getProject()).getIncludedFilesCount(); }
/** * Adds a nested <code><fileset></code> element. * @param fs a <code>FileSet</code> to be added to the path * @throws BuildException on error */ public void addFileset(FileSet fs) throws BuildException { if (fs.getProject() == null) { fs.setProject(getProject()); } add(fs); }
/** * Return a FileSet that has the same basedir and same patternsets * as this one. * @return the cloned fileset */ @Override public Object clone() { if (isReference()) { return getRef(getProject()).clone(); } return super.clone(); }
if (fs.getProject() == null) { log("Deleting fileset with no project specified; assuming executing project", Project.MSG_VERBOSE);
private static File[] scanFileSet(FileSet fs) { Project prj = fs.getProject(); DirectoryScanner scanner = fs.getDirectoryScanner(prj); scanner.scan(); File basedir = scanner.getBasedir(); String[] fileNames = scanner.getIncludedFiles(); File[] ret = new File[fileNames.length]; for (int i = 0; i < fileNames.length; i++) { String fileName = fileNames[i]; ret[i] = new File(basedir, fileName); } return ret; } }
/** * Add a new fileset instance to this batchtest. Whatever the fileset is, * only filename that are <tt>.java</tt> or <tt>.class</tt> will be * considered as 'candidates'. * @param fs the new fileset containing the rules to get the testcases. */ public void addFileSet(FileSet fs) { add(fs); // this one is here because the changes to support ResourceCollections // have broken Magic's JUnitTestTask. // // The task adds a FileSet to a BatchTest instance using the // Java API and without telling the FileSet about its project // instance. The original code would pass in project on the // call to getDirectoryScanner - which is now hidden deep into // Resources.iterator() and not reachable. if (fs.getProject() == null) { fs.setProject(project); } }
/** * Adds a set of tests based on pattern matching. */ public void addFileSet(FileSet fs) { add(fs); if (fs.getProject() == null) { fs.setProject(getProject()); } }
/** * Adds a set of tests based on pattern matching. */ public void addFileSet(FileSet fs) { add(fs); if (fs.getProject() == null) { fs.setProject(getProject()); } }
/** * Write an Ant fileset * * @param fileSet * @param id */ public void writeFileSet( FileSet fileSet, String id ) { writer.startElement( "fileset" ); if ( id != null ) { writer.addAttribute( "id", id ); } File dir = fileSet.getDir( fileSet.getProject() ); writer.addAttribute( "dir", dir.getAbsolutePath() ); DirectoryScanner scanner = fileSet.getDirectoryScanner( fileSet.getProject() ); scanner.scan(); String[] files = scanner.getIncludedFiles(); for ( int i = 0; i < files.length; ++i ) { writer.startElement( "include" ); writer.addAttribute( "name", files[i] ); writer.endElement(); } writer.endElement(); }
Project project = set.getProject(); File dir = set.getDir(project); FileScanner scanner = set.getDirectoryScanner(project);