Search in sources :

Example 1 with YamlParserV2

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);
        }
    }
}
Also used : YamlParserV2(com.walmartlabs.concord.runtime.v2.parser.YamlParserV2) Imports(com.walmartlabs.concord.imports.Imports)

Example 2 with YamlParserV2

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));
}
Also used : Snapshot(com.walmartlabs.concord.repository.Snapshot) YamlParserV2(com.walmartlabs.concord.runtime.v2.parser.YamlParserV2) Imports(com.walmartlabs.concord.imports.Imports)

Aggregations

Imports (com.walmartlabs.concord.imports.Imports)2 YamlParserV2 (com.walmartlabs.concord.runtime.v2.parser.YamlParserV2)2 Snapshot (com.walmartlabs.concord.repository.Snapshot)1