mirror of https://github.com/apache/maven.git
[MNG-7717] Maven warns wrongly about deprecated parameter (#1031)
The implementation for MNG-7706 is wrong: it changes parameter NAME, where it should check type and defaultValue instead. --- https://issues.apache.org/jira/browse/MNG-7717
This commit is contained in:
parent
7967c204e4
commit
65d95f08a6
|
@ -22,6 +22,7 @@ import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.Parameter;
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
|
@ -43,14 +44,14 @@ class DeprecatedCoreExpressionValidator extends AbstractMavenPluginParametersVal
|
||||||
|
|
||||||
static {
|
static {
|
||||||
HashMap<String, String> deprecatedCoreParameters = new HashMap<>();
|
HashMap<String, String> deprecatedCoreParameters = new HashMap<>();
|
||||||
deprecatedCoreParameters.put("localRepository", ARTIFACT_REPOSITORY_REASON);
|
deprecatedCoreParameters.put("${localRepository}", ARTIFACT_REPOSITORY_REASON);
|
||||||
deprecatedCoreParameters.put("session.localRepository", ARTIFACT_REPOSITORY_REASON);
|
deprecatedCoreParameters.put("${session.localRepository}", ARTIFACT_REPOSITORY_REASON);
|
||||||
DEPRECATED_CORE_PARAMETERS = deprecatedCoreParameters;
|
DEPRECATED_CORE_PARAMETERS = deprecatedCoreParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getParameterLogReason(Parameter parameter) {
|
protected String getParameterLogReason(Parameter parameter) {
|
||||||
return "is deprecated core expression; " + DEPRECATED_CORE_PARAMETERS.get(parameter.getName());
|
return "is deprecated core expression; " + DEPRECATED_CORE_PARAMETERS.get(parameter.getDefaultValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,8 +63,12 @@ class DeprecatedCoreExpressionValidator extends AbstractMavenPluginParametersVal
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mojoDescriptor.getParameters().stream()
|
mojoDescriptor.getParameters().stream().filter(this::isDeprecated).forEach(this::logParameter);
|
||||||
.filter(parameter -> DEPRECATED_CORE_PARAMETERS.containsKey(parameter.getName()))
|
}
|
||||||
.forEach(this::logParameter);
|
|
||||||
|
private boolean isDeprecated(Parameter parameter) {
|
||||||
|
return Objects.equals(
|
||||||
|
org.apache.maven.artifact.repository.ArtifactRepository.class.getName(), parameter.getType())
|
||||||
|
&& DEPRECATED_CORE_PARAMETERS.containsKey(parameter.getDefaultValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue