in tooling/camel-karaf-feature-maven-plugin/src/main/java/org/apache/camel/karaf/feature/maven/AutoDetectVersionMojo.java [111:144]
private void autoDetectVersion(Feature feature, Bundle bundle, Map<String, BundleVersion> dependencies) {
String location = bundle.getLocation();
Matcher matcher = MVN_BASED_PROTOCOL.matcher(location);
if (!matcher.matches()) {
getLog().warn("Bundle location %s does not match with a maven based protocol in the feature %s".formatted(location, feature.getName()));
return;
}
final String groupId;
final String artifactId;
Matcher aliasMatcher = AUTO_DETECT_PLACEHOLDER.matcher(matcher.group(4));
if (!aliasMatcher.find()) {
getLog().warn("Bundle location %s does not match with a placeholder syntax in the feature %s".formatted(location, feature.getName()));
return;
}
if (aliasMatcher.group(2) != null && aliasMatcher.group(3) != null) {
groupId = aliasMatcher.group(2);
artifactId = aliasMatcher.group(3);
if (getLog().isDebugEnabled()) {
getLog().debug("Alias %s/%s detected for the artifact %s in the feature %s".formatted(groupId, artifactId, location, feature.getName()));
}
} else {
groupId = matcher.group(2);
artifactId = matcher.group(3);
}
BundleVersion version = dependencies.get("%s/%s".formatted(groupId, artifactId));
if (version == null) {
getLog().error("Version of the artifact %s/%s could not be auto-detected in the feature %s".formatted(groupId, artifactId, feature.getName()));
return;
}
if (getLog().isDebugEnabled()) {
getLog().debug("Version %s detected for the artifact %s/%s in the feature %s".formatted(version, groupId, artifactId, feature.getName()));
}
bundle.setLocation(AUTO_DETECT_PLACEHOLDER.matcher(location).replaceAll(version.toString()));
}