Search in sources :

Example 6 with FileSet

use of org.apache.tools.ant.types.FileSet in project hibernate-orm by hibernate.

the class SchemaUpdateTask method collectFiles.

private String[] collectFiles() {
    List<String> files = new LinkedList<String>();
    for (FileSet fileSet : fileSets) {
        final DirectoryScanner ds = fileSet.getDirectoryScanner(getProject());
        final String[] dsFiles = ds.getIncludedFiles();
        for (String dsFileName : dsFiles) {
            File f = new File(dsFileName);
            if (!f.isFile()) {
                f = new File(ds.getBasedir(), dsFileName);
            }
            files.add(f.getAbsolutePath());
        }
    }
    return ArrayHelper.toStringArray(files);
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) File(java.io.File) LinkedList(java.util.LinkedList)

Example 7 with FileSet

use of org.apache.tools.ant.types.FileSet in project hibernate-orm by hibernate.

the class SchemaValidatorTask method collectFiles.

private String[] collectFiles() {
    List<String> files = new ArrayList<String>();
    for (Object fileSet : fileSets) {
        final FileSet fs = (FileSet) fileSet;
        final DirectoryScanner ds = fs.getDirectoryScanner(getProject());
        for (String dsFile : ds.getIncludedFiles()) {
            File f = new File(dsFile);
            if (!f.isFile()) {
                f = new File(ds.getBasedir(), dsFile);
            }
            files.add(f.getAbsolutePath());
        }
    }
    return ArrayHelper.toStringArray(files);
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) ArrayList(java.util.ArrayList) File(java.io.File)

Example 8 with FileSet

use of org.apache.tools.ant.types.FileSet in project processing by processing.

the class AppBundlerTask method copyLibraryPathEntries.

private void copyLibraryPathEntries(File macOSDirectory) throws IOException {
    for (FileSet fileSet : libraryPath) {
        File libraryPathDirectory = fileSet.getDir();
        DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
        String[] includedFiles = directoryScanner.getIncludedFiles();
        for (String includedFile : includedFiles) {
            File source = new File(libraryPathDirectory, includedFile);
            File destination = new File(macOSDirectory, new File(includedFile).getName());
            copy(source, destination);
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) File(java.io.File)

Example 9 with FileSet

use of org.apache.tools.ant.types.FileSet in project bnd by bndtools.

the class RepoIndexTask method execute.

@Override
public void execute() throws BuildException {
    printCopyright(System.err);
    if (repositoryFile == null)
        throw new BuildException("Output file not specified");
    try {
        // Configure PojoSR
        Map<String, Object> pojoSrConfig = new HashMap<String, Object>();
        pojoSrConfig.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, new ClasspathScanner());
        // Start PojoSR 'framework'
        Framework framework = new PojoServiceRegistryFactoryImpl().newFramework(pojoSrConfig);
        framework.init();
        framework.start();
        if (knownBundles) {
            registerKnownBundles(framework.getBundleContext());
        }
        // Look for indexer and run index generation
        ServiceTracker<ResourceIndexer, ResourceIndexer> tracker = new ServiceTracker<ResourceIndexer, ResourceIndexer>(framework.getBundleContext(), ResourceIndexer.class, null);
        tracker.open();
        ResourceIndexer index = tracker.waitForService(1000);
        if (index == null)
            throw new IllegalStateException("Timed out waiting for ResourceIndexer service.");
        // Flatten the file sets into a single list
        Set<File> fileList = new LinkedHashSet<File>();
        for (FileSet fileSet : fileSets) {
            DirectoryScanner ds = fileSet.getDirectoryScanner(getProject());
            File basedir = ds.getBasedir();
            String[] files = ds.getIncludedFiles();
            for (int i = 0; i < files.length; i++) fileList.add(new File(basedir, files[i]));
        }
        // Run
        try (OutputStream fos = Files.newOutputStream(repositoryFile.toPath())) {
            index.index(fileList, fos, config);
        }
    } catch (Exception e) {
        throw new BuildException(e);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) FileSet(org.apache.tools.ant.types.FileSet) HashMap(java.util.HashMap) ServiceTracker(org.osgi.util.tracker.ServiceTracker) OutputStream(java.io.OutputStream) ResourceIndexer(org.osgi.service.indexer.ResourceIndexer) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) ClasspathScanner(de.kalpatec.pojosr.framework.launch.ClasspathScanner) PojoServiceRegistryFactoryImpl(de.kalpatec.pojosr.framework.PojoServiceRegistryFactoryImpl) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) Framework(org.osgi.framework.launch.Framework)

Example 10 with FileSet

use of org.apache.tools.ant.types.FileSet in project processdash by dtuma.

the class PackageLaunchProfile method createResourceJar.

private void createResourceJar(File tmpFile) throws IOException, ManifestException {
    String contentToken = calculateContentToken();
    Manifest mf = buildManifest(contentToken);
    Jar jar = new Jar();
    jar.bindToOwner(this);
    jar.addConfiguredManifest(mf);
    for (FileSet fs : filesets) jar.addFileset(fs);
    tmpFile.delete();
    jar.setDestFile(tmpFile);
    jar.execute();
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) Jar(org.apache.tools.ant.taskdefs.Jar) Manifest(org.apache.tools.ant.taskdefs.Manifest)

Aggregations

FileSet (org.apache.tools.ant.types.FileSet)165 File (java.io.File)124 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)83 BuildException (org.apache.tools.ant.BuildException)49 Test (org.junit.Test)41 IOException (java.io.IOException)36 ArrayList (java.util.ArrayList)29 Project (org.apache.tools.ant.Project)22 Resource (org.apache.tools.ant.types.Resource)12 FileResource (org.apache.tools.ant.types.resources.FileResource)10 URL (java.net.URL)6 Hashtable (java.util.Hashtable)6 ArchiveFileSet (org.apache.tools.ant.types.ArchiveFileSet)6 Path (org.apache.tools.ant.types.Path)6 ResourceCollection (org.apache.tools.ant.types.ResourceCollection)6 PrintStream (java.io.PrintStream)5 HashMap (java.util.HashMap)5 Iterator (java.util.Iterator)5 List (java.util.List)5 ZipFileSet (org.apache.tools.ant.types.ZipFileSet)5