org.apache.tools.ant.types.ResourceCollection Java Examples
The following examples show how to use
org.apache.tools.ant.types.ResourceCollection.
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: AntWorkspaceResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
private synchronized Map<ModuleDescriptor, File> getModuleDescriptors() { if (md2IvyFile == null) { md2IvyFile = new HashMap<>(); for (ResourceCollection resources : allResources) { for (Resource resource : resources) { File ivyFile = ((FileResource) resource).getFile(); try { ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance() .parseDescriptor(getParserSettings(), ivyFile.toURI().toURL(), isValidate()); md2IvyFile.put(md, ivyFile); Message.debug("Add " + md.getModuleRevisionId().getModuleId()); } catch (Exception ex) { if (haltOnError) { throw new BuildException("impossible to parse ivy file " + ivyFile + " exception=" + ex, ex); } else { Message.warn("impossible to parse ivy file " + ivyFile + " exception=" + ex.getMessage()); } } } } } return md2IvyFile; }
Example #2
Source File: Test.java From IntelliJDeodorant with MIT License | 5 votes |
protected Resource[][] grabNonFileSetResources(ResourceCollection[] rcs) { Resource[][] result = new Resource[rcs.length][]; for (int i = 0; i < rcs.length; i++) { ArrayList<Resource> dirs = new ArrayList<Resource>(); ArrayList<Resource> files = new ArrayList<Resource>(); for (Resource r : rcs[i]) { if (r.isExists()) { if (r.isDirectory()) { dirs.add(r); } else { files.add(r); } } } // make sure directories are in alpha-order - this also // ensures parents come before their children Collections.sort(dirs, new Comparator<Resource>() { public int compare(Resource r1, Resource r2) { return r1.getName().compareTo(r2.getName()); } }); ArrayList<Resource> rs = new ArrayList<Resource>(dirs); rs.addAll(files); result[i] = rs.toArray(new Resource[rs.size()]); } return result; }
Example #3
Source File: Test.java From IntelliJDeodorant with MIT License | 5 votes |
public Resource[][] grabManifests(ResourceCollection[] rcs) { Resource[][] manifests = new Resource[rcs.length][]; for (int i = 0; i < rcs.length; i++) { Resource[][] resources = null; if (rcs[i] instanceof FileSet) { resources = testProduct.grabResources(new FileSet[]{(FileSet) rcs[i]}, this.project); } else { resources = grabNonFileSetResources(new ResourceCollection[]{ rcs[i] }); } for (int j = 0; j < resources[0].length; j++) { String name = resources[0][j].getName().replace('\\', '/'); if (rcs[i] instanceof ArchiveFileSet) { ArchiveFileSet afs = (ArchiveFileSet) rcs[i]; if (!"".equals(afs.getFullpath(getProject()))) { name = afs.getFullpath(getProject()); } else if (!"".equals(afs.getPrefix(getProject()))) { String prefix = afs.getPrefix(getProject()); if (!prefix.endsWith("/") && !prefix.endsWith("\\")) { prefix += "/"; } name = prefix + name; } } if (name.equalsIgnoreCase(MANIFEST_NAME)) { manifests[i] = new Resource[]{resources[0][j]}; break; } } if (manifests[i] == null) { manifests[i] = new Resource[0]; } } return manifests; }
Example #4
Source File: Test.java From IntelliJDeodorant with MIT License | 5 votes |
protected Resource[][] grabNonFileSetResources(ResourceCollection[] rcs) { Resource[][] result = new Resource[rcs.length][]; for (int i = 0; i < rcs.length; i++) { ArrayList<Resource> dirs = new ArrayList<Resource>(); ArrayList<Resource> files = new ArrayList<Resource>(); for (Resource r : rcs[i]) { if (r.isExists()) { if (r.isDirectory()) { dirs.add(r); } else { files.add(r); } } } // make sure directories are in alpha-order - this also // ensures parents come before their children Collections.sort(dirs, new Comparator<Resource>() { public int compare(Resource r1, Resource r2) { return r1.getName().compareTo(r2.getName()); } }); ArrayList<Resource> rs = new ArrayList<Resource>(dirs); rs.addAll(files); result[i] = rs.toArray(new Resource[rs.size()]); } return result; }
Example #5
Source File: Test.java From IntelliJDeodorant with MIT License | 5 votes |
public Resource[][] grabManifests(ResourceCollection[] rcs) { Resource[][] manifests = new Resource[rcs.length][]; for (int i = 0; i < rcs.length; i++) { Resource[][] resources = null; if (rcs[i] instanceof FileSet) { resources = grabResources(new FileSet[] {(FileSet) rcs[i]}); } else { resources = grabNonFileSetResources(new ResourceCollection[] { rcs[i] }); } for (int j = 0; j < resources[0].length; j++) { String name = resources[0][j].getName().replace('\\', '/'); if (rcs[i] instanceof ArchiveFileSet) { ArchiveFileSet afs = (ArchiveFileSet) rcs[i]; if (!"".equals(afs.getFullpath(getProject()))) { name = afs.getFullpath(getProject()); } else if (!"".equals(afs.getPrefix(getProject()))) { String prefix = afs.getPrefix(getProject()); if (!prefix.endsWith("/") && !prefix.endsWith("\\")) { prefix += "/"; } name = prefix + name; } } if (name.equalsIgnoreCase(MANIFEST_NAME)) { manifests[i] = new Resource[] {resources[0][j]}; break; } } if (manifests[i] == null) { manifests[i] = new Resource[0]; } } return manifests; }
Example #6
Source File: Test.java From IntelliJDeodorant with MIT License | 5 votes |
protected Resource[][] grabNonFileSetResources(ResourceCollection[] rcs) { Resource[][] result = new Resource[rcs.length][]; for (int i = 0; i < rcs.length; i++) { ArrayList<Resource> dirs = new ArrayList<Resource>(); ArrayList<Resource> files = new ArrayList<Resource>(); for (Resource r : rcs[i]) { if (r.isExists()) { if (r.isDirectory()) { dirs.add(r); } else { files.add(r); } } } // make sure directories are in alpha-order - this also // ensures parents come before their children Collections.sort(dirs, new Comparator<Resource>() { public int compare(Resource r1, Resource r2) { return r1.getName().compareTo(r2.getName()); } }); ArrayList<Resource> rs = new ArrayList<Resource>(dirs); rs.addAll(files); result[i] = rs.toArray(new Resource[rs.size()]); } return result; }
Example #7
Source File: CompileTask.java From textuml with Eclipse Public License 1.0 | 5 votes |
public synchronized void add(ResourceCollection c) { if (c == null) { return; } resources = (resources == null) ? new Resources() : resources; resources.add(c); }
Example #8
Source File: Groovy.java From groovy with Apache License 2.0 | 5 votes |
/** * Set the source resource. * @param a the resource to load as a single element Resource collection. */ public void addConfigured(ResourceCollection a) { if (a.size() != 1) { throw new BuildException("Only single argument resource collections are supported"); } src = a.iterator().next(); }
Example #9
Source File: BundleInfoTask.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Add file sets for private classes on the bundle classpath. * * @param bcpt The bundle classpath that the bundle will have. */ public void addConfiguredImplsBundleClasspath(BundleClasspathTask bcpt) { for (final Object element : bcpt.getFileSets(failOnClassPath)) { final Restrict restrict = new Restrict(); restrict.add((ResourceCollection) element); restrict.add(analyzeRestriction); implsResourceCollections.add(restrict); } }
Example #10
Source File: BundleInfoTask.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Add file sets for classes exported from the bundle classpath. * * @param bcpt The bundle classpath that the bundle will have. */ public void addConfiguredExportsBundleClasspath(BundleClasspathTask bcpt) { for (final Object element : bcpt.getFileSets(failOnClassPath)) { final Restrict restrict = new Restrict(); restrict.add((ResourceCollection) element); restrict.add(analyzeRestriction); exportsResourceCollections.add(restrict); } }
Example #11
Source File: Test.java From IntelliJDeodorant with MIT License | 5 votes |
public Resource[][] grabManifests(ResourceCollection[] rcs) { Resource[][] manifests = new Resource[rcs.length][]; for (int i = 0; i < rcs.length; i++) { Resource[][] resources = null; if (rcs[i] instanceof FileSet) { resources = testProduct.grabResources(new FileSet[]{(FileSet) rcs[i]}, this.project); } else { resources = grabNonFileSetResources(new ResourceCollection[]{ rcs[i] }); } for (int j = 0; j < resources[0].length; j++) { String name = resources[0][j].getName().replace('\\', '/'); if (rcs[i] instanceof ArchiveFileSet) { ArchiveFileSet afs = (ArchiveFileSet) rcs[i]; if (!"".equals(afs.getFullpath(getProject()))) { name = afs.getFullpath(getProject()); } else if (!"".equals(afs.getPrefix(getProject()))) { String prefix = afs.getPrefix(getProject()); if (!prefix.endsWith("/") && !prefix.endsWith("\\")) { prefix += "/"; } name = prefix + name; } } if (name.equalsIgnoreCase(MANIFEST_NAME)) { manifests[i] = new Resource[]{resources[0][j]}; break; } } if (manifests[i] == null) { manifests[i] = new Resource[0]; } } return manifests; }
Example #12
Source File: PropertiesSyntaxCheckTask.java From development with Apache License 2.0 | 4 votes |
/** * This task accepts any number of files to compare to. */ public void addConfigured(final ResourceCollection resources) { compareTo.add(resources); }
Example #13
Source File: AntWorkspaceResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
public void addConfigured(ResourceCollection resources) { if (!resources.isFilesystemOnly()) { throw new BuildException("Only filesystem resource collection is supported"); } allResources.add(resources); }
Example #14
Source File: WorkerProcessClassPathProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void execute(PersistentCache cache) { File jarFile = jarFile(cache); LOGGER.debug("Generating worker process classes to {}.", jarFile); URL currentClasspath = getClass().getProtectionDomain().getCodeSource().getLocation(); JarJarTask task = new JarJarTask(); task.setDestFile(jarFile); final List<Resource> classResources = new ArrayList<Resource>(); List<Class<?>> renamedClasses = Arrays.asList(GradleWorkerMain.class, BootstrapSecurityManager.class, EncodedStream.EncodedInput.class); List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add(BootstrapClassLoaderWorker.class); classes.addAll(renamedClasses); for (Class<?> aClass : classes) { final String fileName = aClass.getName().replace('.', '/') + ".class"; // Prefer the class from the same classpath as the current class. This is for the case where we're running in a test under an older // version of Gradle, whose worker classes will be visible to us. // TODO - remove this once we have upgraded to a wrapper with these changes in it Enumeration<URL> resources; try { resources = WorkerProcessClassPathProvider.class.getClassLoader().getResources(fileName); } catch (IOException e) { throw new UncheckedIOException(e); } URL resource = null; while (resources.hasMoreElements()) { URL url = resources.nextElement(); resource = url; if (url.toString().startsWith(currentClasspath.toString())) { break; } } URLResource urlResource = new URLResource(resource) { @Override public synchronized String getName() { return fileName; } }; classResources.add(urlResource); } task.add(new ResourceCollection() { public Iterator iterator() { return classResources.iterator(); } public int size() { return classResources.size(); } public boolean isFilesystemOnly() { return true; } }); for (Class<?> renamedClass : renamedClasses) { Rule rule = new Rule(); rule.setPattern(renamedClass.getName()); rule.setResult("jarjar.@0"); task.addConfiguredRule(rule); } AntUtil.execute(task); }
Example #15
Source File: WorkerProcessClassPathProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void execute(PersistentCache cache) { File jarFile = jarFile(cache); LOGGER.debug("Generating worker process classes to {}.", jarFile); URL currentClasspath = getClass().getProtectionDomain().getCodeSource().getLocation(); JarJarTask task = new JarJarTask(); task.setDestFile(jarFile); final List<Resource> classResources = new ArrayList<Resource>(); List<Class<?>> renamedClasses = Arrays.asList(GradleWorkerMain.class, BootstrapSecurityManager.class, EncodedStream.EncodedInput.class); List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add(BootstrapClassLoaderWorker.class); classes.addAll(renamedClasses); for (Class<?> aClass : classes) { final String fileName = aClass.getName().replace('.', '/') + ".class"; // Prefer the class from the same classpath as the current class. This is for the case where we're running in a test under an older // version of Gradle, whose worker classes will be visible to us. // TODO - remove this once we have upgraded to a wrapper with these changes in it Enumeration<URL> resources; try { resources = WorkerProcessClassPathProvider.class.getClassLoader().getResources(fileName); } catch (IOException e) { throw new UncheckedIOException(e); } URL resource = null; while (resources.hasMoreElements()) { URL url = resources.nextElement(); resource = url; if (url.toString().startsWith(currentClasspath.toString())) { break; } } URLResource urlResource = new URLResource(resource) { @Override public synchronized String getName() { return fileName; } }; classResources.add(urlResource); } task.add(new ResourceCollection() { public Iterator iterator() { return classResources.iterator(); } public int size() { return classResources.size(); } public boolean isFilesystemOnly() { return true; } }); for (Class<?> renamedClass : renamedClasses) { Rule rule = new Rule(); rule.setPattern(renamedClass.getName()); rule.setResult("jarjar.@0"); task.addConfiguredRule(rule); } AntUtil.execute(task); }
Example #16
Source File: AntTask.java From forbidden-apis with Apache License 2.0 | 4 votes |
private <T extends ProjectComponent & ResourceCollection> T addSignaturesResource(T res) { res.setProject(getProject()); apiSignatures.add(res); return res; }
Example #17
Source File: AntTask.java From forbidden-apis with Apache License 2.0 | 4 votes |
/** Set of class files to check */ public void add(ResourceCollection rc) { classFiles.add(rc); }
Example #18
Source File: PropertiesCompareTask.java From development with Apache License 2.0 | 4 votes |
/** * This task accepts any number of files to compare to. */ public void addConfigured(final ResourceCollection resources) { compareTo.add(resources); }
Example #19
Source File: GetMavenDependenciesTask.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * Adds a set of ivy.xml resources to check. */ public void add(ResourceCollection rc) { ivyXmlResources.add(rc); }
Example #20
Source File: LibVersionsCheckTask.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * Adds a set of ivy.xml resources to check. */ public void add(ResourceCollection rc) { ivyXmlResources.add(rc); }
Example #21
Source File: LicenseCheckTask.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * Adds a set of JAR resources to check. */ public void add(ResourceCollection rc) { jarResources.add(rc); }
Example #22
Source File: MakeJNLP.java From netbeans with Apache License 2.0 | 4 votes |
public void addConfigured(ResourceCollection rc) throws BuildException { if (files != null) throw new BuildException("modules can be specified just once"); files = rc; }
Example #23
Source File: MakeMasterJNLP.java From netbeans with Apache License 2.0 | 4 votes |
public void addConfigured(ResourceCollection rc) throws BuildException { if (files != null) throw new BuildException("modules can be specified just once"); files = rc; }
Example #24
Source File: WorkerProcessClassPathProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void execute(PersistentCache cache) { File jarFile = jarFile(cache); LOGGER.debug("Generating worker process classes to {}.", jarFile); URL currentClasspath = getClass().getProtectionDomain().getCodeSource().getLocation(); JarJarTask task = new JarJarTask(); task.setDestFile(jarFile); final List<Resource> classResources = new ArrayList<Resource>(); List<Class<?>> renamedClasses = Arrays.asList(GradleWorkerMain.class, BootstrapSecurityManager.class, EncodedStream.EncodedInput.class); List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add(BootstrapClassLoaderWorker.class); classes.addAll(renamedClasses); for (Class<?> aClass : classes) { final String fileName = aClass.getName().replace('.', '/') + ".class"; // Prefer the class from the same classpath as the current class. This is for the case where we're running in a test under an older // version of Gradle, whose worker classes will be visible to us. // TODO - remove this once we have upgraded to a wrapper with these changes in it Enumeration<URL> resources; try { resources = WorkerProcessClassPathProvider.class.getClassLoader().getResources(fileName); } catch (IOException e) { throw new UncheckedIOException(e); } URL resource = null; while (resources.hasMoreElements()) { URL url = resources.nextElement(); resource = url; if (url.toString().startsWith(currentClasspath.toString())) { break; } } URLResource urlResource = new URLResource(resource) { @Override public synchronized String getName() { return fileName; } }; classResources.add(urlResource); } task.add(new ResourceCollection() { public Iterator iterator() { return classResources.iterator(); } public int size() { return classResources.size(); } public boolean isFilesystemOnly() { return true; } }); for (Class<?> renamedClass : renamedClasses) { Rule rule = new Rule(); rule.setPattern(renamedClass.getName()); rule.setResult("jarjar.@0"); task.addConfiguredRule(rule); } AntUtil.execute(task); }
Example #25
Source File: WorkerProcessClassPathProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void execute(PersistentCache cache) { File jarFile = jarFile(cache); LOGGER.debug("Generating worker process classes to {}.", jarFile); URL currentClasspath = getClass().getProtectionDomain().getCodeSource().getLocation(); JarJarTask task = new JarJarTask(); task.setDestFile(jarFile); final List<Resource> classResources = new ArrayList<Resource>(); List<Class<?>> renamedClasses = Arrays.asList(GradleWorkerMain.class, BootstrapSecurityManager.class, EncodedStream.EncodedInput.class); List<Class<?>> classes = new ArrayList<Class<?>>(); classes.add(BootstrapClassLoaderWorker.class); classes.addAll(renamedClasses); for (Class<?> aClass : classes) { final String fileName = aClass.getName().replace('.', '/') + ".class"; // Prefer the class from the same classpath as the current class. This is for the case where we're running in a test under an older // version of Gradle, whose worker classes will be visible to us. // TODO - remove this once we have upgraded to a wrapper with these changes in it Enumeration<URL> resources; try { resources = WorkerProcessClassPathProvider.class.getClassLoader().getResources(fileName); } catch (IOException e) { throw new UncheckedIOException(e); } URL resource = null; while (resources.hasMoreElements()) { URL url = resources.nextElement(); resource = url; if (url.toString().startsWith(currentClasspath.toString())) { break; } } URLResource urlResource = new URLResource(resource) { @Override public synchronized String getName() { return fileName; } }; classResources.add(urlResource); } task.add(new ResourceCollection() { public Iterator iterator() { return classResources.iterator(); } public int size() { return classResources.size(); } public boolean isFilesystemOnly() { return true; } }); for (Class<?> renamedClass : renamedClasses) { Rule rule = new Rule(); rule.setPattern(renamedClass.getName()); rule.setResult("jarjar.@0"); task.addConfiguredRule(rule); } AntUtil.execute(task); }
Example #26
Source File: BundleArchives.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Traverse the given list of resource collections and create * <code>BundleArchive</code>-objects for all bundle jars found. * * @param task * The task that uses this class, used for logging and project * access. * @param resourceCollections * The collection of resource collections selecting the bundle * archives to load. */ public BundleArchives(final Task task, final List<ResourceCollection> resourceCollections) { this(task, resourceCollections, false); }
Example #27
Source File: MakeOSGi.java From netbeans with Apache License 2.0 | 2 votes |
/** * Adds a set of module JARs. * It is permitted for them to be JARs anywhere on disk, * but it is best if they are in a cluster structure * with ../update_tracking/*.xml present * so that associated files can be included in the bundle. */ public void add(ResourceCollection modules) { this.modules.add(modules); }
Example #28
Source File: CompileTask.java From textuml with Eclipse Public License 1.0 | 2 votes |
/** * Add a FileSet. * * @param fs * the <code>FileSet</code> to add. */ public synchronized void add(FileSet fs) { add((ResourceCollection) fs); }
Example #29
Source File: Schematron.java From ph-schematron with Apache License 2.0 | 2 votes |
/** * Add a collection of files to copy. * * @param aResCollection * a resource collection to copy. * @since Ant 1.7 */ public void add (final ResourceCollection aResCollection) { m_aResCollections.add (aResCollection); }