mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 20:12:14 +00:00
Allow detached plugin location to be overridden (#7303)
obtain detatched plugin location via a method that can be overridden
This commit is contained in:
1 parent
2f239fbd4c
commit
79c6043298
1 file changed
+13
-4
@@ -617,7 +617,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
return;
|
||||
}
|
||||
LOGGER.fine(() -> "considering loading a detached dependency " + shortName);
|
||||
for (String loadedFile : loadPluginsFromWar("/WEB-INF/detached-plugins", (dir, name) -> normalisePluginName(name).equals(shortName))) {
|
||||
for (String loadedFile : loadPluginsFromWar(getDetachedLocation(), (dir, name) -> normalisePluginName(name).equals(shortName))) {
|
||||
String loaded = normalisePluginName(loadedFile);
|
||||
File arc = new File(rootDir, loaded + ".jpi");
|
||||
LOGGER.info(() -> "Loading a detached plugin as a dependency: " + arc);
|
||||
@@ -630,6 +630,15 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the location of the detached plugins in the WAR.
|
||||
* @return by default, {@code /WEB-INF/detached-plugins}
|
||||
* @since TODO
|
||||
*/
|
||||
protected @NonNull String getDetachedLocation() {
|
||||
return "/WEB-INF/detached-plugins";
|
||||
}
|
||||
|
||||
protected @NonNull Set<String> loadPluginsFromWar(@NonNull String fromPath) {
|
||||
return loadPluginsFromWar(fromPath, null);
|
||||
}
|
||||
@@ -758,7 +767,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
|
||||
final List<DetachedPluginsUtil.DetachedPlugin> detachedPlugins = DetachedPluginsUtil.getDetachedPlugins(lastExecVersion);
|
||||
|
||||
Set<String> loadedDetached = loadPluginsFromWar("/WEB-INF/detached-plugins", new FilenameFilter() {
|
||||
Set<String> loadedDetached = loadPluginsFromWar(getDetachedLocation(), new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
name = normalisePluginName(name);
|
||||
@@ -793,7 +802,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
new Object[] {lastExecVersion, Jenkins.VERSION, loadedDetached});
|
||||
} else {
|
||||
final Set<DetachedPluginsUtil.DetachedPlugin> forceUpgrade = new HashSet<>();
|
||||
// TODO using getDetachedPlugins here seems wrong; should be forcing an upgrade when the installed version is older than that in WEB-INF/detached-plugins/
|
||||
// TODO using getDetachedPlugins here seems wrong; should be forcing an upgrade when the installed version is older than that in getDetachedLocation()
|
||||
for (DetachedPluginsUtil.DetachedPlugin p : DetachedPluginsUtil.getDetachedPlugins()) {
|
||||
VersionNumber installedVersion = getPluginVersion(rootDir, p.getShortName());
|
||||
VersionNumber requiredVersion = p.getRequiredVersion();
|
||||
@@ -805,7 +814,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
}
|
||||
}
|
||||
if (!forceUpgrade.isEmpty()) {
|
||||
Set<String> loadedDetached = loadPluginsFromWar("/WEB-INF/detached-plugins", new FilenameFilter() {
|
||||
Set<String> loadedDetached = loadPluginsFromWar(getDetachedLocation(), new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
name = normalisePluginName(name);
|
||||
|
||||
Reference in new issue
Block a user