Java Code Examples for org.apache.tools.ant.types.Path#list()
The following examples show how to use
org.apache.tools.ant.types.Path#list() .
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: ObfuscatorTask.java From yGuard with MIT License | 6 votes |
ResourceCpResolver(Path resources, Task target){ this.resource = resources; String[] list = resources.list(); List listUrls = new ArrayList(); for (int i = 0; i <list.length; i++){ try{ URL url = new File(list[i]).toURL(); listUrls.add(url); } catch (MalformedURLException mfue){ target.getProject().log(target, "Could not resolve resource: "+mfue, Project.MSG_WARN); } } URL[] urls = new URL[listUrls.size()]; listUrls.toArray(urls); urlClassLoader = URLClassLoader.newInstance(urls, ClassLoader.getSystemClassLoader()); }
Example 2
Source File: ResourceCpResolver.java From yGuard with MIT License | 6 votes |
public ResourceCpResolver(final Path resources, final Task target) { this.resource = resources; final String[] list = resources.list(); final List listUrls = new ArrayList(); for ( int i = 0; i < list.length; i++ ) { try { final URL url = new File( list[ i ] ).toURL(); listUrls.add( url ); } catch ( MalformedURLException mfue ) { Logger.err( "Could not resolve resource: " + mfue ); target.getProject().log( target, "Could not resolve resource: " + mfue, Project.MSG_WARN ); } } final URL[] urls = new URL[listUrls.size()]; listUrls.toArray( urls ); urlClassLoader = URLClassLoader.newInstance( urls, ClassLoader.getSystemClassLoader() ); }
Example 3
Source File: ZserioTask.java From zserio with BSD 3-Clause "New" or "Revised" License | 6 votes |
private long calcLatestDependency() { long lastModified = 0; for (Path p : dependencies) { String [] files = p.list(); for (String file: files) { final long m = new File(file).lastModified(); verbose("ea: " + file + " " + m); if (m > lastModified) { lastModified = m; } } } return lastModified; }
Example 4
Source File: ZserioTask.java From zserio with BSD 3-Clause "New" or "Revised" License | 6 votes |
private long calcEarliestOutput() { long lastModified = Long.MAX_VALUE; for (Path p : output) { String [] files = p.list(); for (String file: files) { final long m = new File(file).lastModified(); if (m < lastModified) { lastModified = m; } } } return lastModified; }
Example 5
Source File: ZserioTask.java From zserio with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void cleanPreviousOutput() { int count = 0; for (Path p : output) { String [] files = p.list(); for (String file: files) { verbose("delete: " + file); final File fileObject = new File(file); if (!fileObject.delete()) System.out.println("File " + file + " cannot be deleted!"); else count++; } } System.out.println("Deleted " + count + " files."); }
Example 6
Source File: CacheWriterTask.java From netbeans with Apache License 2.0 | 6 votes |
public void execute() throws BuildException { if (paths.isEmpty()) { throw new BuildException ("Source dir or fileset required to scan for images"); } if (outDir == null) { throw new BuildException ("Output directory for cache file must be specified"); } try { CacheWriter writer = new CacheWriter(); writer.setDir(outDir.toString(), clean); Iterator it = paths.iterator(); while (it.hasNext()) { Path curr = (Path) it.next(); String[] dirs = curr.list(); for (int i=0; i < dirs.length; i++) { System.err.println("WriteDir " + dirs[i]); writer.writeDir(dirs[i], true); } } } catch (IOException ioe) { ioe.printStackTrace(); throw new BuildException (ioe.getMessage()); } }
Example 7
Source File: DependencyResolverTaskTest.java From development with Apache License 2.0 | 6 votes |
@Test public void testProjectsNotSet() { task.setWorkspacedir(TESTWORKSPACE); task.setProjects(""); task.execute(); Path path = (Path) project.getReference("resolved.projects.path"); String[] entries = path.list(); assertEquals(4, entries.length); assertEquals(new File("resources/testworkspace/project-lib") .getAbsolutePath(), entries[0]); assertEquals(new File("resources/testworkspace/project-a") .getAbsolutePath(), entries[1]); assertEquals(new File("resources/testworkspace/project-b") .getAbsolutePath(), entries[2]); assertEquals(new File("resources/testworkspace/project-c") .getAbsolutePath(), entries[3]); }
Example 8
Source File: FindBugsTask.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
/** * the auxAnalyzepath to use. * * @param src * auxAnalyzepath */ public void setAuxAnalyzepath(Path src) { boolean nonEmpty = false; String[] elementList = src.list(); for (String anElementList : elementList) { if (!"".equals(anElementList)) { nonEmpty = true; break; } } if (nonEmpty) { if (auxAnalyzepath == null) { auxAnalyzepath = src; } else { auxAnalyzepath.append(src); } } }
Example 9
Source File: FindBugsTask.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
/** * the auxclasspath to use. * * @param src * auxclasspath to use */ public void setAuxClasspath(Path src) { boolean nonEmpty = false; String[] elementList = src.list(); for (String anElementList : elementList) { if (!"".equals(anElementList)) { nonEmpty = true; break; } } if (nonEmpty) { if (auxClasspath == null) { auxClasspath = src; } else { auxClasspath.append(src); } } }
Example 10
Source File: DependencyResolverTaskTest.java From development with Apache License 2.0 | 5 votes |
@Test public void testProjectAandLib() { task.setWorkspacedir(TESTWORKSPACE); task.setProjects("project-a, project-lib"); task.execute(); Path path = (Path) project.getReference("resolved.projects.path"); String[] entries = path.list(); assertEquals(2, entries.length); assertEquals(new File("resources/testworkspace/project-lib") .getAbsolutePath(), entries[0]); assertEquals(new File("resources/testworkspace/project-a") .getAbsolutePath(), entries[1]); }
Example 11
Source File: CompileTaskSupport.java From groovy with Apache License 2.0 | 5 votes |
protected GroovyClassLoader createClassLoader() { GroovyClassLoader gcl = AccessController.doPrivileged( (PrivilegedAction<GroovyClassLoader>) () -> new GroovyClassLoader(ClassLoader.getSystemClassLoader(), config)); Path path = getClasspath(); if (path != null) { final String[] filePaths = path.list(); for (String filePath : filePaths) { gcl.addClasspath(filePath); } } return gcl; }
Example 12
Source File: DependencyResolverTaskTest.java From development with Apache License 2.0 | 5 votes |
@Test public void testProjectLib() { task.setWorkspacedir(TESTWORKSPACE); task.setProjects("project-lib"); task.execute(); Path path = (Path) project.getReference("resolved.projects.path"); String[] entries = path.list(); assertEquals(1, entries.length); assertEquals(new File("resources/testworkspace/project-lib") .getAbsolutePath(), entries[0]); }
Example 13
Source File: PackageGappTask.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Process any extraresourcespath elements provided to this task and * include the resources they refer to in the given set. */ private void processExtraResourcesPaths(Set<URL> resources) { for(Path p : extraResourcesPaths) { for(String resource : p.list()) { File resourceFile = new File(resource); try { resources.add(resourceFile.toURI().toURL()); } catch(MalformedURLException e) { throw new BuildException("Couldn't construct URL for extra resource " + resourceFile, e, getLocation()); } } } }
Example 14
Source File: SortSuiteModulesTest.java From netbeans with Apache License 2.0 | 5 votes |
private String[] getSorted(String property) { Path path = new Path(project); path.setPath(property); String paths[] = path.list(); String rets [] = new String[paths.length]; for (int i = 0; i < paths.length; i++) { rets[i] = new File(paths[i]).getName(); } return rets; }
Example 15
Source File: JPDAStart.java From netbeans with Apache License 2.0 | 5 votes |
private static ClassPath convertToClassPath (Project project, Path path) { String[] paths = path == null ? new String [0] : path.list (); List l = new ArrayList (); int i, k = paths.length; for (i = 0; i < k; i++) { String pathName = project.replaceProperties(paths[i]); File f = FileUtil.normalizeFile (project.resolveFile (pathName)); if (!isValid (f, project)) continue; URL url = fileToURL (f, project, true, false); if (url == null) continue; l.add (url); } URL[] urls = (URL[]) l.toArray (new URL [l.size ()]); return ClassPathSupport.createClassPath (urls); }
Example 16
Source File: JPDAStart.java From netbeans with Apache License 2.0 | 5 votes |
static void verifyPaths(Project project, Path path) { if (path == null) return ; String[] paths = path.list(); for (int i = 0; i < paths.length; i++) { String pathName = project.replaceProperties(paths[i]); File file = FileUtil.normalizeFile (project.resolveFile (pathName)); if (!file.exists()) { project.log("Non-existing path \""+pathName+"\" provided.", Project.MSG_WARN); //throw new BuildException("Non-existing path \""+paths[i]+"\" provided."); } } }
Example 17
Source File: GenerateJnlpFileTask.java From netbeans with Apache License 2.0 | 5 votes |
private static Set<? extends File> getLazyJarsSet(final Project prj, final List<? extends File> runCp, final Path value) { final Set<File> result = new HashSet<File>(); if (value != null) { for (String pathElement : value.list()) { result.add(prj.resolveFile(pathElement)); } } for (File re : runCp) { if (Project.toBoolean(prj.getProperty(String.format(JNLP_LAZY_FORMAT, re.getName())))) { result.add(re); } } return result; }
Example 18
Source File: DependencyResolverTaskTest.java From development with Apache License 2.0 | 5 votes |
@Test public void testProjectBandA() { task.setWorkspacedir(TESTWORKSPACE); task.setProjects("project-b, project-a"); task.execute(); Path path = (Path) project.getReference("resolved.projects.path"); String[] entries = path.list(); assertEquals(3, entries.length); assertEquals(new File("resources/testworkspace/project-lib") .getAbsolutePath(), entries[0]); assertEquals(new File("resources/testworkspace/project-b") .getAbsolutePath(), entries[1]); assertEquals(new File("resources/testworkspace/project-a") .getAbsolutePath(), entries[2]); }
Example 19
Source File: ToolWrapper.java From zserio with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Puts all classpath items into a list of URLs * * @return */ private URL [] getUrls() throws BuildException { ArrayList<URL> urls = new ArrayList<URL>(); for (Path p : classPath) { String [] files = p.list(); for (String f : files) { String u = null; try { if (f.endsWith(".jar")) { u = "jar:file:"+f+"!/"; } else { u = "file:"+f+"/"; } System.out.println("Adding " + u + " to classpath"); urls.add(new URL(u)); } catch (MalformedURLException e) { throw new BuildException("Malformed URL: " + u); } } } URL [] res = new URL[urls.size()]; urls.toArray(res); return res; }
Example 20
Source File: JPDAStart.java From netbeans with Apache License 2.0 | 4 votes |
/** * This method uses SourceForBinaryQuery to find sources for each * path item and returns them as ClassPath instance. All path items for which * the sources were not found are omitted. * */ private static ClassPath convertToSourcePath (Project project, Path path, boolean reportNonExistingFiles) { String[] paths = path == null ? new String [0] : path.list (); List l = new ArrayList (); Set exist = new HashSet (); int i, k = paths.length; for (i = 0; i < k; i++) { String pathName = project.replaceProperties(paths[i]); final String pathInArchive; final int index = pathName.lastIndexOf(URL_EMBEDDING); if (index >= 0) { pathInArchive = pathName.substring(index+URL_EMBEDDING.length()).replace(File.separatorChar, '/'); //NOI18N pathName = pathName.substring(0, index); } else { pathInArchive = ""; //NOI18N } File file = FileUtil.normalizeFile (project.resolveFile (pathName)); if (!isValid (file, project)) continue; URL url = fileToURL (file, project, reportNonExistingFiles, true); if (url == null) continue; if (!pathInArchive.isEmpty()) { url = appendPathInArchive(url, pathInArchive, project); } logger.log(Level.FINE, "convertToSourcePath - class: {0}", url); // NOI18N try { SourceForBinaryQuery.Result srcRootsResult = SourceForBinaryQuery.findSourceRoots(url); FileObject fos[] = srcRootsResult.getRoots(); int j, jj = fos.length; logger.log(Level.FINE, " source roots = {0}; jj = {1}", new Object[]{java.util.Arrays.asList(fos), jj}); /* ?? (#60640) if (jj == 0) { // no sourcepath defined // Take all registered source roots Set allSourceRoots = GlobalPathRegistry.getDefault().getSourceRoots(); fos = (FileObject[]) allSourceRoots.toArray(new FileObject[0]); jj = fos.length; } */ for (j = 0; j < jj; j++) { FileObject fo = fos[j]; logger.log(Level.FINE, "convertToSourcePath - source : {0}", fo); // NOI18N if (FileUtil.isArchiveFile (fo)) { fo = FileUtil.getArchiveRoot (fo); if (fo == null) { // can occur if we fail to find the actual archive fo = fos[j]; } } url = fo.toURL (); if (url == null) continue; if (!exist.contains (url)) { l.add (ClassPathSupport.createResource (url)); exist.add (url); } } // for } catch (IllegalArgumentException ex) { Exceptions.printStackTrace(ex); logger.log(Level.FINE, "Have illegal url! {0}", ex.getLocalizedMessage()); // NOI18N } } return ClassPathSupport.createClassPath (l); }