/** * Tells which source files should be reprocessed based on the * last modification date of target files. * @param logTo where to send (more or less) interesting output. * @param source array of resources bearing relative path and last * modification date. * @param mapper filename mapper indicating how to find the target * files. * @param targets object able to map as a resource a relative path * at <b>destination</b>. * @param granularity The number of milliseconds leeway to give * before deciding a target is out of date. * @return array containing the source files which need to be * copied or processed, because the targets are out of date or do * not exist. * @since Ant 1.6.2 */ public static Resource[] selectOutOfDateSources(final ProjectComponent logTo, final Resource[] source, final FileNameMapper mapper, final ResourceFactory targets, final long granularity) { final Union u = new Union(); u.addAll(Arrays.asList(source)); final ResourceCollection rc = selectOutOfDateSources(logTo, u, mapper, targets, granularity); return rc.size() == 0 ? new Resource[0] : ((Union) rc).listResources(); }
/** * Implement clone. The nested resource collections are cloned as * well. * * @return a cloned instance. */ @Override public Object clone() { try { final Archives a = (Archives) super.clone(); a.zips = (Union) zips.clone(); a.tars = (Union) tars.clone(); return a; } catch (final CloneNotSupportedException e) { throw new BuildException(e); } }
/** * Convenience method. * @return Resource[] */ public Resource[] listResources() { if (isReference()) { return getCheckedRef(Union.class, getDataTypeName()).listResources(); } return streamResources().toArray(Resource[]::new); }
/** * Returns all Resources in String format. Provided for * convenience in implementing Path. * @return String array of Resources. */ public String[] list() { if (isReference()) { return getCheckedRef(Union.class, getDataTypeName()).list(); } return streamResources().map(Object::toString).toArray(String[]::new); }
if (((inResource != null) || (resources.size() != 0) || !inputResources.isEmpty() || !inputMappers.isEmpty()) && !steps.isEmpty()) { if (inResource != null && resources.size() != 0) { handleError("'in' and explicit filesets cannot be used together."); return; if (!useImplicitFileset && resources.size() == 0) { Map<String, List<TypedResource>> useInputResources = new HashMap<String, List<TypedResource>>(); Union outputResources = new Union(); for (String fileName : outputFileNames) { outputResources.add(new FileResource(destDir, fileName)); resources.add(new FileResource(baseDir, includedFiles[i])); includedFiles = new File(baseDir, includedDirs[j]).list(); for (int i = 0; i < includedFiles.length; ++i) { resources.add(new FileResource(baseDir, includedDirs[j] + File.separator + includedFiles[i])); if (resources.size() == 0) { if (failOnNoResources) { handleError("no resources specified"); for (Resource resource : resources.listResources()) { log("Resource: " + resource.getName(), Project.MSG_DEBUG); Map<String, List<TypedResource>> useInputResources = new HashMap<String, List<TypedResource>>(); useOutputResources.put(outPort, new Union(new FileResource(destDir, outFileName[0])));
/** * Add any source resource. * * @param resource source of script * @since Ant 1.7.1 */ public void add(ResourceCollection resource) { resources.add(resource); } }
return Resources.NONE; source = Union.getInstance(source); final Union result = new Union(); for (final Resource sr : source) { String srName = sr.getName(); continue; final Union targetColl = new Union(); for (String targetname : targetnames) { if (targetname == null) { targetname = "(no name)"; targetColl.add(targets.getResource( targetname.replace(File.separatorChar, '/'))); r.add(targetColl); if (r.size() > 0) { result.add(sr); final Resource t = r.iterator().next(); logTo.log(sr.getName() + " added as " + t.getName() + " omitted as " + targetColl.toString() + (targetColl.size() == 1 ? " is" : " are ") + " up to date.", Project.MSG_VERBOSE);
/** * Add a nested <code>ResourceCollection</code>. * @param c the ResourceCollection to add. * @since Ant 1.7 */ public void add(ResourceCollection c) { checkChildrenAllowed(); if (c == null) { return; } if (union == null) { union = new Union(); union.setProject(getProject()); union.setCache(cache); } union.add(c); setChecked(false); }
if (resources.size() != 0) { handleError("Both mapper and fileset on input port: " + port); return; if ((resources.size() != 0) && !inputResources.containsKey(port)) { inputResources.put(port, new ArrayList<TypedResource>()); for (Resource resource : resources.listResources()) { inputResources.get(port).add(new TypedResource(resource, input.getType(), input.getContentType()));
@Override public void execute() { if (file == null && resources.isEmpty()) { throw new BuildException( "import requires file attribute or at least one nested resource"); Union resourcesToImport = new Union(getProject(), resources); Resource fromFileAttribute = getFileAttributeResource(); if (fromFileAttribute != null) { resources.add(fromFileAttribute);
/** * Static convenience method to union an arbitrary set of Resources. * @param rc a ResourceCollection. * @return a Union. */ public static Union getInstance(ResourceCollection rc) { return rc instanceof Union ? (Union) rc : new Union(rc); }
for (Resource resource : outputResources.get(port).listResources()) { outputsLastModified.add(resource.getLastModified()); for (String port : outputResources.keySet()) { Union resources = outputResources.get(port); for (Iterator<Resource> iterator = resources.iterator(); iterator.hasNext(); ) { Resource resource = iterator.next(); userArgs.addOutput(port, resource.getOutputStream()); for (Resource resource : input.getResources().listResources()) { userArgs.addInput(input.getPort(), resource.getInputStream(), resource.toString(), input.getType(), input.getContentType());
private synchronized Union getPath() { if (path == null) { path = new Union(); path.setProject(getProject()); } return path; }
private ResourceCollection read(Resource r) { try (BufferedReader reader = new BufferedReader(open(r))) { Union streamResources = new Union(); streamResources.setCache(true); reader.lines().map(this::parse).forEach(streamResources::add); return streamResources; } catch (final IOException ioe) { throw new BuildException("Unable to read resource " + r.getName() + ": " + ioe, ioe, getLocation()); } }
/** * Fulfill the ResourceCollection contract. * @return an Iterator of Resources. */ @Override public Iterator<Resource> iterator() { if (isReference()) { return ((MultiRootFileSet) getRef(getProject())).iterator(); } return merge().iterator(); }
if (sourceFileSets.isEmpty() && sourceResources.isEmpty() && sourceFile == null) { throw new BuildException( if ((!sourceFileSets.isEmpty() || !sourceResources.isEmpty()) && sourceFile != null) { throw new BuildException( Resource[] r = sourceResources.listResources(); if (r.length > 0) { upToDate = ResourceUtils.selectOutOfDateSources(
/** * Fulfill the ResourceCollection contract. * @return number of elements as int. */ @Override public int size() { if (isReference()) { return ((MultiRootFileSet) getRef(getProject())).size(); } return merge().size(); }