Package org.apache.tools.ant.types.resources

Examples of org.apache.tools.ant.types.resources.FileResource


     * is scanned for matching entries.
     *
     * @param srcFile the (non-null) archive file name for scanning
     */
    public void setSrc(File srcFile) {
        setSrc(new FileResource(srcFile));
    }
View Full Code Here


     */
    public static FileResource asFileResource(FileProvider fileProvider) {
        if (fileProvider instanceof FileResource || fileProvider == null) {
            return (FileResource) fileProvider;
        }
        FileResource result = new FileResource(fileProvider.getFile());
        result.setProject(Project.getProject(fileProvider));
        return result;
    }
View Full Code Here

                        final String name = params[i].getName();
                        final String value = params[i].getValue();
                        hash.put(name, value);
                    } else if ("propertiesfile".equals(type)) {
                        makeTokensFromProperties(
                            new FileResource(new File(params[i].getValue())));
                    }
                }
            }
        }
    }
View Full Code Here

     */
    protected void touch() throws BuildException {
        long defaultTimestamp = getTimestamp();

        if (file != null) {
            touch(new FileResource(file.getParentFile(), file.getName()),
                  defaultTimestamp);
        }
        if (resources == null) {
            return;
        }
        // deal with the resource collections
        for (Resource r : resources) {
            Touchable t = r.as(Touchable.class);
            if (t == null) {
                throw new BuildException("Can't touch " + r);
            }
            touch(r, defaultTimestamp);
        }

        // deal with filesets in a special way since the task
        // originally also used the directories and Union won't return
        // them.
        final int size = filesets.size();
        for (int i = 0; i < size; i++) {
            FileSet fs = (FileSet) filesets.elementAt(i);
            DirectoryScanner ds = fs.getDirectoryScanner(getProject());
            File fromDir = fs.getDir(getProject());

            String[] srcDirs = ds.getIncludedDirectories();

            for (int j = 0; j < srcDirs.length; j++) {
                touch(new FileResource(fromDir, srcDirs[j]), defaultTimestamp);
            }
        }
    }
View Full Code Here

     * @param name the name of the file to resolve.
     * @return the file resource.
     * @since Ant 1.7
     */
    public Resource getResource(String name) {
        return new FileResource(getBaseDir(), name);
    }
View Full Code Here

    @Test
    public void testFind() throws Exception {
        ProjectHelperRepository repo = ProjectHelperRepository.getInstance();
        repo.registerProjectHelper(SomeHelper.class);

        Resource r = new FileResource(new File("test.xml"));
        ProjectHelper helper = repo.getProjectHelperForBuildFile(r);
        assertTrue(helper instanceof ProjectHelper2);
        helper = repo.getProjectHelperForAntlib(r);
        assertTrue(helper instanceof ProjectHelper2);

        r = new FileResource(new File("test.myext"));
        helper = repo.getProjectHelperForBuildFile(r);
        assertTrue(helper instanceof SomeHelper);
        helper = repo.getProjectHelperForAntlib(r);
        assertTrue(helper instanceof SomeHelper);
View Full Code Here

     * @param propertyFile the file to load the properties from.
     * @return loaded <code>Properties</code> object.
     * @throws BuildException if the file could not be found or read.
     */
    public Properties getProperties(File propertyFile) throws BuildException {
        return getProperties(new FileResource(getProject(), propertyFile));
    }
View Full Code Here

     * Each property will be treated as a replacefilter where token is the name
     * of the property and value is the value of the property.
     * @param replaceFilterFile <code>File</code> to load.
     */
    public void setReplaceFilterFile(File replaceFilterFile) {
        setReplaceFilterResource(new FileResource(getProject(),
                                                  replaceFilterFile));
    }
View Full Code Here

     * <code>&lt;replacefilter&gt;</code> elements are drawn; required only if
     * the <i>property</i> attribute of <code>&lt;replacefilter&gt;</code> is used.
     * @param propertyFile <code>File</code> to load.
     */
    public void setPropertyFile(File propertyFile) {
        setPropertyResource(new FileResource(propertyFile));
    }
View Full Code Here

     *
     * @return the resource with the given name.
     * @since Ant 1.5.2
     */
    public synchronized Resource getResource(String name) {
        return new FileResource(basedir, name);
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.types.resources.FileResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.