-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support optional to optional extension dependencies #7729
Conversation
Allow optional extensions to depend on other optional extensions in the same add-on. Signed-off-by: ricekot <github@ricekot.com>
@@ -126,6 +126,8 @@ public class AddOnLoader extends URLClassLoader { | |||
*/ | |||
private Map<String, AddOnClassLoader> addOnLoaders = new HashMap<>(); | |||
|
|||
private Map<String, Collection<AddOnClassLoader>> extensionLoaders = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class loaders are being added but never removed from the map, when the extension/add-on is unloaded.
DEPENDENCIES_ELEMENT + "." + DEPENDENCIES_ADDONS_ALL_ELEMENTS; | ||
private static final String EXTENSION_EXTENSION_DEPENDENCIES = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JavaDoc could be updated to mention the new element.
List<HierarchicalConfiguration> fields = | ||
List<HierarchicalConfiguration> addOnFields = | ||
node.configurationsAt(DEPENDENCIES_ADDONS_ALL_ELEMENTS); | ||
if (fields.isEmpty()) { | ||
return new Dependencies(javaVersion, Collections.<AddOnDep>emptyList()); | ||
var extensionFields = node.configurationsAt(DEPENDENCIES_EXTENSIONS_ALL_ELEMENTS); | ||
if (addOnFields.isEmpty() && extensionFields.isEmpty()) { | ||
return new Dependencies(javaVersion, List.of(), List.of()); | ||
} | ||
|
||
List<AddOnDep> addOns = readAddOnDependencies(fields); | ||
return new Dependencies(javaVersion, addOns); | ||
List<AddOnDep> addOns = readAddOnDependencies(addOnFields); | ||
List<ExtensionDep> extensions = readExtensionDependencies(extensionFields); | ||
return new Dependencies(javaVersion, addOns, extensions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes (and in Dependencies
) should not be needed, the add-on will not depend on extensions(?).
if (classname == null) { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed, the name is required.
@@ -320,16 +328,12 @@ protected Class<?> findClass(String name) throws ClassNotFoundException { | |||
} | |||
} | |||
|
|||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep this the default behaviour (classes of the add-on should have priority over the ones in the dependencies) and allow to change it when needed.
if (classname == null) { | ||
continue; | ||
} | ||
if (addOn.getExtensionsWithDeps().contains(classname)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should also check that it can be loaded (i.e. the transitive dependencies are all met).
Closing as per discussions in Slack. The original intention of this PR was to support the case where the GraphQL add-on wanted to use some functionalities of the quickstart add-on (launch the user's preferred browser with GraphQL IDE URL open) without explicitly depending on it. There are other ways to achieve this use case, e.g. move any functionality needed by two or more add-ons into commonlib (in this case, launching a browser). |
Allow optional extensions to depend on other optional extensions in the same add-on.
Signed-off-by: ricekot github@ricekot.com