/** * Constructor for Ant attribute introspection. * @param p the Project against which to resolve <code>s</code>. * @param s the absolute or Project-relative filename as a String. * @see org.apache.tools.ant.IntrospectionHelper */ public FileResource(Project p, String s) { this(p, p.resolveFile(s)); }
@Override public void set(final Project p, final Object parent, final String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, p.resolveFile(value)); } };
@Override public void set(final Project p, final Object parent, final String value) throws InvocationTargetException, IllegalAccessException { m.invoke(parent, p.resolveFile(value).toPath()); } };
/** * Returns the resolved file * @param extension the extension * @param project the project * @return the file resolved * @throws BuildException if no location is set */ @Override public File resolve(final Extension extension, final Project project) throws BuildException { if (null == location) { throw new BuildException("No location specified for resolver"); } return project.resolveFile(location); } /**
/** * Adds an element to the classpath to be searched. * * @param pathElement The path element to add. Must not be * <code>null</code>. * * @exception BuildException if the given path element cannot be resolved * against the project. */ public void addPathElement(String pathElement) throws BuildException { File pathComponent = project != null ? project.resolveFile(pathElement) : new File( pathElement); try { addPathFile(pathComponent); } catch (IOException e) { throw new BuildException(e); } }
/** * Set the directory. * @param d a <code>String</code> value */ public void setDir(String d) { this.dir = getProject().resolveFile(d); }
@Override void set(final Project p, final Object parent, final String value) throws InvocationTargetException, IllegalAccessException, BuildException { m.invoke(parent, new FileResource(p, p.resolveFile(value))); } };
/** * Adds an element to the classpath to be searched. * * @param pathElement The path element to add. Must not be * <code>null</code>. * * @exception BuildException if the given path element cannot be resolved * against the project. */ public void addPathElement(final String pathElement) throws BuildException { final File pathComponent = project != null ? project.resolveFile(pathElement) : new File( pathElement); try { addPathFile(pathComponent); } catch (final IOException e) { throw new BuildException(e); } }
/** * Return a <code>File[]</code> from the specified set of filenames. * @param name <code>String[]</code> * @return <code>File[]</code>. */ protected File[] toFileArray(String[] name) { if (name == null) { return null; } //remove any null elements ArrayList<File> list = new ArrayList<>(name.length); for (String n : name) { if (n != null) { list.add(getProject().resolveFile(n)); } } return list.toArray(new File[list.size()]); }
/** * Adds basedirs as a comma separated list. * @param dirs directories as CSV */ public void setBaseDirs(final String dirs) { if (isReference()) { throw tooManyAttributes(); } if (dirs != null && !dirs.isEmpty()) { for (final String d : dirs.split(",")) { baseDirs.add(getProject().resolveFile(d)); } } }
/** * Set the list of files to be attached. * * @param filenames Comma-separated list of files. */ public void setFiles(String filenames) { StringTokenizer t = new StringTokenizer(filenames, ", "); while (t.hasMoreTokens()) { createAttachments() .add(new FileResource(getProject().resolveFile(t.nextToken()))); } }
/** * Set the list of source files to process. * * @param src a comma separated list of source files. */ public void setSourcefiles(final String src) { final StringTokenizer tok = new StringTokenizer(src, ","); while (tok.hasMoreTokens()) { final String f = tok.nextToken(); final SourceFile sf = new SourceFile(); sf.setFile(getProject().resolveFile(f.trim())); addSource(sf); } }
private void collectFileListFromSourcePath() { for (String filename : src.list()) { final File srcDir = getProject().resolveFile(filename); if (!srcDir.exists()) { throw new BuildException("srcdir \"" + srcDir.getPath() + "\" does not exist!", getLocation()); } final DirectoryScanner ds = this.getDirectoryScanner(srcDir); scanDir(srcDir, destDir != null ? destDir : srcDir, ds.getIncludedFiles()); } }
/** * Link to docs at "url" using package list at "url2" * - separate the URLs by using a space character. * * @param src the offline link specification (url and package list) */ public void setLinkoffline(final String src) { final LinkArgument le = createLink(); le.setOffline(true); final String linkOfflineError = "The linkoffline attribute must include" + " a URL and a package-list file location separated by a" + " space"; if (src.trim().isEmpty()) { throw new BuildException(linkOfflineError); } final StringTokenizer tok = new StringTokenizer(src, " ", false); le.setHref(tok.nextToken()); if (!tok.hasMoreTokens()) { throw new BuildException(linkOfflineError); } le.setPackagelistLoc(getProject().resolveFile(tok.nextToken())); }
/** * @deprecated since 1.5.x. * setSrc(String) is deprecated and is replaced with * setSrc(File) to make Ant's Introspection * mechanism do the work and also to encapsulate operations on * the type in its own class. * @ant.attribute ignore="true" * @param src a <code>String</code> value */ @Deprecated public void setSrc(String src) { log("DEPRECATED - The setSrc(String) method has been deprecated." + " Use setSrc(File) instead."); setSrc(getProject().resolveFile(src)); }
/** * @deprecated since 1.5.x. * setDest(String) is deprecated and is replaced with * setDest(File) to make Ant's Introspection * mechanism do the work and also to encapsulate operations on * the type in its own class. * @ant.attribute ignore="true" * @param dest a <code>String</code> value */ @Deprecated public void setDest(String dest) { log("DEPRECATED - The setDest(String) method has been deprecated." + " Use setDest(File) instead."); setDest(getProject().resolveFile(dest)); }
/** * Creates the temporary file. * * @exception BuildException if something goes wrong with the build */ @Override public void execute() throws BuildException { if (property == null || property.isEmpty()) { throw new BuildException("no property specified"); } if (destDir == null) { destDir = getProject().resolveFile("."); } File tfile = FILE_UTILS.createTempFile(prefix, suffix, destDir, deleteOnExit, createFile); getProject().setNewProperty(property, tfile.toString()); } }
/** * Called to validate that the tool parameters have been configured. * @throws BuildException if there is an error. */ @Override public void validateConfigured() throws BuildException { super.validateConfigured(); if (ejbdeploy) { String home = getTask().getProject().getProperty("websphere.home"); if (home == null) { throw new BuildException( "The 'websphere.home' property must be set when 'ejbdeploy=true'"); } websphereHome = getTask().getProject().resolveFile(home); } }
/** * Executes the task. * * @throws BuildException if an error occurs */ public void execute() throws BuildException { checkParameters(); resetFileLists(); loadRegisteredScriptExtensions(); if (javac != null) jointCompilation = true; // scan source directories and dest directory to build up // compile lists String[] list = src.list(); for (String filename : list) { File file = getProject().resolveFile(filename); if (!file.exists()) { throw new BuildException("srcdir \"" + file.getPath() + "\" does not exist!", getLocation()); } DirectoryScanner ds = this.getDirectoryScanner(file); String[] files = ds.getIncludedFiles(); scanDir(file, destDir != null ? destDir : file, files); } compile(); if (updatedProperty != null && taskSuccess && compileList.length != 0) { getProject().setNewProperty(updatedProperty, "true"); } }
private void touch(Resource r, long defaultTimestamp) { if (fileNameMapper == null) { FileProvider fp = r.as(FileProvider.class); if (fp != null) { // use this to create file and deal with non-writable files touch(fp.getFile(), defaultTimestamp); } else { r.as(Touchable.class).touch(defaultTimestamp); } } else { String[] mapped = fileNameMapper.mapFileName(r.getName()); if (mapped != null && mapped.length > 0) { long modTime = defaultTimestamp; if (millis < 0 && r.isExists()) { modTime = r.getLastModified(); } for (String fileName : mapped) { touch(getProject().resolveFile(fileName), modTime); } } } }