in log4j-transform-maven-plugin/src/main/java/org/apache/logging/log4j/transform/maven/LocationMojo.java [195:221]
private boolean validateLog4jVersion() throws MojoExecutionException {
Optional<Artifact> artifact = project.getArtifacts().stream()
.filter(a -> LOG4J_GROUP_ID.equals(a.getGroupId()) && LOG4J_API_ARTIFACT_ID.equals(a.getArtifactId()))
.findAny();
Artifact log4jApi;
if (artifact.isPresent()) {
log4jApi = artifact.get();
} else {
getLog().info("Skipping project. Log4j API is not being used.");
return false;
}
try {
if (MIN_SUPPORTED_VERSION.compareTo(log4jApi.getSelectedVersion()) > 0) {
getLog().error("Log4j2 API version " + MIN_SUPPORTED_VERSION + " required. Selected version: "
+ log4jApi.getSelectedVersion());
return false;
}
// Transitive dependency
if (!project.getDependencyArtifacts().contains(log4jApi)) {
getLog().warn("Log4j2 API should not be a transitive dependency.");
}
} catch (OverConstrainedVersionException e) {
getLog().error("Can not determine `log4j-api` version. " + e.getMessage());
return false;
}
return true;
}