use of org.commonjava.maven.galley.maven.model.view.settings.MavenSettingsView in project galley by Commonjava.
the class MavenSettingsReader method read.
/**
* Read (and stack by inheritance) one or more settings.xml files, and return a view that can be used to
* query various parts of the Maven settings object.<br/>
* <br/>
* <b>NOTE:</b> The first file in the list should be the most specific (eg. user-level),
* followed by ancester files in the inheritance hierarchy (parent, grand-parent, etc.).
*
* @param settingsFiles One or more files to parse, in most-local-first order
* @return The settings object
* @throws GalleyMavenException XML parsing failed, or a file could not be read.
*/
public MavenSettingsView read(final File... settingsFiles) throws GalleyMavenException {
final List<DocRef<File>> drs = new ArrayList<DocRef<File>>();
for (final File f : settingsFiles) {
if (f == null || !f.exists()) {
continue;
}
try {
final Document doc = xml.parse(f);
drs.add(new DocRef<File>(f, f, doc));
} catch (final GalleyMavenXMLException e) {
throw new GalleyMavenException("Failed to parse settings XML: {}. Reason: {}", e, f, e.getMessage());
}
}
if (drs.isEmpty()) {
return null;
}
final MavenSettingsView view = new MavenSettingsView(drs, xpath, xml);
return view;
}
Aggregations