use of org.apache.maven.toolchain.RequirementMatcher in project maven-plugins by apache.
the class CustomToolchainFactory method createToolchain.
public ToolchainPrivate createToolchain(ToolchainModel model) throws MisconfiguredToolchainException {
if (model == null) {
return null;
}
CustomToolchainImpl customToolchain = new CustomToolchainImpl(model, logger);
// populate the provides section
Properties provides = getProvidesProperties(model);
for (Map.Entry<Object, Object> provide : provides.entrySet()) {
String key = (String) provide.getKey();
String value = (String) provide.getValue();
if (value == null) {
throw new MisconfiguredToolchainException("Provides token '" + key + "' doesn't have any value configured.");
}
RequirementMatcher matcher;
if ("version".equals(key)) {
matcher = RequirementMatcherFactory.createVersionMatcher(value);
} else {
matcher = RequirementMatcherFactory.createExactMatcher(value);
}
customToolchain.addProvideToken(key, matcher);
}
// populate the configuration section
Properties configuration = toProperties((Xpp3Dom) model.getConfiguration());
String toolHome = configuration.getProperty(CustomToolchainImpl.KEY_TOOLHOME);
if (toolHome == null) {
throw new MisconfiguredToolchainException("Custom toolchain without the " + CustomToolchainImpl.KEY_TOOLHOME + " configuration element.");
}
toolHome = FileUtils.normalize(toolHome);
customToolchain.setToolHome(toolHome);
if (!new File(toolHome).exists()) {
throw new MisconfiguredToolchainException("Non-existing tool home configuration at " + new File(toolHome).getAbsolutePath());
}
return customToolchain;
}
Aggregations