Skip to content

Commit

Permalink
Added the handling of apache/camel-kamelets#2260 corner case in conne…
Browse files Browse the repository at this point in the history
…ctors generated by kamelets
  • Loading branch information
valdar committed Oct 29, 2024
1 parent 09807fb commit 54c3131
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,16 @@ private void updateConnector() throws Exception {

private Set<String> getKameletDependencies(KameletModel kamelet) throws XPathExpressionException {
Set<String> deps = new HashSet<>(kamelet.getDependencies());
Set<String> gavDeps = deps.stream().map(stringDep -> {
Set<String> gavDeps = deps.stream()
.filter(stringDep -> stringDep != null && !stringDep.trim().isEmpty() && !"null".equals(stringDep.trim()))
.map(stringDep -> {
if (stringDep.startsWith("mvn:")) {
return stringDep.replaceFirst("mvn:", "");
} else if (stringDep.startsWith("camel:")) {
return getMainDepGroupId() + ":" + stringDep.replaceFirst(":", "-");
} else {
getLog().warn("Dependency " + stringDep + "is used as is. Might not be the intended behaviour!");
String length = stringDep == null ? "the string is null value" : Integer.toString(stringDep.length());
getLog().warn("Dependency string: " + stringDep + " (length of the string is: " + length + ") is used as is. Might not be the intended behaviour!");
return stringDep;
}
}).collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ public static KameletModel parseKameletYaml(ObjectNode kameletYamlNode) {
km.setRequiredProperties(requiredProperties);

Set<String> dependencies = new HashSet<>();
kameletYamlNode.at("/spec/dependencies").forEach(req -> dependencies.add(req.asText()));
kameletYamlNode.at("/spec/dependencies").forEach(req -> {
if (req != null && !req.isNull()) {
dependencies.add(req.asText());
}
});
km.setDependencies(dependencies);

List<KameletPropertyModel> kpms = new ArrayList<>();
Expand Down

0 comments on commit 54c3131

Please sign in to comment.