fix: warn if deprecated configs are used by jeremylong · Pull Request #8366 · dependency-check/DependencyCheck (original) (raw)

👍 If we expect the logging code to live longer, you could extract a helper function. The logging message follows a pattern (DRY).

As for Maven, we could check the MojoExecution configuration.

@Parameter(defaultValue = "${mojoExecution}", readonly = true) private MojoExecution mojoExecution;

private void warnIfDeprecatedParamUsed(String deprecatedName, String currentName) { mojoExecution.getConfiguration() .getChildren() .stream() .filter(child -> deprecatedName.equals(child.getName())) .findFirst() .ifPresent(c -> getLog().warn("...")); }

// invoke warnIfDeprecatedParamUsed() for each pair or maybe use reflection to find all aliased @Parameter annotation?

Or check the Maven session

@Parameter(defaultValue = "${session}", readonly = true) private MavenSession session;

... // session.getUserProperties() or session.getCurrentProject().getProperties()