- SchemaContext context = processYang();
- generateSources(context);
- }
-
- /**
- * Generate {@link SchemaContext} with {@link YangModelParserImpl}
- */
- private SchemaContext processYang() throws MojoExecutionException {
- try {
- String[] yangFiles = Util.listFilesAsArrayOfPaths(yangFilesRootDir);
-
- if (yangFiles.length == 0)
- getLog().warn(
- Util.message("No %s file found in %s", LOG_PREFIX,
- Util.YANG_SUFFIX, yangFilesRootDir));
- // TODO only warning or throw exception ?
-
- Set<Module> parsedYang = parser.parseYangModels(yangFiles);
- SchemaContext resolveSchemaContext = parser
- .resolveSchemaContext(parsedYang);
- getLog().info(
- Util.message("%s files parsed from %s", LOG_PREFIX,
- Util.YANG_SUFFIX, Arrays.toString(yangFiles)));
- return resolveSchemaContext;
-
- // MojoExecutionException is thrown since execution cannot continue
- } catch (Exception e) {
- String message = Util.message("Unable to parse %s files from %s",
- LOG_PREFIX, Util.YANG_SUFFIX, yangFilesRootDir);
- getLog().error(message, e);
- throw new MojoExecutionException(message, e);
- }
- }
-
- /**
- * Call generate on every generator from plugin configuration
- */
- private void generateSources(SchemaContext context)
- throws MojoFailureException {
- if (codeGenerators.length == 0) {
- getLog().warn(
- Util.message("No code generators provided", LOG_PREFIX));
- return;