Java Code Examples for org.apache.tools.ant.types.FileSet#getDir()
The following examples show how to use
org.apache.tools.ant.types.FileSet#getDir() .
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: BasicStyleCheckerTask.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void execute() throws BuildException { BasicStyleCheckerEngine engine = new BasicStyleCheckerEngine(); try { for (FileSet fileset: filesets) { final DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); for (String filename: scanner.getIncludedFiles()) { final File file = new File(fileset.getDir(getProject()), filename); System.out.println(file.getCanonicalPath()); engine.check(file); } } } catch (IOException e) { throw new BuildException(e); } }
Example 2
Source File: RccTask.java From hadoop with Apache License 2.0 | 6 votes |
/** * Invoke the Hadoop record compiler on each record definition file */ @Override public void execute() throws BuildException { if (src == null && filesets.size()==0) { throw new BuildException("There must be a file attribute or a fileset child element"); } if (src != null) { doCompile(src); } Project myProject = getProject(); for (int i = 0; i < filesets.size(); i++) { FileSet fs = filesets.get(i); DirectoryScanner ds = fs.getDirectoryScanner(myProject); File dir = fs.getDir(myProject); String[] srcs = ds.getIncludedFiles(); for (int j = 0; j < srcs.length; j++) { doCompile(new File(dir, srcs[j])); } } }
Example 3
Source File: TestSummaryCreatorTask.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Returns the list of input files ({@link java.io.File} objects) to process. * Note that this does not check that the file is a valid and useful XML file. * * @return The input files */ private List getInputFiles() { ArrayList result = new ArrayList(); for (Iterator it = _fileSets.iterator(); it.hasNext();) { FileSet fileSet = (FileSet)it.next(); File fileSetDir = fileSet.getDir(getProject()); DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject()); String[] files = scanner.getIncludedFiles(); for (int idx = 0; (files != null) && (idx < files.length); idx++) { File file = new File(fileSetDir, files[idx]); if (file.isFile() && file.canRead()) { result.add(file); } } } return result; }
Example 4
Source File: RccTask.java From hadoop-gpu with Apache License 2.0 | 6 votes |
/** * Invoke the Hadoop record compiler on each record definition file */ public void execute() throws BuildException { if (src == null && filesets.size()==0) { throw new BuildException("There must be a file attribute or a fileset child element"); } if (src != null) { doCompile(src); } Project myProject = getProject(); for (int i = 0; i < filesets.size(); i++) { FileSet fs = filesets.get(i); DirectoryScanner ds = fs.getDirectoryScanner(myProject); File dir = fs.getDir(myProject); String[] srcs = ds.getIncludedFiles(); for (int j = 0; j < srcs.length; j++) { doCompile(new File(dir, srcs[j])); } } }
Example 5
Source File: RccTask.java From RDFS with Apache License 2.0 | 6 votes |
/** * Invoke the Hadoop record compiler on each record definition file */ public void execute() throws BuildException { if (src == null && filesets.size()==0) { throw new BuildException("There must be a file attribute or a fileset child element"); } if (src != null) { doCompile(src); } Project myProject = getProject(); for (int i = 0; i < filesets.size(); i++) { FileSet fs = filesets.get(i); DirectoryScanner ds = fs.getDirectoryScanner(myProject); File dir = fs.getDir(myProject); String[] srcs = ds.getIncludedFiles(); for (int j = 0; j < srcs.length; j++) { doCompile(new File(dir, srcs[j])); } } }
Example 6
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 7
Source File: BasicInstrumentationTask.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private void collectClassNames() { logger.info( "collecting class names for extended instrumentation determination" ); Project project = getProject(); Iterator filesets = filesets(); while ( filesets.hasNext() ) { FileSet fs = ( FileSet ) filesets.next(); DirectoryScanner ds = fs.getDirectoryScanner( project ); String[] includedFiles = ds.getIncludedFiles(); File d = fs.getDir( project ); for ( int i = 0; i < includedFiles.length; ++i ) { File file = new File( d, includedFiles[i] ); try { collectClassNames( file ); } catch ( Exception e ) { throw new BuildException( e ); } } } logger.info( classNames.size() + " class(es) being checked" ); }
Example 8
Source File: AbstractProcessTask.java From astor with GNU General Public License v2.0 | 5 votes |
protected Collection getFiles() { Map fileMap = new HashMap(); Project p = getProject(); for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet)filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(p); String[] srcFiles = ds.getIncludedFiles(); File dir = fs.getDir(p); for (int j = 0; j < srcFiles.length; j++) { File src = new File(dir, srcFiles[j]); fileMap.put(src.getAbsolutePath(), src); } } return fileMap.values(); }
Example 9
Source File: AbstractProcessTask.java From astor with GNU General Public License v2.0 | 5 votes |
protected Collection getFiles() { Map fileMap = new HashMap(); Project p = getProject(); for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet)filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(p); String[] srcFiles = ds.getIncludedFiles(); File dir = fs.getDir(p); for (int j = 0; j < srcFiles.length; j++) { File src = new File(dir, srcFiles[j]); fileMap.put(src.getAbsolutePath(), src); } } return fileMap.values(); }
Example 10
Source File: SqlTestCaseConfig.java From doma-gen with Apache License 2.0 | 5 votes |
/** @param fileSet SQLファイルの集合 */ public void addConfiguredFileSet(FileSet fileSet) { DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject()); File baseDir = fileSet.getDir(); for (String fileName : scanner.getIncludedFiles()) { sqlFiles.add(new File(baseDir, fileName)); } }
Example 11
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 12
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 13
Source File: AbstractProcessTask.java From cglib with Apache License 2.0 | 5 votes |
protected Collection getFiles() { Map fileMap = new HashMap(); Project p = getProject(); for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet)filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(p); String[] srcFiles = ds.getIncludedFiles(); File dir = fs.getDir(p); for (int j = 0; j < srcFiles.length; j++) { File src = new File(dir, srcFiles[j]); fileMap.put(src.getAbsolutePath(), src); } } return fileMap.values(); }
Example 14
Source File: UnionBugs.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private List<File> createListOfAllFilesToMerge() { List<File> fileList = new ArrayList<>(); for (FileSet s : fileSets) { File fromDir = s.getDir(getProject()); for (String file : s.getDirectoryScanner(getProject()).getIncludedFiles()) { fileList.add(new File(fromDir, file)); } } return fileList; }
Example 15
Source File: DdlToDatabaseTask.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ protected Database readModel() { DatabaseIO reader = new DatabaseIO(); Database model = null; reader.setValidateXml(_validateXml); reader.setUseInternalDtd(_useInternalDtd); if ((_singleSchemaFile != null) && !_fileSets.isEmpty()) { throw new BuildException("Please use either the schemafile attribute or the sub fileset element, but not both"); } if (_singleSchemaFile != null) { model = readSingleSchemaFile(reader, _singleSchemaFile); } else { for (Iterator it = _fileSets.iterator(); it.hasNext();) { FileSet fileSet = (FileSet)it.next(); File fileSetDir = fileSet.getDir(getProject()); DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject()); String[] files = scanner.getIncludedFiles(); for (int idx = 0; (files != null) && (idx < files.length); idx++) { Database curModel = readSingleSchemaFile(reader, new File(fileSetDir, files[idx])); if (model == null) { model = curModel; } else if (curModel != null) { try { model.mergeWith(curModel); } catch (IllegalArgumentException ex) { throw new BuildException("Could not merge with schema from file "+files[idx]+": "+ex.getLocalizedMessage(), ex); } } } } } return model; }
Example 16
Source File: WriteDataToDatabaseCommand.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public void execute(DatabaseTaskBase task, Database model) throws BuildException { if ((_singleDataFile != null) && !_fileSets.isEmpty()) { throw new BuildException("Please use either the datafile attribute or the sub fileset element, but not both"); } Platform platform = getPlatform(); DataReader dataReader = null; // GemStone changes BEGIN boolean ignoreEndEx = true; platform.setAddIdentityUsingAlterTable(_addIdentityUsingAlterTable); // GemStone changes END platform.setIdentityOverrideOn(_useExplicitIdentityValues); try { dataReader = getDataIO().getConfiguredDataReader(platform, model); dataReader.getSink().start(); if (_singleDataFile != null) { readSingleDataFile(task, dataReader, _singleDataFile); } else { for (Iterator it = _fileSets.iterator(); it.hasNext();) { FileSet fileSet = (FileSet)it.next(); File fileSetDir = fileSet.getDir(task.getProject()); DirectoryScanner scanner = fileSet.getDirectoryScanner(task.getProject()); String[] files = scanner.getIncludedFiles(); for (int idx = 0; (files != null) && (idx < files.length); idx++) { readSingleDataFile(task, dataReader, new File(fileSetDir, files[idx])); } } } // GemStone changes BEGIN ignoreEndEx = false; // GemStone changes END } catch (Exception ex) { handleException(ex, ex.getMessage()); // GemStone changes BEGIN ignoreEndEx = false; // GemStone changes END } finally { if (dataReader != null) { // GemStone changes BEGIN if (ignoreEndEx) { try { dataReader.getSink().end(); writeAddIdentityUsingAlterTable(platform, model); } catch (DataSinkException dse) { // keep the original thrown exception } } else { // GemStone changes END dataReader.getSink().end(); // GemStone changes BEGIN writeAddIdentityUsingAlterTable(platform, model); } // GemStone changes END } } }
Example 17
Source File: DdlToDatabaseTask.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ protected Database readModel() { DatabaseIO reader = new DatabaseIO(); Database model = null; reader.setValidateXml(_validateXml); reader.setUseInternalDtd(_useInternalDtd); if ((_singleSchemaFile != null) && !_fileSets.isEmpty()) { throw new BuildException("Please use either the schemafile attribute or the sub fileset element, but not both"); } if (_singleSchemaFile != null) { model = readSingleSchemaFile(reader, _singleSchemaFile); } else { for (Iterator it = _fileSets.iterator(); it.hasNext();) { FileSet fileSet = (FileSet)it.next(); File fileSetDir = fileSet.getDir(getProject()); DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject()); String[] files = scanner.getIncludedFiles(); for (int idx = 0; (files != null) && (idx < files.length); idx++) { Database curModel = readSingleSchemaFile(reader, new File(fileSetDir, files[idx])); if (model == null) { model = curModel; } else if (curModel != null) { try { model.mergeWith(curModel); } catch (IllegalArgumentException ex) { throw new BuildException("Could not merge with schema from file "+files[idx]+": "+ex.getLocalizedMessage(), ex); } } } } } return model; }
Example 18
Source File: WriteDataToDatabaseCommand.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public void execute(DatabaseTaskBase task, Database model) throws BuildException { if ((_singleDataFile != null) && !_fileSets.isEmpty()) { throw new BuildException("Please use either the datafile attribute or the sub fileset element, but not both"); } Platform platform = getPlatform(); DataReader dataReader = null; // GemStone changes BEGIN boolean ignoreEndEx = true; platform.setAddIdentityUsingAlterTable(_addIdentityUsingAlterTable); // GemStone changes END platform.setIdentityOverrideOn(_useExplicitIdentityValues); try { dataReader = getDataIO().getConfiguredDataReader(platform, model); dataReader.getSink().start(); if (_singleDataFile != null) { readSingleDataFile(task, dataReader, _singleDataFile); } else { for (Iterator it = _fileSets.iterator(); it.hasNext();) { FileSet fileSet = (FileSet)it.next(); File fileSetDir = fileSet.getDir(task.getProject()); DirectoryScanner scanner = fileSet.getDirectoryScanner(task.getProject()); String[] files = scanner.getIncludedFiles(); for (int idx = 0; (files != null) && (idx < files.length); idx++) { readSingleDataFile(task, dataReader, new File(fileSetDir, files[idx])); } } } // GemStone changes BEGIN ignoreEndEx = false; // GemStone changes END } catch (Exception ex) { handleException(ex, ex.getMessage()); // GemStone changes BEGIN ignoreEndEx = false; // GemStone changes END } finally { if (dataReader != null) { // GemStone changes BEGIN if (ignoreEndEx) { try { dataReader.getSink().end(); writeAddIdentityUsingAlterTable(platform, model); } catch (DataSinkException dse) { // keep the original thrown exception } } else { // GemStone changes END dataReader.getSink().end(); // GemStone changes BEGIN writeAddIdentityUsingAlterTable(platform, model); } // GemStone changes END } } }
Example 19
Source File: CommentCorrecterTask.java From netbeans with Apache License 2.0 | 4 votes |
/** * Executes the ant task, performing initial comment correction on the set of * files defined in <code>filesets</code>. Overrides the <code>execute()</code> * method in the <code>Task</code> class. * * @throws org.apache.tools.ant.BuildException if parameters validation fails or * an I/O error occurs */ @Override public void execute() throws BuildException { if (text == null) { throw new BuildException( "The 'text' attribute is required."); // NOI18N } try { final String comment = Utils.readFile(text); for (FileSet fileset: filesets) { final DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); for (String filename: scanner.getIncludedFiles()) { final File file = new File(fileset.getDir(getProject()), filename); log(file.getAbsolutePath()); final FileHandler handler = CommentCorrecter.getInstance().getHandler(file); if (handler != null) { handler.load(file); final String current = handler.getCurrentComment(); if (current == null) { log(" ...inserting " + // NOI18N "the initial comment"); // NOI18N handler.insertComment(comment, lineLength); } else { final String correct = handler.getCorrectComment(comment, lineLength); if (current.equals(correct)) { log(" ...skipping -- " + // NOI18N "the comment is up to date"); // NOI18N } else { log(" ...updating " + // NOI18N "the initial comment"); // NOI18N handler.updateComment(comment, lineLength); } } handler.save(file); } else { log(" ...skipping -- " + // NOI18N "not recognized by any handler"); // NOI18N } } } } catch (IOException e) { throw new BuildException(e); } }
Example 20
Source File: JPDAReload.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void execute() throws BuildException { if (logger.isLoggable(Level.FINE)) { logger.fine("JPDAReload.execute(), filesets = "+filesets); } if (filesets.size() == 0) { throw new BuildException ("A nested fileset with class to refresh in VM must be specified."); } // check debugger state DebuggerEngine debuggerEngine = DebuggerManager.getDebuggerManager (). getCurrentEngine (); if (debuggerEngine == null) { throw new BuildException ("No debugging sessions was found."); } JPDADebugger debugger = debuggerEngine.lookupFirst(null, JPDADebugger.class); if (debugger == null) { throw new BuildException("Current debugger is not JPDA one."); } if (!debugger.canFixClasses ()) { throw new BuildException("The debugger does not support Fix action."); } if (debugger.getState () == JPDADebugger.STATE_DISCONNECTED) { throw new BuildException ("The debugger is not running"); } System.out.println ("Classes to be reloaded:"); FileUtils fileUtils = FileUtils.getFileUtils(); Map map = new HashMap (); EditorContext editorContext = DebuggerManager.getDebuggerManager().lookupFirst(null, EditorContext.class); Iterator it = filesets.iterator (); while (it.hasNext ()) { FileSet fs = (FileSet) it.next (); DirectoryScanner ds = fs.getDirectoryScanner (getProject ()); String fileNames[] = ds.getIncludedFiles (); File baseDir = fs.getDir (getProject ()); int i, k = fileNames.length; for (i = 0; i < k; i++) { File f = fileUtils.resolveFile (baseDir, fileNames [i]); if (f != null) { FileObject fo = FileUtil.toFileObject(f); if (fo != null) { try { String url = classToSourceURL (fo); if (url != null) editorContext.updateTimeStamp (debugger, url); InputStream is = fo.getInputStream (); long fileSize = fo.getSize (); byte[] bytecode = new byte [(int) fileSize]; is.read (bytecode); // remove ".class" from and use dots for for separator String className = fileNames [i].substring ( 0, fileNames [i].length () - 6 ).replace (File.separatorChar, '.'); map.put ( className, bytecode ); System.out.println (" " + className); } catch (IOException ex) { ex.printStackTrace (); } } } } } if (logger.isLoggable(Level.FINE)) { logger.fine("Reloaded classes: "+map.keySet()); } if (map.size () == 0) { System.out.println (" No class to reload"); return; } String error = null; try { debugger.fixClasses (map); } catch (UnsupportedOperationException uoex) { error = "The virtual machine does not support this operation: "+uoex.getLocalizedMessage(); } catch (NoClassDefFoundError ncdfex) { error = "The bytes don't correspond to the class type (the names don't match): "+ncdfex.getLocalizedMessage(); } catch (VerifyError ver) { error = "A \"verifier\" detects that a class, though well formed, contains an internal inconsistency or security problem: "+ver.getLocalizedMessage(); } catch (UnsupportedClassVersionError ucver) { error = "The major and minor version numbers in bytes are not supported by the VM. "+ucver.getLocalizedMessage(); } catch (ClassFormatError cfer) { error = "The bytes do not represent a valid class. "+cfer.getLocalizedMessage(); } catch (ClassCircularityError ccer) { error = "A circularity has been detected while initializing a class: "+ccer.getLocalizedMessage(); } catch (VMOutOfMemoryException oomex) { error = "Out of memory in the target VM has occurred during class reload."; } if (error != null) { getProject().log(error, Project.MSG_ERR); throw new BuildException(error); } }