Search in sources :

Example 46 with FileSet

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

the class EsaTaskTest method generateArchiveNoManifest.

@Test
public void generateArchiveNoManifest() {
    File srcDir = new File("../src/test/resources");
    File destfile = new File("target/esa-test1.esa");
    if (destfile.exists()) {
        destfile.delete();
    }
    assertFalse(destfile.exists());
    EsaTask esaTask = new EsaTask();
    Project testProject = new Project();
    esaTask.setProject(testProject);
    FileSet fileSet = new FileSet();
    fileSet.setDir(srcDir);
    fileSet.setIncludes("*.jar");
    esaTask.addFileset(fileSet);
    esaTask.setDestFile(destfile);
    esaTask.setSymbolicName("esatask-test");
    esaTask.setVersion("1.0.0");
    esaTask.execute();
    assertTrue(destfile.exists());
    try {
        ZipFile esaArchive = new ZipFile(destfile);
        assertNotNull(esaArchive);
        ZipEntry subsystemManifest = esaArchive.getEntry("OSGI-INF/SUBSYSTEM.MF");
        assertNull(subsystemManifest);
    } catch (IOException e) {
        fail(e.getMessage());
    }
}
Also used : Project(org.apache.tools.ant.Project) FileSet(org.apache.tools.ant.types.FileSet) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 47 with FileSet

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

the class EsaTaskTest method generateArchiveWithFileManifest.

@Test
public void generateArchiveWithFileManifest() {
    File srcDir = new File("../src/test/resources");
    File destfile = new File("target/esa-test2.esa");
    if (destfile.exists()) {
        destfile.delete();
    }
    assertFalse(destfile.exists());
    EsaTask esaTask = new EsaTask();
    Project testProject = new Project();
    esaTask.setProject(testProject);
    FileSet fileSet = new FileSet();
    fileSet.setDir(srcDir);
    fileSet.setIncludes("*.jar");
    esaTask.addFileset(fileSet);
    esaTask.setDestFile(destfile);
    esaTask.setSymbolicName("esatask-test");
    esaTask.setVersion("1.0.0");
    esaTask.setManifest(new File(srcDir, "SUBSYSTEM.MF"));
    esaTask.execute();
    assertTrue(destfile.exists());
    try {
        ZipFile esaArchive = new ZipFile(destfile);
        assertNotNull(esaArchive);
        ZipEntry subsystemManifest = esaArchive.getEntry("OSGI-INF/SUBSYSTEM.MF");
        assertNotNull(subsystemManifest);
    } catch (IOException e) {
        fail(e.getMessage());
    }
}
Also used : Project(org.apache.tools.ant.Project) FileSet(org.apache.tools.ant.types.FileSet) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Example 48 with FileSet

use of org.apache.tools.ant.types.FileSet in project ceylon-compiler by ceylon.

the class CeylonCompileAntTask method addToCompileList.

private void addToCompileList(List<File> dirs) {
    for (File srcDir : dirs) {
        if (srcDir.isDirectory()) {
            FileSet fs = (FileSet) this.files.clone();
            fs.setDir(srcDir);
            DirectoryScanner ds = fs.getDirectoryScanner(getProject());
            String[] files = ds.getIncludedFiles();
            for (String fileName : files) compileList.add(new File(srcDir, fileName));
        }
    }
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 49 with FileSet

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

the class DeployTask method execute.

@Override
public void execute() throws BuildException {
    try {
        Project project = Workspace.getProject(getProject().getBaseDir());
        // Deploy the files that need to be released
        for (FileSet fileset : filesets) {
            DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
            String[] files = ds.getIncludedFiles();
            if (files.length == 0)
                logger.debug("No files included");
            for (int i = 0; i < files.length; i++) {
                File file = new File(ds.getBasedir(), files[i]);
                try {
                    if (file.isFile() && file.getName().endsWith(".jar")) {
                        if (deployRepo != null)
                            project.deploy(deployRepo, file);
                        else
                            project.deploy(file);
                    } else
                        messages.NotAJarFile_(file);
                } catch (Exception e) {
                    messages.FailedToDeploy_Exception_(file, e);
                }
            }
        }
        report(project);
        if (project.getErrors().size() > 0)
            throw new BuildException("Deploy failed");
    } catch (Throwable t) {
        t.printStackTrace();
        throw new BuildException(t);
    }
}
Also used : Project(aQute.bnd.build.Project) FileSet(org.apache.tools.ant.types.FileSet) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) BuildException(org.apache.tools.ant.BuildException)

Example 50 with FileSet

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

the class PackageLaunchProfile method calculateContentToken.

private String calculateContentToken() throws IOException {
    List<File> files = new ArrayList<File>();
    for (FileSet fs : filesets) {
        DirectoryScanner ds = fs.getDirectoryScanner(getProject());
        for (String name : ds.getIncludedFiles()) files.add(new File(ds.getBasedir(), name));
    }
    if (files.isEmpty())
        throw new BuildException("You must designate at least one file " + "to include in the launch profile.");
    Collections.sort(files, FILENAME_SORTER);
    Checksum ck = new Adler32();
    for (File f : files) calcChecksum(f, ck);
    return Long.toString(Math.abs(ck.getValue()), Character.MAX_RADIX);
}
Also used : FileSet(org.apache.tools.ant.types.FileSet) Checksum(java.util.zip.Checksum) DirectoryScanner(org.apache.tools.ant.DirectoryScanner) ArrayList(java.util.ArrayList) BuildException(org.apache.tools.ant.BuildException) File(java.io.File) Adler32(java.util.zip.Adler32)

Aggregations

FileSet (org.apache.tools.ant.types.FileSet)52 File (java.io.File)38 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)26 IOException (java.io.IOException)20 BuildException (org.apache.tools.ant.BuildException)13 Project (org.apache.tools.ant.Project)11 ArrayList (java.util.ArrayList)10 Iterator (java.util.Iterator)4 FileInputStream (java.io.FileInputStream)3 Test (org.junit.Test)3 AbstractProject (hudson.model.AbstractProject)2 VirtualChannel (hudson.remoting.VirtualChannel)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2 StringTokenizer (java.util.StringTokenizer)2 ZipEntry (java.util.zip.ZipEntry)2 ZipFile (java.util.zip.ZipFile)2 Project (aQute.bnd.build.Project)1