Skip to content

Commit

Permalink
fix(core): use subgroup package infos when available (#4908)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skraye authored Sep 12, 2024
1 parent 0c2c476 commit 8fca0fd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/src/main/java/io/kestra/core/docs/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ public class Plugin {
public static Plugin of(RegisteredPlugin registeredPlugin, @Nullable String subgroup) {
Plugin plugin = new Plugin();
plugin.name = registeredPlugin.name();
PluginSubGroup subGroupInfos = null;
if (subgroup == null) {
plugin.title = registeredPlugin.title();
} else {
plugin.title = subgroup.substring(subgroup.lastIndexOf('.') + 1);
subGroupInfos = registeredPlugin.allClass().stream().filter(c -> c.getName().contains(subgroup)).map(clazz -> clazz.getPackage().getDeclaredAnnotation(PluginSubGroup.class)).toList().getFirst();
plugin.title = !subGroupInfos.title().isEmpty() ? subGroupInfos.title() : subgroup.substring(subgroup.lastIndexOf('.') + 1);;

}
plugin.group = registeredPlugin.group();
plugin.description = registeredPlugin.description();
plugin.description = subGroupInfos != null && !subGroupInfos.description().isEmpty() ? subGroupInfos.description() : registeredPlugin.description();
plugin.license = registeredPlugin.license();
plugin.longDescription = registeredPlugin.longDescription();
plugin.version = registeredPlugin.version();
Expand All @@ -59,7 +62,9 @@ public static Plugin of(RegisteredPlugin registeredPlugin, @Nullable String subg
e.getValue().toString()
))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
plugin.categories = registeredPlugin
plugin.categories = subGroupInfos != null ?
Arrays.stream(subGroupInfos.categories()).toList() :
registeredPlugin
.allClass()
.stream()
.map(clazz -> clazz.getPackage().getDeclaredAnnotation(PluginSubGroup.class))
Expand Down

0 comments on commit 8fca0fd

Please sign in to comment.