mirror of https://github.com/apache/maven.git
[MNG-7758] Report dependency problems for all repository (#1563)
This commit is contained in:
parent
db33754938
commit
768ebbc263
|
@ -18,6 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.maven.plugin;
|
package org.apache.maven.plugin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +38,18 @@ public class PluginResolutionException extends Exception {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PluginResolutionException(Plugin plugin, List<Exception> exceptions, Throwable cause) {
|
||||||
|
super(
|
||||||
|
"Plugin " + plugin.getId() + " or one of its dependencies could not be resolved:"
|
||||||
|
+ System.lineSeparator() + "\t"
|
||||||
|
+ exceptions.stream()
|
||||||
|
.map(Throwable::getMessage)
|
||||||
|
.collect(Collectors.joining(System.lineSeparator() + "\t"))
|
||||||
|
+ System.lineSeparator(),
|
||||||
|
cause);
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
public Plugin getPlugin() {
|
public Plugin getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,8 @@ public class DefaultPluginDependenciesResolver implements PluginDependenciesReso
|
||||||
pluginArtifact = pluginArtifact.setProperties(props);
|
pluginArtifact = pluginArtifact.setProperties(props);
|
||||||
}
|
}
|
||||||
} catch (ArtifactDescriptorException e) {
|
} catch (ArtifactDescriptorException e) {
|
||||||
throw new PluginResolutionException(plugin, e);
|
throw new PluginResolutionException(
|
||||||
|
plugin, e.getResult().getExceptions(), logger.isDebugEnabled() ? e : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -140,7 +141,8 @@ public class DefaultPluginDependenciesResolver implements PluginDependenciesReso
|
||||||
request.setTrace(trace);
|
request.setTrace(trace);
|
||||||
pluginArtifact = repoSystem.resolveArtifact(session, request).getArtifact();
|
pluginArtifact = repoSystem.resolveArtifact(session, request).getArtifact();
|
||||||
} catch (ArtifactResolutionException e) {
|
} catch (ArtifactResolutionException e) {
|
||||||
throw new PluginResolutionException(plugin, e);
|
throw new PluginResolutionException(
|
||||||
|
plugin, e.getResult().getExceptions(), logger.isDebugEnabled() ? e : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluginArtifact;
|
return pluginArtifact;
|
||||||
|
@ -229,9 +231,11 @@ public class DefaultPluginDependenciesResolver implements PluginDependenciesReso
|
||||||
depRequest.setRoot(node);
|
depRequest.setRoot(node);
|
||||||
return repoSystem.resolveDependencies(session, depRequest);
|
return repoSystem.resolveDependencies(session, depRequest);
|
||||||
} catch (DependencyCollectionException e) {
|
} catch (DependencyCollectionException e) {
|
||||||
throw new PluginResolutionException(plugin, e);
|
throw new PluginResolutionException(
|
||||||
|
plugin, e.getResult().getExceptions(), logger.isDebugEnabled() ? e : null);
|
||||||
} catch (DependencyResolutionException e) {
|
} catch (DependencyResolutionException e) {
|
||||||
throw new PluginResolutionException(plugin, e.getCause());
|
throw new PluginResolutionException(
|
||||||
|
plugin, e.getResult().getCollectExceptions(), logger.isDebugEnabled() ? e : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,9 @@ public class DefaultProjectDependenciesResolver implements ProjectDependenciesRe
|
||||||
result.setCollectionErrors(e.getResult().getExceptions());
|
result.setCollectionErrors(e.getResult().getExceptions());
|
||||||
|
|
||||||
throw new DependencyResolutionException(
|
throw new DependencyResolutionException(
|
||||||
result, "Could not resolve dependencies for project " + project.getId() + ": " + e.getMessage(), e);
|
result,
|
||||||
|
"Could not collect dependencies for project " + project.getId(),
|
||||||
|
logger.isDebugEnabled() ? e : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
depRequest.setRoot(node);
|
depRequest.setRoot(node);
|
||||||
|
@ -190,7 +192,9 @@ public class DefaultProjectDependenciesResolver implements ProjectDependenciesRe
|
||||||
process(result, e.getResult().getArtifactResults());
|
process(result, e.getResult().getArtifactResults());
|
||||||
|
|
||||||
throw new DependencyResolutionException(
|
throw new DependencyResolutionException(
|
||||||
result, "Could not resolve dependencies for project " + project.getId() + ": " + e.getMessage(), e);
|
result,
|
||||||
|
"Could not resolve dependencies for project " + project.getId(),
|
||||||
|
logger.isDebugEnabled() ? e : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -18,18 +18,52 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.maven.project;
|
package org.apache.maven.project;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.aether.graph.Dependency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class DependencyResolutionException extends Exception {
|
public class DependencyResolutionException extends Exception {
|
||||||
|
|
||||||
private final transient DependencyResolutionResult result;
|
private final transient DependencyResolutionResult result;
|
||||||
|
private final transient String detailMessage;
|
||||||
|
|
||||||
public DependencyResolutionException(DependencyResolutionResult result, String message, Throwable cause) {
|
public DependencyResolutionException(DependencyResolutionResult result, String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
this.result = result;
|
this.result = result;
|
||||||
|
this.detailMessage = prepareDetailMessage(message, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String prepareDetailMessage(String message, DependencyResolutionResult result) {
|
||||||
|
StringBuilder msg = new StringBuilder(message);
|
||||||
|
msg.append(System.lineSeparator());
|
||||||
|
for (Dependency dependency : result.getUnresolvedDependencies()) {
|
||||||
|
msg.append("dependency: ").append(dependency).append(System.lineSeparator());
|
||||||
|
List<Exception> exceptions = result.getResolutionErrors(dependency);
|
||||||
|
for (Exception e : exceptions) {
|
||||||
|
msg.append("\t").append(e.getMessage()).append(System.lineSeparator());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Exception exception : result.getCollectionErrors()) {
|
||||||
|
msg.append(exception.getMessage()).append(System.lineSeparator());
|
||||||
|
if (exception.getCause() != null) {
|
||||||
|
msg.append("\tCaused by: ")
|
||||||
|
.append(exception.getCause().getMessage())
|
||||||
|
.append(System.lineSeparator());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DependencyResolutionResult getResult() {
|
public DependencyResolutionResult getResult() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return detailMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,9 +226,7 @@ public class BootstrapCoreExtensionManager {
|
||||||
.filter(ArtifactResult::isResolved)
|
.filter(ArtifactResult::isResolved)
|
||||||
.map(ArtifactResult::getArtifact)
|
.map(ArtifactResult::getArtifact)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} catch (PluginResolutionException e) {
|
} catch (PluginResolutionException | InterpolationException e) {
|
||||||
throw new ExtensionResolutionException(extension, e.getCause());
|
|
||||||
} catch (InterpolationException e) {
|
|
||||||
throw new ExtensionResolutionException(extension, e);
|
throw new ExtensionResolutionException(extension, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue