use of com.walmartlabs.concord.runtime.v2.parser.YamlParserV2 in project concord by walmartlabs.
the class ProjectLoaderV2 method export.
public void export(Path baseDir, Path destDir, ImportsNormalizer importsNormalizer, ImportsListener listener, CopyOption... options) throws Exception {
YamlParserV2 parser = new YamlParserV2();
ProcessDefinition root = loadRoot(parser, baseDir);
Resources resources = root != null ? root.resources() : Resources.builder().build();
boolean hasImports = root != null && root.imports() != null && !root.imports().isEmpty();
if (!hasImports) {
copyResources(baseDir, resources, destDir, options);
return;
}
Path tmpDir = null;
try {
tmpDir = IOUtils.createTempDir("concord-export");
copyResources(baseDir, resources, tmpDir, options);
Imports imports = importsNormalizer.normalize(root.imports());
importManager.process(imports, tmpDir, listener);
copyResources(tmpDir, resources, destDir, options);
} finally {
if (tmpDir != null) {
IOUtils.deleteRecursively(tmpDir);
}
}
}
use of com.walmartlabs.concord.runtime.v2.parser.YamlParserV2 in project concord by walmartlabs.
the class ProjectLoaderV2 method load.
public Result load(Path baseDir, ImportsNormalizer importsNormalizer, ImportsListener listener) throws Exception {
YamlParserV2 parser = new YamlParserV2();
// load the initial ProcessDefinition from the root concord.yml file
// it will be used to determine whether we need to load other resources (e.g. imports)
ProcessDefinition root = loadRoot(parser, baseDir);
List<Snapshot> snapshots = Collections.emptyList();
if (root != null) {
Imports imports = importsNormalizer.normalize(root.imports());
snapshots = importManager.process(imports, baseDir, listener);
}
List<Path> files = loadResources(baseDir, root != null ? root.resources() : Resources.builder().build());
Collections.sort(files);
List<ProcessDefinition> definitions = new ArrayList<>();
for (Path p : files) {
definitions.add(parser.parse(baseDir, p));
}
if (root != null) {
definitions.add(root);
}
if (definitions.isEmpty()) {
throw new IllegalStateException("Can't find any Concord process definition files in '" + baseDir + "'");
}
return new Result(snapshots, merge(definitions));
}
Aggregations