if (yangFilesInProject.isEmpty()) {
// No files to process, skip.
LOG.info("{} No input files found", LOG_PREFIX);
+ wipeAllState(prevState);
return;
}
final List<GeneratorTask> codeGenerators = instantiateGenerators();
if (codeGenerators.isEmpty()) {
LOG.warn("{} No code generators provided", LOG_PREFIX);
+ wipeAllState(prevState);
return;
}
}
}
+ private void wipeAllState(final YangToSourcesState prevState) throws MojoExecutionException {
+ if (prevState != null) {
+ for (var file : prevState.outputFiles().fileStates().keySet()) {
+ try {
+ Files.deleteIfExists(Path.of(file));
+ } catch (IOException e) {
+ throw new MojoExecutionException("Failed to remove file " + file, e);
+ }
+ }
+ }
+
+ try {
+ stateStorage.deleteState();
+ } catch (IOException e) {
+ throw new MojoExecutionException("Failed to remove execution state", e);
+ }
+ }
+
private List<GeneratorTask> instantiateGenerators() throws MojoExecutionException {
// Search for available FileGenerator implementations
final Map<String, FileGeneratorFactory> factories = Maps.uniqueIndex(