Skip to content

Commit

Permalink
Make extended plugins optional
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Oct 15, 2024
1 parent b5dcde3 commit 44154b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ public class PluginPropertiesExtension {

private String customFolderName = "";

/** Other plugins this plugin extends through SPI */
/** Other plugins this plugin extends through SPI, these plugins are required to install this plugin */
private List<String> extendedPlugins = new ArrayList<>();

/** Other plugins this plugin extends through SPI, these plugins are not required for install */
private List<String> optionalExtendedPlugins = new ArrayList<>();

private boolean hasNativeController;

/** True if the plugin requires the opensearch keystore to exist, false otherwise. */
Expand Down Expand Up @@ -122,6 +125,10 @@ public List<String> getExtendedPlugins() {
return this.extendedPlugins;
}

public List<String> getOptionalExtendedPlugins() {
return this.optionalExtendedPlugins;
}

public boolean isHasNativeController() {
return hasNativeController;
}
Expand Down Expand Up @@ -164,6 +171,10 @@ public void setExtendedPlugins(List<String> extendedPlugins) {
this.extendedPlugins = extendedPlugins;
}

public void setOptionalExtendedPlugins(List<String> optionalExtendedPlugins) {
this.optionalExtendedPlugins = optionalExtendedPlugins;
}

public boolean isHasClientJar() {
return hasClientJar;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ private static void addSortedBundle(
for (String dependency : bundle.plugin.getExtendedPlugins()) {
Bundle depBundle = bundles.get(dependency);
if (depBundle == null) {
throw new IllegalArgumentException("Missing plugin [" + dependency + "], dependency of [" + name + "]");
continue;
// throw new IllegalArgumentException("Missing plugin [" + dependency + "], dependency of [" + name + "]");
}
addSortedBundle(depBundle, bundles, sortedBundles, dependencyStack);
assert sortedBundles.contains(depBundle);
Expand Down Expand Up @@ -653,7 +654,9 @@ static void checkBundleJarHell(Set<URL> classpath, Bundle bundle, Map<String, Se
Set<URL> urls = new HashSet<>();
for (String extendedPlugin : exts) {
Set<URL> pluginUrls = transitiveUrls.get(extendedPlugin);
assert pluginUrls != null : "transitive urls should have already been set for " + extendedPlugin;
if (pluginUrls == null) {
continue;
}

Set<URL> intersection = new HashSet<>(urls);
intersection.retainAll(pluginUrls);
Expand Down Expand Up @@ -690,6 +693,7 @@ static void checkBundleJarHell(Set<URL> classpath, Bundle bundle, Map<String, Se
union.addAll(bundle.urls);
JarHell.checkJarHell(union, logger::debug);
} catch (Exception e) {
e.printStackTrace();
throw new IllegalStateException("failed to load plugin " + bundle.plugin.getName() + " due to jar hell", e);
}
}
Expand Down

0 comments on commit 44154b5

Please sign in to comment.