use of org.codehaus.plexus.component.repository.exception.ComponentLifecycleException in project maven-plugins by apache.
the class AbstractDeployMojo method configureWagon.
/**
* Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
*
* @param wagon
* @param repositoryId
* @param settings
* @param container
* @param log
* @throws TransferFailedException
* @todo Remove when {@link WagonManager#getWagon(Repository) is available}. It's available in Maven 2.0.5.
*/
private static void configureWagon(Wagon wagon, String repositoryId, Settings settings, PlexusContainer container, Log log) throws TransferFailedException {
log.debug(" configureWagon ");
// MSITE-25: Make sure that the server settings are inserted
for (Server server : settings.getServers()) {
String id = server.getId();
log.debug("configureWagon server " + id);
if (id != null && id.equals(repositoryId) && (server.getConfiguration() != null)) {
final PlexusConfiguration plexusConf = new XmlPlexusConfiguration((Xpp3Dom) server.getConfiguration());
ComponentConfigurator componentConfigurator = null;
try {
componentConfigurator = (ComponentConfigurator) container.lookup(ComponentConfigurator.ROLE, "basic");
if (isMaven3OrMore()) {
componentConfigurator.configureComponent(wagon, plexusConf, container.getContainerRealm());
} else {
configureWagonWithMaven2(componentConfigurator, wagon, plexusConf, container);
}
} catch (final ComponentLookupException e) {
throw new TransferFailedException("While configuring wagon for \'" + repositoryId + "\': Unable to lookup wagon configurator." + " Wagon configuration cannot be applied.", e);
} catch (ComponentConfigurationException e) {
throw new TransferFailedException("While configuring wagon for \'" + repositoryId + "\': Unable to apply wagon configuration.", e);
} finally {
if (componentConfigurator != null) {
try {
container.release(componentConfigurator);
} catch (ComponentLifecycleException e) {
log.error("Problem releasing configurator - ignoring: " + e.getMessage());
}
}
}
}
}
}
Aggregations