}
LOG.info("{} {} YANG models processed in {}", LOG_PREFIX, holder.getContext().getModules().size(), sw);
- outputFiles.addAll(generateSources(holder, codeGenerators, parserConfig));
+
+ for (GeneratorTaskFactory factory : codeGenerators) {
+ if (!parserConfig.equals(factory.parserConfig())) {
+ continue;
+ }
+
+ final Stopwatch genSw = Stopwatch.createStarted();
+ final GeneratorTask task = factory.createTask(project, holder);
+ LOG.debug("{} Task {} initialized in {}", LOG_PREFIX, task, genSw);
+
+ final List<FileState> files;
+ try {
+ files = task.execute(buildContext);
+ } catch (FileGeneratorException | IOException e) {
+ throw new MojoFailureException(LOG_PREFIX + " Generator " + factory + " failed", e);
+ }
+
+ outputFiles.addAll(files);
+
+ LOG.info("{} Sources generated by {}: {} in {}", LOG_PREFIX, factory.generatorName(), files.size(),
+ genSw);
+ }
if (!sourcesPersisted) {
// add META_INF/yang once
.collect(ImmutableList.toImmutableList());
}
- /**
- * Call generate on every generator from plugin configuration.
- */
- private List<FileState> generateSources(final ContextHolder context,
- final Collection<GeneratorTaskFactory> generators, final YangParserConfiguration parserConfig)
- throws MojoFailureException {
- final var generatorToFiles = ImmutableList.<FileState>builder();
- for (GeneratorTaskFactory factory : generators) {
- if (!parserConfig.equals(factory.parserConfig())) {
- continue;
- }
-
- final Stopwatch sw = Stopwatch.createStarted();
- final GeneratorTask task = factory.createTask(project, context);
- LOG.debug("{} Task {} initialized in {}", LOG_PREFIX, task, sw);
-
- final List<FileState> files;
- try {
- files = task.execute(buildContext);
- } catch (FileGeneratorException | IOException e) {
- throw new MojoFailureException(LOG_PREFIX + " Generator " + factory + " failed", e);
- }
-
- final String generatorName = factory.generatorName();
- LOG.debug("{} Sources generated by {}: {}", LOG_PREFIX, generatorName, files);
-
- final int fileCount = files.size();
- generatorToFiles.addAll(files);
-
- LOG.info("{} Sources generated by {}: {} in {}", LOG_PREFIX, generatorName, fileCount, sw);
- }
-
- return generatorToFiles.build();
- }
-
@VisibleForTesting
static @NonNull Path stateFilePath(final String projectBuildDirectory) {
// ${project.build.directory}/maven-status/yang-maven-plugin/execution.state