Refine search
/** * Styles all existing resources. * * @param stylesheet style sheet to use * @since Ant 1.7 */ private void processResources(final Resource stylesheet) { for (final Resource r : resources) { if (!r.isExists()) { continue; } File base = baseDir; String name = r.getName(); final FileProvider fp = r.as(FileProvider.class); if (fp != null) { final FileResource f = ResourceUtils.asFileResource(fp); base = f.getBaseDir(); if (base == null) { name = f.getFile().getAbsolutePath(); } } process(base, name, destDir, stylesheet); } }
/** * Get the named resource. * @param name path name of the file relative to the dir attribute. * * @return the resource with the given name. * @since Ant 1.5.2 */ @Override public synchronized Resource getResource(final String name) { return new FileResource(basedir, name); }
/** * Returns the list of files corresponding to the resource collection * * @param resources - A list of {@link ResourceCollection} * @return the list of files corresponding to the resource collection * @throws BuildException */ private List<String> getFiles(List<ResourceCollection> resources) throws BuildException { List<String> files= Lists.newArrayList(); for (ResourceCollection rc : resources) { for (Resource o : rc) { if (o instanceof FileResource) { FileResource fr = ((FileResource) o); if (fr.isDirectory()) { throw new BuildException("Directory based FileResources are not supported."); } if (! fr.isExists()) { log("'" + fr.toLongString() + "' does not exist", Project.MSG_VERBOSE); } files.add(fr.getFile().getAbsolutePath()); } else { log("Unsupported Resource type: " + o.toString(), Project.MSG_VERBOSE); } } } return files; }
/** * Return the basedir to which the name is relative. * @return the basedir as File. */ public File getBaseDir() { if (isReference()) { return getCheckedRef().getBaseDir(); } dieOnCircularReference(); return baseDir; }
/** * Get the hash code for this Resource. * @return hash code as int. */ @Override public int hashCode() { if (isReference()) { return getCheckedRef().hashCode(); } return MAGIC * (getFile() == null ? NULL_FILE : getFile().hashCode()); }
/** * Learn whether the resource is a directory. * @return boolean flag indicating if the resource is a directory. */ @Override public boolean isDirectory() { return isReference() ? getCheckedRef().isDirectory() : getNotNullFile().isDirectory(); }
/** * Adds a basedir as nested element. * @param r basedir */ public void addConfiguredBaseDir(final FileResource r) { if (isReference()) { throw noChildrenAllowed(); } baseDirs.add(r.getFile()); }
if (resource.isFilesystemOnly()) { File file = fileResource.getFile(); String filename = fileResource.getName(); File basedir = fileResource.getBaseDir(); return isSelected(basedir, filename, file); Resource tmpResource = new FileResource(tmpFile); ResourceUtils.copyResource(resource, tmpResource); boolean isSelected = isSelected(tmpFile.getParentFile(), tmpFile.getName(), resource.toLongString()); tmpFile.delete(); return isSelected; } catch (UnsupportedOperationException uoe) { log("The resource '" + resource.getName() + "' does not provide an InputStream, so it is not checked. " + "According to 'selres' attribute value it is "
List<TypedResource> mappedResources = new ArrayList<TypedResource>(); for (String fileName : inputFileNames) { FileResource mappedResource = new FileResource(baseDir, fileName); if (mappedResource.isExists()) { mappedResources.add(new TypedResource(mappedResource, inputMapper.getType(), inputMapper.getContentType())); } else { log("Skipping non-exstent mapped resource: " + mappedResource.toString(), Project.MSG_DEBUG); 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])); List<TypedResource> mappedResources = new ArrayList<TypedResource>(); for (String fileName : inputFileNames) { FileResource mappedResource = new FileResource(baseDir, fileName); mappedResources.add(new TypedResource(mappedResource, inputMapper.getType(), inputMapper.getContentType())); useOutputResources.put(outPort, new Union(new FileResource(destDir, outFileName[0]))); Union outputResources = new Union(); for (String fileName : outputFileNames) { outputResources.add(new FileResource(destDir, fileName));
/** * Get the file represented by this FileResource. * @return the File. */ @Override public File getFile() { if (isReference()) { return getCheckedRef().getFile(); } dieOnCircularReference(); synchronized (this) { if (file == null) { //try to resolve file set via basedir/name property setters: File d = getBaseDir(); String n = super.getName(); if (n != null) { setFile(FILE_UTILS.resolveFile(d, n)); } } } return file; }
/** * Compare this FileResource to another Resource. * @param another the other Resource against which to compare. * @return a negative integer, zero, or a positive integer as this FileResource * is less than, equal to, or greater than the specified Resource. */ @Override public int compareTo(Resource another) { if (isReference()) { return getCheckedRef().compareTo(another); } if (this.equals(another)) { return 0; } FileProvider otherFP = another.as(FileProvider.class); if (otherFP != null) { File f = getFile(); if (f == null) { return -1; } File of = otherFP.getFile(); if (of == null) { return 1; } int compareFiles = f.compareTo(of); return compareFiles != 0 ? compareFiles : getName().compareTo(another.getName()); } return super.compareTo(another); }
if(this.templateDir != null && this.templateDir.isDirectory()) { templatePathStr = this.templateDir.toString(); if(this.javadocDir != null && this.javadocDir.isDirectory()) { this.log("Setting javadoc directory to " + javadocDir, LogLevel.DEBUG.getLevel()); this.jxr.setJavadocLinkDir(this.javadocDir.toString()); this.jxr.setDest(this.destDir.toString()); this.stylesheet = new URLResource(defaultStylesheetUrl); FileResource destStylesheet = new FileResource(this.destDir.getFile(), "stylesheet.css"); ResourceUtils.copyResource(this.stylesheet, destStylesheet);
/** * Create a new resource that matches a relative or absolute path. * If the current instance has a compatible baseDir attribute, it is copied. * @param path relative/absolute path to a resource * @return a new resource of type FileResource * @throws BuildException if desired * @since Ant1.8 */ @Override public Resource getResource(String path) { File newfile = FILE_UTILS.resolveFile(getFile(), path); FileResource fileResource = new FileResource(newfile); if (FILE_UTILS.isLeadingPath(getBaseDir(), newfile)) { fileResource.setBaseDir(getBaseDir()); } return fileResource; }
.asFileResource(r.as(FileProvider.class)); File toDir = hasDestDir ? destDir : fr.getBaseDir(); String[] destFilenames = destMapper.mapFileName(fr.getName()); if (destFilenames == null || destFilenames.length != 1) { throw new BuildException(ERROR_BAD_MAP + fr.getFile()); signOneJar(fr.getFile(), destFile);
File file = aFile.getFile(); docMetaData.setDocumentTitle(file.getName()); docMetaData.setDocumentUri(file.toURI().toString() + qualifier); docMetaData.setDocumentId(aFile.getName() + qualifier); if (aFile.getBaseDir() != null) { docMetaData.setDocumentBaseUri(sourceLocation.toURI().toString()); docMetaData.setCollectionId(aFile.getBaseDir().getPath());
if (file != null) resources.add(new FileResource(file)); for (Resource resource : resources) { File todir = this.todir; if (todir == null && resource.isFilesystemOnly()) todir = ((FileResource) resource).getBaseDir(); if (todir == null) todir = this.getProject().getBaseDir(); String outputFileName = resource.getName(); if (outputFileName.endsWith(".html")) { outputFileName = outputFileName.substring(0, outputFileName.length() - 5);
while (resources.hasNext()) { Resource r = (Resource) resources.next(); if (!r.isExists()) { continue; String baseDir = fr.getBaseDir().getAbsolutePath(); String file = fr.getFile().getAbsolutePath(); file = file.substring(baseDir.length(), file.length()); String[] parts = file.split("/");
if (!r.isExists()) { throw new BuildException("Could not find resource %s to scp.", r.toLongString()); FileProvider fp = r.as(FileProvider.class); if (fp == null) { throw new BuildException("Resource %s is not a file.", File baseDir = fr.getBaseDir(); if (baseDir == null) { throw new BuildException("basedir for resource %s is undefined.",
private void convertResource(Resource in, final File out) throws Exception { if (in.isFilesystemOnly()) { this.html2txt.html2txt(((FileResource) in).getFile(), out); } else { IoUtil.asFile( in.getInputStream(), // inputStream true, // closeInputStream "h2t", // prefix ".html", // suffix null, // directory new ConsumerWhichThrows<File, Exception>() { // delegate @Override public void consume(File temporaryFile) throws Exception { AntTask.this.html2txt.html2txt(temporaryFile, out); } } ); } } }
/** * Compare another Object to this FileResource for equality. * @param another the other Object to compare. * @return true if another is a FileResource representing the same file. */ @Override public boolean equals(Object another) { if (this == another) { return true; } if (isReference()) { return getCheckedRef().equals(another); } if (another == null || !(another.getClass().equals(getClass()))) { return false; } FileResource otherfr = (FileResource) another; return getFile() == null ? otherfr.getFile() == null : getFile().equals(otherfr.getFile()) && getName().equals(otherfr.getName()); }