Search in sources :

Example 36 with FileResource

use of org.apache.tools.ant.types.resources.FileResource in project ant by apache.

the class XSLTProcess method configureLiaison.

/**
 * Loads the stylesheet and set xsl:param parameters.
 *
 * @param stylesheet the file from which to load the stylesheet.
 * @exception BuildException if the stylesheet cannot be loaded.
 * @deprecated since Ant 1.7
 */
@Deprecated
protected void configureLiaison(final File stylesheet) throws BuildException {
    final FileResource fr = new FileResource();
    fr.setProject(getProject());
    fr.setFile(stylesheet);
    configureLiaison(fr);
}
Also used : FileResource(org.apache.tools.ant.types.resources.FileResource)

Example 37 with FileResource

use of org.apache.tools.ant.types.resources.FileResource in project ant by apache.

the class XmlProperty method getResource.

/**
 * @return the resource.
 */
protected Resource getResource() {
    // delegate this way around to support subclasses that
    // overwrite getFile
    File f = getFile();
    FileProvider fp = src.as(FileProvider.class);
    return f == null ? src : fp != null && fp.getFile().equals(f) ? src : new FileResource(f);
}
Also used : FileProvider(org.apache.tools.ant.types.resources.FileProvider) FileResource(org.apache.tools.ant.types.resources.FileResource) File(java.io.File)

Example 38 with FileResource

use of org.apache.tools.ant.types.resources.FileResource in project ant by apache.

the class TraXLiaison method setStylesheet.

/**
 * Set the stylesheet file.
 * @param stylesheet a <code>File</code> value
 * @throws Exception on error
 */
public void setStylesheet(final File stylesheet) throws Exception {
    final FileResource fr = new FileResource();
    fr.setProject(project);
    fr.setFile(stylesheet);
    setStylesheet(fr);
}
Also used : FileResource(org.apache.tools.ant.types.resources.FileResource)

Example 39 with FileResource

use of org.apache.tools.ant.types.resources.FileResource in project jacoco by jacoco.

the class ReportTask method createBundle.

private IBundleCoverage createBundle(final GroupElement group) throws IOException {
    final CoverageBuilder builder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(executionDataStore, builder);
    for (final Iterator<?> i = group.classfiles.iterator(); i.hasNext(); ) {
        final Resource resource = (Resource) i.next();
        if (resource.isDirectory() && resource instanceof FileResource) {
            analyzer.analyzeAll(((FileResource) resource).getFile());
        } else {
            final InputStream in = resource.getInputStream();
            analyzer.analyzeAll(in, resource.getName());
            in.close();
        }
    }
    final IBundleCoverage bundle = builder.getBundle(group.name);
    logBundleInfo(bundle, builder.getNoMatchClasses());
    return bundle;
}
Also used : InputStream(java.io.InputStream) FileResource(org.apache.tools.ant.types.resources.FileResource) Resource(org.apache.tools.ant.types.Resource) FileResource(org.apache.tools.ant.types.resources.FileResource) IBundleCoverage(org.jacoco.core.analysis.IBundleCoverage) CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) Analyzer(org.jacoco.core.analysis.Analyzer)

Example 40 with FileResource

use of org.apache.tools.ant.types.resources.FileResource in project jacoco by jacoco.

the class AntResourcesLocatorTest method testFilePrecedence.

@Test
public void testFilePrecedence() throws IOException {
    createFile("src/org/jacoco/example/Test.java", "DDD");
    locator.add(new FileResource(folder.getRoot(), "src"));
    locator.add(createFile("org/jacoco/example/Test.java", "FFF"));
    final Reader source = locator.getSourceFile("org/jacoco/example", "Test.java");
    assertContent("FFF", source);
}
Also used : FileResource(org.apache.tools.ant.types.resources.FileResource) Reader(java.io.Reader) BufferedReader(java.io.BufferedReader) Test(org.junit.Test)

Aggregations

FileResource (org.apache.tools.ant.types.resources.FileResource)48 File (java.io.File)29 BuildException (org.apache.tools.ant.BuildException)25 Resource (org.apache.tools.ant.types.Resource)23 IOException (java.io.IOException)15 FileProvider (org.apache.tools.ant.types.resources.FileProvider)10 Test (org.junit.Test)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 Liquibase (liquibase.Liquibase)6 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)6 FileSet (org.apache.tools.ant.types.FileSet)6 Contexts (liquibase.Contexts)5 LiquibaseException (liquibase.exception.LiquibaseException)5 BufferedReader (java.io.BufferedReader)4 Reader (java.io.Reader)4 Writer (java.io.Writer)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4