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 java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
|
@ -43,14 +44,14 @@ class DeprecatedCoreExpressionValidator extends AbstractMavenPluginParametersVal
|
|||
|
||||
static {
|
||||
HashMap<String, String> deprecatedCoreParameters = new HashMap<>();
|
||||
deprecatedCoreParameters.put("localRepository", ARTIFACT_REPOSITORY_REASON);
|
||||
deprecatedCoreParameters.put("session.localRepository", ARTIFACT_REPOSITORY_REASON);
|
||||
deprecatedCoreParameters.put("${localRepository}", ARTIFACT_REPOSITORY_REASON);
|
||||
deprecatedCoreParameters.put("${session.localRepository}", ARTIFACT_REPOSITORY_REASON);
|
||||
DEPRECATED_CORE_PARAMETERS = deprecatedCoreParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -62,8 +63,12 @@ class DeprecatedCoreExpressionValidator extends AbstractMavenPluginParametersVal
|
|||
return;
|
||||
}
|
||||
|
||||
mojoDescriptor.getParameters().stream()
|
||||
.filter(parameter -> DEPRECATED_CORE_PARAMETERS.containsKey(parameter.getName()))
|
||||
.forEach(this::logParameter);
|
||||
mojoDescriptor.getParameters().stream().filter(this::isDeprecated).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