}
}
Collections.sort(candidates);
}
if ( candidates.size() == 0 ) {
throw new MojoExecutionException("No model files found in " + systemsDirectory);
}
for(final String name : candidates) {
logger.debug("Reading model " + name + " in project " + project.getId());
try {
final File f = new File(systemsDirectory, name);
final FileReader reader = new FileReader(f);
try {
final Model current = ModelReader.read(reader, f.getAbsolutePath());
final Map<Traceable, String> errors = ModelUtility.validate(current);
if (errors != null ) {
throw new MojoExecutionException("Invalid model at " + name + " : " + errors);
}
ModelUtility.merge(result, current);
} finally {
IOUtils.closeQuietly(reader);
}
} catch ( final IOException io) {
throw new MojoExecutionException("Unable to read " + name, io);
}
}
final Map<Traceable, String> errors = ModelUtility.validate(result);
if (errors != null ) {
throw new MojoExecutionException("Invalid assembled model : " + errors);
}
return result;
}