use of org.apache.maven.plugin.resources.remote.SupplementalDataModel in project asterixdb by apache.
the class SupplementalModelHelper method loadSupplements.
static Map<String, Model> loadSupplements(Log log, String[] models) throws MojoExecutionException {
if (models == null) {
log.debug("Supplemental data models won't be loaded. " + "No models specified.");
return Collections.emptyMap();
}
List<Supplement> supplements = new ArrayList<>();
for (String set : models) {
log.debug("Preparing ruleset: " + set);
try {
File f = new File(set);
if (!f.exists()) {
throw new MojoExecutionException("Cold not resolve " + set);
}
if (!f.canRead()) {
throw new MojoExecutionException("Supplemental data models won't be loaded. " + "File " + f.getAbsolutePath() + " cannot be read, check permissions on the file.");
}
log.debug("Loading supplemental models from " + f.getAbsolutePath());
SupplementalDataModelXpp3Reader reader = new SupplementalDataModelXpp3Reader();
try (FileInputStream fis = new FileInputStream(f);
Reader fileReader = new InputStreamReader(fis)) {
SupplementalDataModel supplementalModel = reader.read(fileReader);
supplements.addAll(supplementalModel.getSupplement());
}
} catch (Exception e) {
String msg = "Error loading supplemental data models: " + e.getMessage();
log.error(msg, e);
throw new MojoExecutionException(msg, e);
}
}
log.debug("Loading supplements complete.");
Map<String, Model> supplementMap = new HashMap<>();
for (Supplement sd : supplements) {
Xpp3Dom dom = (Xpp3Dom) sd.getProject();
Model m = getSupplement(log, dom);
supplementMap.put(generateSupplementMapKey(m.getGroupId(), m.getArtifactId()), m);
}
return supplementMap;
}
Aggregations