@Override
Map<String, String> mappings(final Map<String, String> context, final String value, final Model model) {
final Map<String, String> mappings = Maps.newHashMap();
if (value.contains("${project.dm.") && model.getDependencyManagement() != null) {
final DefaultArtifact artifact;
try {
artifact = new DefaultArtifact(value);
final List<Dependency> dependencies = model.getDependencyManagement().getDependencies();
for (Dependency dependency : dependencies) {
if (!dependency.getGroupId().equalsIgnoreCase(artifact.getGroupId())) {
continue;
}
if (!dependency.getArtifactId().equalsIgnoreCase(artifact.getArtifactId())) {
continue;
}
String extensionToCompare = dependency.getType();
if (extensionToCompare == null || extensionToCompare.isEmpty()) {
extensionToCompare = "jar";
}
if (!extensionToCompare.equals(artifact.getExtension())) {
continue;
}
String classifierToCompare = dependency.getClassifier();
if (classifierToCompare == null || extensionToCompare.isEmpty()) {
classifierToCompare = "";
}
if (!classifierToCompare.equals(artifact.getClassifier())) {
continue;
}
mappings.put("project.dm.version", dependency.getVersion());
}