mirror of https://github.com/apache/maven.git
[MNG-8117] Maven PluginVersionResolver improvement (#1502)
Produces output like this: https://gist.github.com/cstamas/3ca4bc6cea5f701054061871b5db3f35 --- https://issues.apache.org/jira/browse/MNG-8117
This commit is contained in:
parent
d8199bf3b9
commit
ba52bfe600
|
@ -39,6 +39,7 @@ import org.apache.maven.artifact.repository.metadata.io.MetadataReader;
|
|||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.MavenPluginManager;
|
||||
import org.apache.maven.plugin.PluginIncompatibleException;
|
||||
import org.apache.maven.plugin.PluginResolutionException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.plugin.version.PluginVersionRequest;
|
||||
|
@ -175,6 +176,8 @@ public class DefaultPluginVersionResolver implements PluginVersionResolver {
|
|||
throws PluginVersionResolutionException {
|
||||
String version = null;
|
||||
ArtifactRepository repo = null;
|
||||
boolean resolvedPluginVersions = !versions.versions.isEmpty();
|
||||
boolean searchPerformed = false;
|
||||
|
||||
if (versions.releaseVersion != null && !versions.releaseVersion.isEmpty()) {
|
||||
version = versions.releaseVersion;
|
||||
|
@ -184,8 +187,13 @@ public class DefaultPluginVersionResolver implements PluginVersionResolver {
|
|||
repo = versions.latestRepository;
|
||||
}
|
||||
if (version != null && !isCompatible(request, version)) {
|
||||
logger.info(
|
||||
"Latest version of plugin {}:{} failed compatibility check",
|
||||
request.getGroupId(),
|
||||
request.getArtifactId());
|
||||
versions.versions.remove(version);
|
||||
version = null;
|
||||
searchPerformed = true;
|
||||
}
|
||||
|
||||
if (version == null) {
|
||||
|
@ -206,16 +214,26 @@ public class DefaultPluginVersionResolver implements PluginVersionResolver {
|
|||
}
|
||||
}
|
||||
|
||||
for (Version v : releases) {
|
||||
String ver = v.toString();
|
||||
if (isCompatible(request, ver)) {
|
||||
version = ver;
|
||||
repo = versions.versions.get(version);
|
||||
break;
|
||||
if (!releases.isEmpty()) {
|
||||
logger.info(
|
||||
"Looking for compatible RELEASE version of plugin {}:{}",
|
||||
request.getGroupId(),
|
||||
request.getArtifactId());
|
||||
for (Version v : releases) {
|
||||
String ver = v.toString();
|
||||
if (isCompatible(request, ver)) {
|
||||
version = ver;
|
||||
repo = versions.versions.get(version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version == null) {
|
||||
if (version == null && !snapshots.isEmpty()) {
|
||||
logger.info(
|
||||
"Looking for compatible SNAPSHOT version of plugin {}:{}",
|
||||
request.getGroupId(),
|
||||
request.getArtifactId());
|
||||
for (Version v : snapshots) {
|
||||
String ver = v.toString();
|
||||
if (isCompatible(request, ver)) {
|
||||
|
@ -228,15 +246,27 @@ public class DefaultPluginVersionResolver implements PluginVersionResolver {
|
|||
}
|
||||
|
||||
if (version != null) {
|
||||
// if LATEST worked out of the box, remain silent as today, otherwise inform user about search result
|
||||
if (searchPerformed) {
|
||||
logger.info("Selected plugin {}:{}:{}", request.getGroupId(), request.getArtifactId(), version);
|
||||
}
|
||||
result.setVersion(version);
|
||||
result.setRepository(repo);
|
||||
} else {
|
||||
logger.warn(
|
||||
resolvedPluginVersions
|
||||
? "Could not find compatible version of plugin {}:{} in any plugin repository"
|
||||
: "Plugin {}:{} not found in any plugin repository",
|
||||
request.getGroupId(),
|
||||
request.getArtifactId());
|
||||
throw new PluginVersionResolutionException(
|
||||
request.getGroupId(),
|
||||
request.getArtifactId(),
|
||||
request.getRepositorySession().getLocalRepository(),
|
||||
request.getRepositories(),
|
||||
"Plugin not found in any plugin repository");
|
||||
resolvedPluginVersions
|
||||
? "Could not find compatible plugin version in any plugin repository"
|
||||
: "Plugin not found in any plugin repository");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,8 +291,12 @@ public class DefaultPluginVersionResolver implements PluginVersionResolver {
|
|||
|
||||
try {
|
||||
pluginManager.checkPrerequisites(pluginDescriptor);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Ignoring incompatible plugin version {}", version, e);
|
||||
} catch (PluginIncompatibleException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.warn("Ignoring incompatible plugin version {}:", version, e);
|
||||
} else {
|
||||
logger.warn("Ignoring incompatible plugin version {}: {}", version, e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue