Skip to content
Permalink
Browse files

[FIXED JENKINS-19736] Installing a plugin with optional dependencies …

…doesn't upgrade the optional dependencies when needed
  • Loading branch information...
stephenc committed Sep 25, 2013
1 parent 0ab7988 commit 01d5fbc2e06d76db1501ad3e24691c2643a9acd7
Showing with 28 additions and 3 deletions.
  1. +28 −3 core/src/main/java/hudson/model/UpdateSite.java
@@ -597,6 +597,12 @@ public Api getApi() {
@Exported
public final Map<String,String> dependencies = new HashMap<String,String>();

/**
* Optional dependencies of this plugin.
*/
@Exported
public final Map<String,String> optionalDependencies = new HashMap<String,String>();

@DataBoundConstructor
public Plugin(String sourceId, JSONObject o) {
super(sourceId, o, UpdateSite.this.url);
@@ -611,9 +617,12 @@ public Plugin(String sourceId, JSONObject o) {
// Make sure there's a name attribute, that that name isn't maven-plugin - we ignore that one -
// and that the optional value isn't true.
if (get(depObj,"name")!=null
&& !get(depObj,"name").equals("maven-plugin")
&& get(depObj,"optional").equals("false")) {
dependencies.put(get(depObj,"name"), get(depObj,"version"));
&& !get(depObj,"name").equals("maven-plugin")) {
if (get(depObj, "optional").equals("false")) {
dependencies.put(get(depObj, "name"), get(depObj, "version"));
} else {
optionalDependencies.put(get(depObj, "name"), get(depObj, "version"));
}
}

}
@@ -691,6 +700,22 @@ else if (current.isOlderThan(requiredVersion)) {
}
}

for(Map.Entry<String,String> e : optionalDependencies.entrySet()) {
Plugin depPlugin = Jenkins.getInstance().getUpdateCenter().getPlugin(e.getKey());
if (depPlugin == null) {
continue;
}
VersionNumber requiredVersion = new VersionNumber(e.getValue());

PluginWrapper current = depPlugin.getInstalled();

// If the optional dependency plugin is installed, is the version we depend on newer than
// what's installed? If so, upgrade.
if (current != null && current.isOlderThan(requiredVersion)) {
deps.add(depPlugin);
}
}

return deps;
}

0 comments on commit 01d5fbc

Please sign in to comment.
You can’t perform that action at this time.