org.apache.tools.ant.types.FileSet Java Examples
The following examples show how to use
org.apache.tools.ant.types.FileSet.
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: UpdateSigner.java From stendhal with GNU General Public License v2.0 | 6 votes |
/** * ants execute method. */ @Override public void execute() { try { for (final FileSet fileset : filesets) { final DirectoryScanner ds = fileset.getDirectoryScanner(getProject()); final String[] includedFiles = ds.getIncludedFiles(); for (final String filename : includedFiles) { String signature = sign(ds.getBasedir().getAbsolutePath() + File.separator + filename); System.out.println("file-signature." + filename + "=" + signature); } } } catch (final Exception e) { throw new BuildException(e); } }
Example #2
Source File: AntBuildResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Before public void setUp() { TestHelper.cleanCache(); project = TestHelper.newProject(); project.setProperty("ivy.cache.dir", TestHelper.cache.getAbsolutePath()); AntWorkspaceResolver antWorkspaceResolver = new AntWorkspaceResolver(); antWorkspaceResolver.setName("test-workspace"); wa = antWorkspaceResolver.createArtifact(); FileSet fileset = new FileSet(); fileset.setProject(project); fileset.setDir(new File("test/workspace")); fileset.setIncludes("*/ivy.xml"); antWorkspaceResolver.addConfigured(fileset); antWorkspaceResolver.setProject(project); configure = new IvyConfigure(); configure.setProject(project); configure.setFile(new File("test/workspace/ivysettings.xml")); configure.addConfiguredWorkspaceResolver(antWorkspaceResolver); configure.execute(); }
Example #3
Source File: MapRenderer.java From stendhal with GNU General Public License v2.0 | 6 votes |
/** * ants execute method. */ @Override public void execute() { try { for (final FileSet fileset : filesets) { final DirectoryScanner ds = fileset.getDirectoryScanner(getProject()); final String[] includedFiles = ds.getIncludedFiles(); for (final String filename : includedFiles) { System.out.println(ds.getBasedir().getAbsolutePath() + File.separator + filename); convert(ds.getBasedir().getAbsolutePath() + File.separator + filename); } } } catch (final Exception e) { throw new BuildException(e); } }
Example #4
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 #5
Source File: RccTask.java From big-c 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 #6
Source File: UploadFileSetToS3TaskTests.java From aws-ant-tasks with Apache License 2.0 | 6 votes |
@Test public void testExecuteMultipleFiles() throws IOException { UploadFileSetToS3Task task = new UploadFileSetToS3Task(); task.setProject(new Project()); FileSet fileset = new FileSet(); fileset.setDir(testFile1.getParentFile()); fileset.setIncludes("*.txt"); task.addFileset(fileset); task.setBucketName(BUCKET_NAME); task.setKeyPrefix(KEY_PREFIX); task.execute(); resFile1 = File.createTempFile(RES_FILE_1, TESTFILE_SUFFIX); resFile2 = File.createTempFile(RES_FILE_2, TESTFILE_SUFFIX); resFile3 = File.createTempFile(RES_FILE_3, TESTFILE_SUFFIX); client.getObject(new GetObjectRequest(BUCKET_NAME, KEY_PREFIX + fileName1), resFile1); client.getObject(new GetObjectRequest(BUCKET_NAME, KEY_PREFIX + fileName2), resFile2); client.getObject(new GetObjectRequest(BUCKET_NAME, KEY_PREFIX + fileName3), resFile3); assertTrue(FileUtils.contentEquals(testFile1, resFile1)); assertTrue(FileUtils.contentEquals(testFile1, resFile1)); assertTrue(FileUtils.contentEquals(testFile1, resFile1)); }
Example #7
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testReverse() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/build.xml,F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setReverse(true); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(5, files.length); assertListOfFiles("test/buildlist/", new String[] {"E", "D", "A", "C", "B"}, files); }
Example #8
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 #9
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 #10
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithTwoRoots() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("E2/**"); buildlist.addFileset(fs); buildlist.setRoot("C,E"); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(3, files.length); // A and D should be filtered out assertListOfFiles("test/buildlist/", new String[] {"B", "C", "E"}, files); }
Example #11
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithModuleWithSameNameAndDifferentOrg() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlist")); fs.setIncludes("**/build.xml"); fs.setExcludes("F/build.xml,G/build.xml"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("skip"); String[] files = getFiles(buildlist); assertEquals(6, files.length); assertListOfFiles("test/buildlist/", new String[] {"B", "C", "A", "D"}, files); // the order of E and E2 is undefined List<URI> other = new ArrayList<>(); other.add(new File(files[4]).getAbsoluteFile().toURI()); other.add(new File(files[5]).getAbsoluteFile().toURI()); Collections.sort(other); assertEquals(new File("test/buildlist/E/build.xml").getAbsoluteFile().toURI(), other.get(0)); assertEquals(new File("test/buildlist/E2/build.xml").getAbsoluteFile().toURI(), other.get(1)); }
Example #12
Source File: IvyBuildListTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testNoParents() { FileSet fs = new FileSet(); fs.setDir(new File("test/buildlists/testNoParents")); fs.setIncludes("**/build.xml"); buildlist.addFileset(fs); buildlist.setOnMissingDescriptor("skip"); buildlist.setHaltonerror(false); String[] files = getFiles(buildlist); assertEquals(5, files.length); assertListOfFiles("test/buildlists/testNoParents/", new String[] {"bootstrap-parent", "ireland", "germany", "master-parent", "croatia"}, files); }
Example #13
Source File: FileFinder.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Returns an array with the file names of the specified file pattern that have been found in the workspace. * * @param workspace * root directory of the workspace * * @return the file names of all found files */ public String[] find(final File workspace) { try { FileSet fileSet = new FileSet(); Project antProject = new Project(); fileSet.setProject(antProject); fileSet.setDir(workspace); fileSet.setIncludes(includesPattern); TypeSelector selector = new TypeSelector(); FileType fileType = new FileType(); fileType.setValue(FileType.FILE); selector.setType(fileType); fileSet.addType(selector); if (StringUtils.isNotBlank(excludesPattern)) { fileSet.setExcludes(excludesPattern); } fileSet.setFollowSymlinks(followSymlinks); return fileSet.getDirectoryScanner(antProject).getIncludedFiles(); } catch (BuildException ignored) { return new String[0]; // as fallback do not return any file } }
Example #14
Source File: FileIterator.java From groovy with Apache License 2.0 | 5 votes |
private boolean setNextObject() { while (true) { while (ds == null) { if (!fileSetIterator.hasNext()) { return false; } FileSet fs = fileSetIterator.next(); ds = fs.getDirectoryScanner(project); ds.scan(); if (iterateDirectories) { files = ds.getIncludedDirectories(); } else { files = ds.getIncludedFiles(); } if (files.length > 0) { fileIndex = -1; break; } else { ds = null; } } if (ds != null && files != null) { if (++fileIndex < files.length) { nextFile = new File(ds.getBasedir(), files[fileIndex]); nextObjectSet = true; return true; } else { ds = null; } } } }
Example #15
Source File: MakeJNLP.java From netbeans with Apache License 2.0 | 5 votes |
private void generateVersionXMLFiles() throws IOException { FileSet fs = new FileSet(); fs.setIncludes("**/*.jar"); for (File directory : jarDirectories) { fs.setDir(directory); DirectoryScanner scan = fs.getDirectoryScanner(getProject()); StringWriter writeVersionXML = new StringWriter(); writeVersionXML.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); writeVersionXML.append("<jnlp-versions>\n"); for (String jarName : scan.getIncludedFiles()) { File jar = new File(scan.getBasedir(), jarName); JarFile jarFile = new JarFile(jar); String version = getJarVersion(jarFile); if (version != null) { writeVersionXML.append(" <resource>\n <pattern>\n <name>"); writeVersionXML.append(jar.getName()); writeVersionXML.append("</name>\n <version-id>"); writeVersionXML.append(version); writeVersionXML.append("</version-id>\n </pattern>\n <file>"); writeVersionXML.append(jar.getName()); writeVersionXML.append("</file>\n </resource>\n"); } else { writeVersionXML.append(" <!-- No version found for "); writeVersionXML.append(jar.getName()); writeVersionXML.append(" -->\n"); } } writeVersionXML.append("</jnlp-versions>\n"); writeVersionXML.close(); File versionXML = new File(directory, "version.xml"); FileWriter w = new FileWriter(versionXML); w.write(writeVersionXML.toString()); w.close(); } }
Example #16
Source File: DownloadBinariesTest.java From netbeans with Apache License 2.0 | 5 votes |
private void downloadBinaries(boolean clean) { DownloadBinaries task = new DownloadBinaries(); task.setProject(new Project()); task.setCache(cache); task.setClean(clean); task.setServer(server.toURI().toString()); FileSet manifest = new FileSet(); manifest.setFile(list); task.addManifest(manifest); task.execute(); }
Example #17
Source File: Txt2Html.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Perform the conversion * * @throws BuildException if an error occurs during execution of * this task. */ @Override public void execute() throws BuildException { int count = 0; // Step through each file and convert. Iterator<FileSet> iter = filesets.iterator(); while( iter.hasNext() ) { FileSet fs = iter.next(); DirectoryScanner ds = fs.getDirectoryScanner(getProject()); File basedir = ds.getBasedir(); String[] files = ds.getIncludedFiles(); for( int i = 0; i < files.length; i++ ) { File from = new File( basedir, files[i] ); File to = new File( todir, files[i] + ".html" ); if( !to.exists() || (from.lastModified() > to.lastModified()) ) { log( "Converting file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath(), Project.MSG_VERBOSE ); try { convert( from, to ); } catch( IOException e ) { throw new BuildException( "Could not convert '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'", e ); } count++; } } if( count > 0 ) { log( "Converted " + count + " file" + (count > 1 ? "s" : "") + " to " + todir.getAbsolutePath() ); } } }
Example #18
Source File: JarExpander.java From PoseidonX with Apache License 2.0 | 5 votes |
private FileSet createFileSetForJarFile(File jarFile, Project prj) { FileSet fileSet = new FileSet(); fileSet.setProject(prj); fileSet.setFile(jarFile); return fileSet; }
Example #19
Source File: MXJC2Task.java From mxjc with MIT License | 5 votes |
/** Nested <schema> element. */ public void addConfiguredSchema( FileSet fs ) { for (InputSource value : toInputSources(fs)) options.addGrammar(value); addIndividualFilesTo( fs, dependsSet ); }
Example #20
Source File: AntTask.java From forbidden-apis with Apache License 2.0 | 5 votes |
/** Sets a directory as base for class files. The implicit pattern '**/*.class' is used to only scan class files. */ public void setDir(File dir) { final FileSet fs = new FileSet(); fs.setProject(getProject()); fs.setDir(dir); // needed if somebody sets restrictClassFilename=false: fs.setIncludes("**/*.class"); classFiles.add(fs); }
Example #21
Source File: JNLPUpdateManifestBranding.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void execute() throws BuildException { Set<String> filePaths = new HashSet<>(); File tmpFile = null; for (FileSet fs : filesets) { if (fs != null) { DirectoryScanner scan = fs.getDirectoryScanner(getProject()); for (String f : scan.getIncludedFiles()) { filePaths.add(fs.getDir().getAbsolutePath() + File.separatorChar + f.replace(File.separatorChar, '/')); } } } try { for (String filePathIter : filePaths) { File jarFile = new File(filePathIter); if (isSigned(jarFile) == null) { tmpFile = extendLibraryManifest(getProject(), jarFile, jarFile, codebase, permissions, appName); } if (tmpFile != null) { sign(tmpFile, jarFile); deleteTmpFile(tmpFile); } else { sign(jarFile, jarFile); } } } catch (IOException | ManifestException ex) { getProject().log( "Failed to extend libraries manifests: " + ex.getMessage(), //NOI18N Project.MSG_WARN); } }
Example #22
Source File: ExclusionsFromLicenseInfo.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void execute() throws BuildException { try (FileOutputStream fos = new FileOutputStream(new File(getProject().getBaseDir(), exclusionFile)); OutputStreamWriter osw = new OutputStreamWriter(fos); BufferedWriter bw = new BufferedWriter(osw)) { Path nballPath = nball.toPath(); List<File> licenseinfofiles = Files.walk(nballPath) .filter(p -> p.endsWith("licenseinfo.xml")) .map(p -> p.toFile()) .collect(Collectors.toList()); FileSet licenseinfoFileset = new FileSet(); licenseinfoFileset.setProject(getProject()); licenseinfoFileset.setDir(nball.getAbsoluteFile()); for(File licenseInfoFile: licenseinfofiles) { Licenseinfo li = Licenseinfo.parse(licenseInfoFile); for(Fileset fs: li.getFilesets()) { for(File f: fs.getFiles()) { Path relativePath = nball.toPath().relativize(f.toPath()); licenseinfoFileset.appendIncludes(new String[]{relativePath.toString()}); bw.write(relativePath.toString()); bw.newLine(); } } } getProject().addReference(this.licenseinfoFileset, licenseinfoFileset); } catch (IOException ex) { throw new BuildException(ex); } }
Example #23
Source File: FileArchive.java From revapi with Apache License 2.0 | 5 votes |
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; }
Example #24
Source File: UnionBugs2.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void configureFindbugsEngine() { addArg("-withMessages"); addArg("-output"); addArg(to); for (FileSet s : fileSets) { File fromDir = s.getDir(getProject()); for (String file : s.getDirectoryScanner(getProject()).getIncludedFiles()) { addArg(new File(fromDir, file).toString()); } } }
Example #25
Source File: BundleInfoTask.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Add a file set with classes that shall be exported. * * @param set The file set with exports to add. */ public void addConfiguredExports(FileSet set) { final Restrict restrict = new Restrict(); restrict.add(set); restrict.add(analyzeRestriction); exportsResourceCollections.add(restrict); }
Example #26
Source File: CreateModuleXML.java From netbeans with Apache License 2.0 | 5 votes |
private void scanModules(FileSet fs, boolean isEnabled, boolean isAutoload, boolean isEager, boolean isHidden, List<String> names) throws BuildException { FileScanner scan = fs.getDirectoryScanner(getProject()); File dir = scan.getBasedir(); for (String kid : scan.getIncludedFiles()) { File module = new File(dir, kid); scanOneModule(module, kid, isEnabled, isAutoload, isEager, isHidden, names); } }
Example #27
Source File: Bundle.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addImplicitFileset() { if (baseDir != null) { final FileSet fileset = (FileSet) getImplicitFileSet().clone(); fileset.setDir(baseDir); srcFilesets.add(fileset); } }
Example #28
Source File: IvyCacheFilesetTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testEmptyConf() { project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-108.xml"); fileset.setSetid("emptyconf-setid"); fileset.setConf("empty"); fileset.execute(); Object ref = project.getReference("emptyconf-setid"); assertNotNull(ref); assertTrue(ref instanceof FileSet); FileSet fs = (FileSet) ref; DirectoryScanner directoryScanner = fs.getDirectoryScanner(project); directoryScanner.scan(); assertEquals(0, directoryScanner.getIncludedFiles().length); }
Example #29
Source File: AbstractCajaAntTask.java From caja with Apache License 2.0 | 5 votes |
public void addConfiguredFileSet(FileSet fs) { DirectoryScanner scanner = fs.getDirectoryScanner(getProject()); File baseDir = scanner.getBasedir(); scanner.scan(); String[] includedFiles = scanner.getIncludedFiles(); Arrays.sort(includedFiles); for (String localPath : includedFiles) { files.add(new File(baseDir, localPath)); } }
Example #30
Source File: CreateModuleXML.java From netbeans with Apache License 2.0 | 4 votes |
/** Add a set of module JARs that should be hidden. */ public void addHidden(FileSet fs) { hidden.add(fs); }