use of org.apache.tools.ant.types.PatternSet.NameEntry in project gate-core by GateNLP.
the class PackageGappTask method copyDirectories.
/**
* Copy directories as specified by the given map.
*
* @param copyMap map specifying the directories to copy and the
* target locations to which they should be copied.
* @param minimalPlugin if true, treat the directory as a GATE plugin
* and copy just the minimal files needed for the plugin to
* work (creole.xml and any referenced jars).
*/
private void copyDirectories(Map<URL, URL> copyMap, boolean minimalPlugin) {
for (Map.Entry<URL, URL> copyEntry : copyMap.entrySet()) {
File source = Files.fileFromURL(copyEntry.getKey());
if (!source.exists()) {
return;
}
File dest = Files.fileFromURL(copyEntry.getValue());
// set up a copy task to do the copying
Copy copyTask = new Copy();
copyTask.setProject(getProject());
copyTask.setLocation(getLocation());
copyTask.setTaskName(getTaskName());
copyTask.setTodir(dest);
// ensure the target directory exists
dest.mkdirs();
FileSet fileSet = new FileSet();
copyTask.addFileset(fileSet);
fileSet.setDir(source);
if (minimalPlugin) {
// just copy creole.xml and JARs
NameEntry include = fileSet.createInclude();
include.setName("creole.xml");
URL creoleXml;
try {
creoleXml = new URL(copyEntry.getKey().toExternalForm() + "/creole.xml");
} catch (MalformedURLException e) {
throw new BuildException("Error creating URL for creole.xml in plugin " + copyEntry.getKey());
}
for (String jarString : getJars(creoleXml)) {
NameEntry jarInclude = fileSet.createInclude();
jarInclude.setName(jarString);
}
}
// do the copying
copyTask.init();
copyTask.perform();
}
}
use of org.apache.tools.ant.types.PatternSet.NameEntry in project ant-ivy by apache.
the class IvyCacheFileset method doExecute.
public void doExecute() throws BuildException {
prepareAndCheck();
if (setid == null) {
throw new BuildException("setid is required in ivy cachefileset");
}
try {
final List<ArtifactDownloadReport> artifactDownloadReports = getArtifactReports();
if (artifactDownloadReports.isEmpty()) {
// generate an empty fileset
final FileSet emptyFileSet = new EmptyFileSet();
emptyFileSet.setProject(getProject());
getProject().addReference(setid, emptyFileSet);
return;
}
// find a common base dir of the resolved artifacts
final File baseDir = this.requireCommonBaseDir(artifactDownloadReports);
final FileSet fileset = new FileSet();
fileset.setDir(baseDir);
fileset.setProject(getProject());
// enroll each of the artifact files into the fileset
for (final ArtifactDownloadReport artifactDownloadReport : artifactDownloadReports) {
if (artifactDownloadReport.getLocalFile() == null) {
continue;
}
final NameEntry ne = fileset.createInclude();
ne.setName(getPath(baseDir, artifactDownloadReport.getLocalFile()));
}
getProject().addReference(setid, fileset);
} catch (Exception ex) {
throw new BuildException("impossible to build ivy cache fileset: " + ex, ex);
}
}
Aggregations