use of org.apache.maven.toolchain.MisconfiguredToolchainException in project maven-plugins by apache.
the class ToolchainMojo method selectToolchain.
protected boolean selectToolchain(String type, Map<String, String> params) throws MojoExecutionException {
getLog().info("Required toolchain: " + getToolchainRequirementAsString(type, params));
int typeFound = 0;
try {
ToolchainPrivate[] tcs = getToolchains(type);
for (ToolchainPrivate tc : tcs) {
if (!type.equals(tc.getType())) {
// useful because of MNG-5716
continue;
}
typeFound++;
if (tc.matchesRequirements(params)) {
getLog().info("Found matching toolchain for type " + type + ": " + tc);
// store matching toolchain to build context
toolchainManagerPrivate.storeToolchainToBuildContext(tc, session);
return true;
}
}
} catch (MisconfiguredToolchainException ex) {
throw new MojoExecutionException("Misconfigured toolchains.", ex);
}
getLog().error("No toolchain " + ((typeFound == 0) ? "found" : ("matched from " + typeFound + " found")) + " for type " + type);
return false;
}
use of org.apache.maven.toolchain.MisconfiguredToolchainException 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;
}
use of org.apache.maven.toolchain.MisconfiguredToolchainException in project maven-plugins by apache.
the class ToolchainMojo method selectToolchain.
protected boolean selectToolchain(String type, Map<String, String> params) throws MojoExecutionException {
getLog().info("Required toolchain: " + getToolchainRequirementAsString(type, params));
int typeFound = 0;
try {
ToolchainPrivate[] tcs = getToolchains(type);
for (ToolchainPrivate tc : tcs) {
if (!type.equals(tc.getType())) {
// useful because of MNG-5716
continue;
}
typeFound++;
if (tc.matchesRequirements(params)) {
getLog().info("Found matching toolchain for type " + type + ": " + tc);
// store matching toolchain to build context
toolchainManagerPrivate.storeToolchainToBuildContext(tc, session);
return true;
}
}
} catch (MisconfiguredToolchainException ex) {
throw new MojoExecutionException("Misconfigured toolchains.", ex);
}
getLog().error("No toolchain " + ((typeFound == 0) ? "found" : ("matched from " + typeFound + " found")) + " for type " + type);
return false;
}
Aggregations