
com.github.connollyst.jolt.JoltCrawler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jolt-maven-plugin Show documentation
Show all versions of jolt-maven-plugin Show documentation
A Maven plugin to apply JSON to JSON transformations using the Jolt spec. Useful as
part of a Maven build to transform JSON generated by one plugin to JSON consumable by
another.
package com.github.connollyst.jolt;
import org.apache.maven.plugin.logging.Log;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
/**
* @author Sean Connolly
*/
class JoltCrawler extends SimpleFileVisitor {
private final Log log;
private final Path inputDirectory;
private final Path outputDirectory;
private final JoltTransformer transformer;
JoltCrawler(Log log, Path inputDirectory, Path outputDirectory, JoltTransformer transformer) {
this.log = log;
this.inputDirectory = inputDirectory;
this.outputDirectory = outputDirectory;
this.transformer = transformer;
}
@Override
public FileVisitResult visitFile(Path sourceFile, BasicFileAttributes sourceAttributes) throws IOException {
log.info("Processing " + sourceFile);
Path relativeSourcePath = inputDirectory.relativize(sourceFile);
Path destinationPath = outputDirectory.resolve(relativeSourcePath);
log.info("Output " + destinationPath);
transformer.execute(sourceFile, destinationPath);
return super.visitFile(sourceFile, sourceAttributes);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy