/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList * * @param srcDir The source directory * @param destDir The destination directory * @param files An array of filenames */ protected void scanDir(final File srcDir, final File destDir, final String[] files) { final GlobPatternMapper m = new GlobPatternMapper(); for (String extension : findSupportedFileExtensions()) { m.setFrom(extension); m.setTo("*.class"); final SourceFileScanner sfs = new SourceFileScanner(this); final File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); if (newFiles.length > 0) { lookForPackageInfos(srcDir, newFiles); final File[] newCompileList = new File[compileList.length + newFiles.length]; System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length); compileList = newCompileList; } } }
private String[] restrict(String[] s, File baseDir) { return (mapper == null || force) ? s : new SourceFileScanner(this).restrict(s, baseDir, destDir, mapper); }
/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList * * @param srcDir The source directory * @param destDir The destination directory * @param files An array of filenames */ protected void scanDir(File srcDir, File destDir, String[] files) { GlobPatternMapper m = new GlobPatternMapper(); SourceFileScanner sfs = new SourceFileScanner(this); File[] newFiles; for (String extension : getScriptExtensions()) { m.setFrom("*." + extension); m.setTo("*.class"); newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); addToCompileList(newFiles); } if (jointCompilation) { m.setFrom("*.java"); m.setTo("*.class"); newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); addToCompileList(newFiles); } }
/** * Convenience layer on top of restrict that returns the source * files as File objects (containing absolute paths if srcDir is * absolute). * @param files the original set of files. * @param srcDir all files are relative to this directory. * @param destDir target files live here. If null file names * returned by the mapper are assumed to be absolute. * @param mapper knows how to construct a target file names from * source file names. * @return an array of files. */ public File[] restrictAsFiles(String[] files, File srcDir, File destDir, FileNameMapper mapper) { return restrictAsFiles(files, srcDir, destDir, mapper, FILE_UTILS.getFileTimestampGranularity()); }
/** * Convenience layer on top of restrict that returns the source * files as File objects (containing absolute paths if srcDir is * absolute). * * @param files the original set of files. * @param srcDir all files are relative to this directory. * @param destDir target files live here. If null file names * returned by the mapper are assumed to be absolute. * @param mapper knows how to construct a target file names from * source file names. * @param granularity The number of milliseconds leeway to give * before deciding a target is out of date. * @return an array of files. * @since Ant 1.6.2 */ public File[] restrictAsFiles(String[] files, File srcDir, File destDir, FileNameMapper mapper, long granularity) { return Stream.of(restrict(files, srcDir, destDir, mapper, granularity)) .map(name -> new File(srcDir, name)).toArray(File[]::new); }
/** * Restrict the given set of files to those that are newer than * their corresponding target files. * * @param files the original set of files. * @param srcDir all files are relative to this directory. * @param destDir target files live here. if null file names * returned by the mapper are assumed to be absolute. * @param mapper knows how to construct a target file names from * source file names. * @return an array of filenames. */ public String[] restrict(String[] files, File srcDir, File destDir, FileNameMapper mapper) { return restrict(files, srcDir, destDir, mapper, FILE_UTILS.getFileTimestampGranularity()); }
log.debug("Including changed files from: " + basedir); SourceFileScanner sourceScanner = new SourceFileScanner(this); File[] files = sourceScanner.restrictAsFiles(includes, basedir, destdir, mapper);
/** * Scan a directory for files to check for "up to date"ness * @param srcDir the directory * @param files the files to scan for * @return true if the files are up to date */ protected boolean scanDir(File srcDir, String[] files) { SourceFileScanner sfs = new SourceFileScanner(this); FileNameMapper mapper = getMapper(); File dir = srcDir; if (mapperElement == null) { dir = null; } return sfs.restrict(files, srcDir, dir, mapper).length == 0; }
/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList * * @param srcDir the source directory * @param destDir the destination directory * @param files the files to scan */ protected void scanDir(File srcDir, File destDir, String[] files) { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("*.exml"); m.setTo("*.as"); SourceFileScanner sfs = new SourceFileScanner(this); File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); if (newFiles.length > 0) { File[] newCompileList = new File[compileList.length + newFiles.length]; System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length); compileList = newCompileList; } }
/** * Is the archive up to date in relationship to a list of files. * @param files the files to check * @param dir the base directory for the files. * @return true if the archive is up to date. * @since Ant 1.5.2 */ protected boolean archiveIsUpToDate(final String[] files, final File dir) { final SourceFileScanner sfs = new SourceFileScanner(this); final MergingMapper mm = new MergingMapper(); mm.setTo(tarFile.getAbsolutePath()); return sfs.restrict(files, dir, null, mm).length == 0; }
/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList * * @param srcDir the source directory * @param destDir the destination directory * @param files the files to scan */ protected void scanDir(File srcDir, File destDir, String[] files) { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("*.properties"); m.setTo("*.as"); SourceFileScanner sfs = new SourceFileScanner(this); File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); if (newFiles.length > 0) { File[] newCompileList = new File[compileList.length + newFiles.length]; System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length); compileList = newCompileList; } }
/** * Scans the directory looking for class files to be compiled. * The result is returned in the class variable compileList. * @param baseDir the base direction * @param files the list of files to scan * @param mapper the mapper of files to target files */ protected void scanDir(File baseDir, String[] files, FileNameMapper mapper) { String[] newFiles = files; if (idl) { log("will leave uptodate test to rmic implementation in idl mode.", Project.MSG_VERBOSE); } else if (iiop && iiopOpts != null && iiopOpts.contains("-always")) { log("no uptodate test as -always option has been specified", Project.MSG_VERBOSE); } else { SourceFileScanner sfs = new SourceFileScanner(this); newFiles = sfs.restrict(files, baseDir, getOutputDir(), mapper); } Stream.of(newFiles).map(s -> s.replace(File.separatorChar, '.')) .map(s -> s.substring(0, s.lastIndexOf(".class"))) .forEach(compileList::add); }
/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList * * @param srcDir the source directory * @param destDir the destination directory * @param files the files to scan */ protected void scanDir(File srcDir, File destDir, String[] files) { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("*.exml"); m.setTo("*.as"); SourceFileScanner sfs = new SourceFileScanner(this); File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); if (newFiles.length > 0) { File[] newCompileList = new File[compileList.length + newFiles.length]; System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length); compileList = newCompileList; } }
final SourceFileScanner ds = new SourceFileScanner(this); toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity);
/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList * * @param srcDir the source directory * @param destDir the destination directory * @param files the files to scan */ protected void scanDir(File srcDir, File destDir, String[] files) { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("*.properties"); m.setTo("*.as"); SourceFileScanner sfs = new SourceFileScanner(this); File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); if (newFiles.length > 0) { File[] newCompileList = new File[compileList.length + newFiles.length]; System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length); compileList = newCompileList; } }
upToDate = targetFile.lastModified() >= sourceFile.lastModified(); } else { SourceFileScanner sfs = new SourceFileScanner(this); upToDate = sfs.restrict(new String[] {sourceFile.getAbsolutePath()}, null, null, mapperElement.getImplementation()).length == 0;
/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList * * @param srcDir the source directory * @param destDir the destination directory * @param files the files to scan */ protected void scanDir(File srcDir, File destDir, String[] files) { GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("*" + Jooc.INPUT_FILE_SUFFIX); m.setTo("*.js"); SourceFileScanner sfs = new SourceFileScanner(this); File[] newFiles = sfs.restrictAsFiles(files, srcDir, destDir, m); if (newFiles.length > 0) { File[] newCompileList = new File[compileList.length + newFiles.length]; System.arraycopy(compileList, 0, newCompileList, 0, compileList.length); System.arraycopy(newFiles, 0, newCompileList, compileList.length, newFiles.length); compileList = newCompileList; } }
SourceFileScanner sfs = new SourceFileScanner(this); files = sfs.restrict(files, srcDir, destDir, m); int count = files.length; if (count == 0) {
/** * Scans the directory looking for source files to be compiled. * The results are returned in the class variable compileList */ protected void scanFiles(String files[]) throws BuildException { File file; // TODO: create an own pattern mapper GlobPatternMapper m = new GlobPatternMapper(); m.setFrom("*.idl"); m.setTo("*.java"); SourceFileScanner sfs = new SourceFileScanner(this); File[] newfiles = sfs.restrictAsFiles(files, _srcdir, _destdir, m); _compileList = new File[ newfiles.length ]; for (int i = 0; i < newfiles.length; i++) { log("scan file: " + newfiles[ i ].getPath(), Project.MSG_DEBUG); file = newfiles[ i ]; if (!file.exists()) { throw new BuildException("The input file \"" + file.getPath() + "\" does not exist !"); } _compileList[ i ] = file; } }
/** * Scans the directory looking for source files to be compiled. * The results are returned in the instance variable <code>reportFilesMap</code>. * * @param srcdir source directory * @param destdir destination directory * @param files included file names */ protected void scanDir(File srcdir, File destdir, String[] files) { RegexpPatternMapper mapper = new RegexpPatternMapper(); mapper.setFrom("^(.*)\\.(.*)$"); mapper.setTo("\\1.jasper"); SourceFileScanner scanner = new SourceFileScanner(this); String[] newFiles = scanner.restrict(files, srcdir, destdir, mapper); if (newFiles != null && newFiles.length > 0) { for (int i = 0; i < newFiles.length; i++) { reportFilesMap.put( (new File(srcdir, newFiles[i])).getAbsolutePath(), (new File(destdir, mapper.mapFileName(newFiles[i])[0])).getAbsolutePath() ); } } }