Java Code Examples for org.apache.tools.ant.FileScanner#getIncludedFiles()
The following examples show how to use
org.apache.tools.ant.FileScanner#getIncludedFiles() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckHelpSets.java From netbeans with Apache License 2.0 | 6 votes |
public void execute() throws BuildException { for(FileSet fs: filesets) { FileScanner scanner = fs.getDirectoryScanner(getProject()); File dir = scanner.getBasedir(); String[] files = scanner.getIncludedFiles(); for (int i = 0; i < files.length; i++) { File helpset = new File(dir, files[i]); try { checkHelpSet(helpset); } catch (BuildException be) { throw be; } catch (Exception e) { throw new BuildException("Error checking helpset", e, new Location(helpset.getAbsolutePath())); } } } }
Example 2
Source File: JarBundler.java From JarBundler with Apache License 2.0 | 6 votes |
private void processExtraClassPathFileSets() throws BuildException { for (Iterator jarIter = mExtraClassPathFileSets.iterator(); jarIter .hasNext();) { FileSet fs = (FileSet) jarIter.next(); Project p = fs.getProject(); File srcDir = fs.getDir(p); FileScanner ds = fs.getDirectoryScanner(p); fs.setupDirectoryScanner(ds, p); ds.scan(); String[] files = ds.getIncludedFiles(); for (int i = 0; i < files.length; i++) { File f = new File(srcDir, files[i]); String path = f.getPath().replace(File.separatorChar, '/'); bundleProperties.addToExtraClassPath(path); } } }
Example 3
Source File: CheckLinks.java From netbeans with Apache License 2.0 | 5 votes |
public void execute () throws BuildException { if (basedir == null) throw new BuildException ("Must specify the basedir attribute"); FileScanner scanner = getDirectoryScanner (basedir); scanner.scan (); String message = "Scanning for broken links in " + basedir + " ..."; if (! checkexternal) message += " (external URLs will be skipped)"; log (message); String[] files = scanner.getIncludedFiles (); Set<URI> okurls = new HashSet<>(1000); Set<URI> badurls = new HashSet<>(100); Set<URI> cleanurls = new HashSet<>(100); List<String> errors = new ArrayList<>(); for (int i = 0; i < files.length; i++) { File file = new File (basedir, files[i]); URI fileurl = file.toURI(); log ("Scanning " + file, Project.MSG_VERBOSE); try { scan(this, null, null, getLocation().toString(), "", fileurl, okurls, badurls, cleanurls, checkexternal, checkspaces, checkforbidden, 1, mappers, filters, errors); } catch (IOException ioe) { throw new BuildException("Could not scan " + file + ": " + ioe, ioe, getLocation()); } } String testMessage = null; if (!errors.isEmpty()) { StringBuilder b = new StringBuilder("There were broken links"); for (String error : errors) { b.append("\n" + error); } testMessage = b.toString(); } JUnitReportWriter.writeReport(this, null, report, Collections.singletonMap("testBrokenLinks", testMessage)); }
Example 4
Source File: Bundle.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addZipGroups() { for (int i = 0; i < zipgroups.size(); i++) { final FileSet fileset = zipgroups.get(i); final FileScanner fs = fileset.getDirectoryScanner(getProject()); final String[] files = fs.getIncludedFiles(); final File basedir = fs.getBasedir(); for (final String file : files) { final ZipFileSet zipfileset = new ZipFileSet(); zipfileset.setSrc(new File(basedir, file)); srcFilesets.add(zipfileset); } } }
Example 5
Source File: JarBundler.java From JarBundler with Apache License 2.0 | 5 votes |
private void processJarFileSets() throws BuildException { for (Iterator jarIter = mJarFileSets.iterator(); jarIter.hasNext();) { FileSet fs = (FileSet) jarIter.next(); Project p = fs.getProject(); File srcDir = fs.getDir(p); FileScanner ds = fs.getDirectoryScanner(p); fs.setupDirectoryScanner(ds, p); ds.scan(); String[] files = ds.getIncludedFiles(); try { for (int i = 0; i < files.length; i++) { String fileName = files[i]; File src = new File(srcDir, fileName); File dest = new File(mJavaDir, fileName); if (mVerbose) log("Copying JAR file to \"" + bundlePath(dest) + "\""); mFileUtils.copyFile(src, dest); bundleProperties.addToClassPath(fileName); } } catch (IOException ex) { throw new BuildException("Cannot copy jar file: " + ex); } } }
Example 6
Source File: JarBundler.java From JarBundler with Apache License 2.0 | 5 votes |
private void processCopyingFileSets(List fileSets, File targetdir, boolean setExec) { for (Iterator execIter = fileSets.iterator(); execIter.hasNext();) { FileSet fs = (FileSet) execIter.next(); Project p = fs.getProject(); File srcDir = fs.getDir(p); FileScanner ds = fs.getDirectoryScanner(p); fs.setupDirectoryScanner(ds, p); ds.scan(); String[] files = ds.getIncludedFiles(); if (files.length == 0) { // this is probably an error -- warn about it System.err .println("WARNING: fileset for copying from directory " + srcDir + ": no files found"); } else { try { for (int i = 0; i < files.length; i++) { String fileName = files[i]; File src = new File(srcDir, fileName); File dest = new File(targetdir, fileName); if (mVerbose) log("Copying " + (setExec ? "exec" : "resource") + " file to \"" + bundlePath(dest) +"\""); mFileUtils.copyFile(src, dest); if (setExec) setExecutable(dest); } } catch (IOException ex) { throw new BuildException("Cannot copy file: " + ex); } } } }
Example 7
Source File: CheckLicense.java From netbeans with Apache License 2.0 | 4 votes |
public @Override void execute() throws BuildException { if (fragment == null) { if (fragments == null) { throw new BuildException("You must supply a fragment", getLocation()); } executeReplace(); return; } if (filesets.isEmpty()) { throw new BuildException("You must supply at least one fileset", getLocation()); } String failMsg = null; try { for (FileSet fileset : filesets) { FileScanner scanner = fileset.getDirectoryScanner(getProject()); File baseDir = scanner.getBasedir (); String[] files = scanner.getIncludedFiles (); log ("Looking for " + fragment + " in " + files.length + " files in " + baseDir.getAbsolutePath ()); for (int i = 0; i < files.length; i++) { File f = new File (baseDir, files[i]); //log("Scanning " + f, Project.MSG_VERBOSE); try (BufferedReader br = new BufferedReader (new FileReader (f))) { String line; while ((line = br.readLine ()) != null) { if (line.indexOf (fragment) != -1) { // Found it. if (fail != null && "whenpresent".equals(fail.getValue())) { if (failMsg != null) { log(failMsg, Project.MSG_ERR); } failMsg = "License found in " + f; } break; } } if (line == null) { String msg = f.getAbsolutePath () + ":1: no license notice found"; if (fail != null && "whenmissing".equals(fail.getValue())) { throw new BuildException(msg); } if (fail == null) { // Scanned whole file without finding it. log (msg, Project.MSG_ERR); } } } } } if (failMsg != null) { throw new BuildException(failMsg); } } catch (IOException ioe) { throw new BuildException("Could not open files to check licenses", ioe, getLocation()); } }