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());
}
}
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());
}
}
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));
}
}
}
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);
}
}
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);
}
Aggregations