mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-04 07:35:53 +00:00
Add dependency resolution to manually uploaded plugins.
This commit is contained in:
1 parent
1fe9cf7b7a
commit
fcdebe56c0
7 files changed
+156
-1
No files matched your search
@@ -62,6 +62,7 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jenkinsci.bytecode.Transformer;
|
||||
import org.jvnet.hudson.reactor.Executable;
|
||||
@@ -1298,12 +1299,33 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
|
||||
|
||||
pluginUploaded = true;
|
||||
|
||||
JSONArray dependencies = new JSONArray();
|
||||
try {
|
||||
Manifest m = new JarFile(t).getManifest();
|
||||
String deps = m.getMainAttributes().getValue("Plugin-Dependencies");
|
||||
|
||||
if (StringUtils.isNotBlank(deps)) {
|
||||
// now we get to parse it!
|
||||
String[] plugins = deps.split(",");
|
||||
for (String p : plugins) {
|
||||
// should have name:version[;resolution:=optional]
|
||||
String[] attrs = p.split("[:;]");
|
||||
dependencies.add(new JSONObject()
|
||||
.element("name", attrs[0])
|
||||
.element("version", attrs[1])
|
||||
.element("optional", p.contains("resolution:=optional")));
|
||||
}
|
||||
}
|
||||
} catch(IOException e) {
|
||||
LOGGER.log(WARNING, "Unable to setup dependency list for plugin upload", e);
|
||||
}
|
||||
|
||||
// Now create a dummy plugin that we can dynamically load (the InstallationJob will force a restart if one is needed):
|
||||
JSONObject cfg = new JSONObject().
|
||||
element("name", baseName).
|
||||
element("version", "0"). // unused but mandatory
|
||||
element("url", t.toURI().toString()).
|
||||
element("dependencies", new JSONArray());
|
||||
element("dependencies", dependencies);
|
||||
new UpdateSite(UpdateCenter.ID_UPLOAD, null).new Plugin(UpdateCenter.ID_UPLOAD, cfg).deploy(true);
|
||||
return new HttpRedirect("../updateCenter");
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in new issue
Block a user