use of org.apache.maven.plugin.resources.remote.io.xpp3.SupplementalDataModelXpp3Reader 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;
}
use of org.apache.maven.plugin.resources.remote.io.xpp3.SupplementalDataModelXpp3Reader in project maven-plugins by apache.
the class ProcessRemoteResourcesMojo method loadSupplements.
private Map<String, Model> loadSupplements(String[] models) throws MojoExecutionException {
if (models == null) {
getLog().debug("Supplemental data models won't be loaded. " + "No models specified.");
return Collections.emptyMap();
}
List<Supplement> supplements = new ArrayList<Supplement>();
for (String set : models) {
getLog().debug("Preparing ruleset: " + set);
try {
File f = locator.getResourceAsFile(set, getLocationTemp(set));
if (null == f || !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.");
}
getLog().debug("Loading supplemental models from " + f.getAbsolutePath());
SupplementalDataModelXpp3Reader reader = new SupplementalDataModelXpp3Reader();
SupplementalDataModel supplementalModel = reader.read(new FileReader(f));
supplements.addAll(supplementalModel.getSupplement());
} catch (Exception e) {
String msg = "Error loading supplemental data models: " + e.getMessage();
getLog().error(msg, e);
throw new MojoExecutionException(msg, e);
}
}
getLog().debug("Loading supplements complete.");
Map<String, Model> supplementMap = new HashMap<String, Model>();
for (Supplement sd : supplements) {
Xpp3Dom dom = (Xpp3Dom) sd.getProject();
Model m = getSupplement(dom);
supplementMap.put(generateSupplementMapKey(m.getGroupId(), m.getArtifactId()), m);
}
return supplementMap;
}
Aggregations