use of org.metaborg.spoofax.meta.core.pluto.stamp.DirectoryModifiedStamper in project spoofax by metaborg.
the class CopyPattern method build.
@Override
public None build(Input input) throws IOException {
requireBuild(input.origin);
require(input.srcDir, new DirectoryModifiedStamper());
final Collection<File> files = FileUtils.listFiles(input.srcDir, new RegexFileFilter(input.pattern), FalseFileFilter.INSTANCE);
for (File file : files) {
require(file);
final File dstFile = new File(input.dstDir, file.getName());
FileUtils.copyFile(file, dstFile);
provide(dstFile);
}
return None.val;
}
use of org.metaborg.spoofax.meta.core.pluto.stamp.DirectoryModifiedStamper in project spoofax by metaborg.
the class ArchiveBuilder method build.
@Override
protected OutputTransient<File> build(Input input) throws Throwable {
requireBuild(input.origin);
final ZipArchiver zipArchiver = new ZipArchiver();
final FileObject root = paths.root();
require(toFile(paths.iconsDir()), new DirectoryModifiedStamper());
zipArchiver.addFilesTo(root.getName(), paths.iconsDir(), FileSelectorUtils.all());
require(toFile(paths.targetMetaborgDir()), new DirectoryModifiedStamper());
zipArchiver.addFilesTo(root.getName(), paths.targetMetaborgDir(), FileSelectorUtils.not(FileSelectorUtils.ant("*.dep")));
zipArchiver.addFileTo(root.getName(), paths.mbComponentConfigFile());
for (IExportConfig export : input.exports) {
export.accept(new IExportVisitor() {
@Override
public void visit(ResourceExport export) {
addFiles(export, export.directory, export.includes, export.excludes);
}
@Override
public void visit(LangDirExport export) {
addFiles(export, export.directory, export.includes, export.excludes);
}
@Override
public void visit(LangFileExport export) {
try {
final FileObject file = paths.root().resolveFile(export.file);
zipArchiver.addFile(export.file, file);
} catch (IOException e) {
report("Unable to package export: " + export);
}
}
private void addFiles(IExportConfig export, String directory, Iterable<String> includes, Iterable<String> excludes) {
try {
final FileObject dir = paths.root().resolveFile(directory);
final FileSelector includesSelector;
if (Iterables.isEmpty(includes)) {
includesSelector = FileSelectorUtils.all();
} else {
includesSelector = FileSelectorUtils.ant(includes);
}
final FileSelector excludesSelector;
if (Iterables.isEmpty(excludes)) {
excludesSelector = FileSelectorUtils.none();
} else {
excludesSelector = FileSelectorUtils.ant(excludes);
}
zipArchiver.addFilesTo(paths.root().getName(), dir, FileSelectorUtils.includeExclude(includesSelector, excludesSelector));
} catch (IOException e) {
report("Unable to package export: " + export);
}
}
});
}
final FileObject spxArchiveFile = paths.spxArchiveFile(input.languageIdentifier.toFileString());
zipArchiver.build(spxArchiveFile, this);
return OutputTransient.of(toFile(spxArchiveFile));
}
use of org.metaborg.spoofax.meta.core.pluto.stamp.DirectoryModifiedStamper in project spoofax by metaborg.
the class PackageBuilder method jar.
public Origin jar(File jarFile, File baseDir, @Nullable Origin origin, @Nullable File depPath, Iterable<File> paths) throws IOException {
final Collection<JarBuilder.Entry> fileEntries = Lists.newLinkedList();
for (File path : paths) {
require(path, new DirectoryModifiedStamper());
final Collection<File> files = findFiles(path);
for (final File classFile : files) {
final String relative = relativize(classFile, baseDir);
// Ignore files that are not relative to the base directory.
if (relative != null) {
// Convert \ to / on Windows; ZIP/JAR files must use / for paths.
// HACK: this should be fixed in the JarBuilder.
final String forwardslashRelative = relative.replace('\\', '/');
fileEntries.add(new JarBuilder.Entry(forwardslashRelative, classFile));
}
}
}
final BuildRequest<?, ?, ?, ?> buildRequest = new BuildRequest<>(JarBuilder.factory, new JarBuilder.Input(jarFile, fileEntries, origin, depPath));
final Origin jarOrigin = Origin.from(buildRequest);
requireBuild(jarOrigin);
return jarOrigin;
}
Aggregations