Skip to content
Permalink
Browse files

[JENKINS-21486] Refactoring

  • Loading branch information...
Vlatombe committed Jul 28, 2016
1 parent 43ddbdf commit 646969b690797bb289a558104109ec1fc92b38cf
Showing with 20 additions and 13 deletions.
  1. +20 −13 core/src/main/java/hudson/PluginWrapper.java
@@ -28,7 +28,6 @@
import hudson.PluginManager.PluginInstanceStore;
import hudson.model.Api;
import hudson.model.ModelObject;
import jenkins.MissingDependencyException;
import jenkins.YesNoMaybe;
import jenkins.model.Jenkins;
import hudson.model.UpdateCenter;
@@ -550,26 +549,24 @@ public boolean hasLicensesXml() {
if (requiredCoreVersion == null) {
LOGGER.warning(shortName + " doesn't declare required core version.");
} else {
if (Jenkins.getVersion().isOlderThan(new VersionNumber(requiredCoreVersion))) {
throw new IOException(shortName + " requires a more recent core version (" + requiredCoreVersion + ") than the current (" + Jenkins.getVersion() + ").");
}
checkRequiredCoreVersion(requiredCoreVersion);
}
}
List<String> missingDependencies = new ArrayList<String>();
List<String> obsoleteDependencies = new ArrayList<String>();
List<String> disabledDependencies = new ArrayList<String>();
List<Dependency> missingDependencies = new ArrayList<>();
List<Dependency> obsoleteDependencies = new ArrayList<>();
List<Dependency> disabledDependencies = new ArrayList<>();
// make sure dependencies exist
for (Dependency d : dependencies) {
PluginWrapper dependency = parent.getPlugin(d.shortName);
if (dependency == null) {
missingDependencies.add(d.toString());
missingDependencies.add(d);
} else {
if (dependency.isActive()) {
if (ENABLE_PLUGIN_DEPENDENCIES_VERSION_CHECK && dependency.getVersionNumber().isOlderThan(new VersionNumber(d.version))) {
obsoleteDependencies.add(dependency.getShortName() + "(" + dependency.getVersion() + " < " + d.version + ")");
if (isDependencyObsolete(d, dependency)) {
obsoleteDependencies.add(d);
}
} else {
disabledDependencies.add(d.toString());
disabledDependencies.add(d);
}

}
@@ -578,8 +575,8 @@ public boolean hasLicensesXml() {
for (Dependency d : optionalDependencies) {
PluginWrapper dependency = parent.getPlugin(d.shortName);
if (dependency != null && dependency.isActive()) {
if (ENABLE_PLUGIN_DEPENDENCIES_VERSION_CHECK && dependency.getVersionNumber().isOlderThan(new VersionNumber(d.version))) {
obsoleteDependencies.add(dependency.getShortName() + "(" + dependency.getVersion() + " < " + d.version + ")");
if (isDependencyObsolete(d, dependency)) {
obsoleteDependencies.add(d);
} else {
dependencies.add(d);
}
@@ -613,6 +610,16 @@ public boolean hasLicensesXml() {
}
}

private void checkRequiredCoreVersion(String requiredCoreVersion) throws IOException {
if (Jenkins.getVersion().isOlderThan(new VersionNumber(requiredCoreVersion))) {
throw new IOException(shortName + " requires a more recent core version (" + requiredCoreVersion + ") than the current (" + Jenkins.getVersion() + ").");
}
}

private boolean isDependencyObsolete(Dependency d, PluginWrapper dependency) {
return ENABLE_PLUGIN_DEPENDENCIES_VERSION_CHECK && dependency.getVersionNumber().isOlderThan(new VersionNumber(d.version));
}

/**
* If the plugin has {@link #getUpdateInfo() an update},
* returns the {@link hudson.model.UpdateSite.Plugin} object.

0 comments on commit 646969b

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