Permalink
Browse files

Only use DependencyGroups

  • Loading branch information...
1 parent bd9daaf commit 747193696cd96d61e0fd74eec99e4348a8a21c9d @wolfs committed Nov 29, 2010
Showing with 3 additions and 40 deletions.
  1. +3 −40 src/main/java/hudson/plugins/depgraph_view/CalculateDeps.java
View
43 src/main/java/hudson/plugins/depgraph_view/CalculateDeps.java
@@ -6,12 +6,9 @@
import hudson.model.Hudson;
import hudson.model.Item;
-import java.lang.reflect.Field;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import java.util.logging.Level;
import java.util.logging.Logger;
public class CalculateDeps {
@@ -41,9 +38,9 @@ private void calculateNodesAndDependencies(Set<AbstractProject<?, ?>> fromProjec
for (AbstractProject<?,?> project : fromProjects) {
if (project.hasPermission(Item.READ)) {
newProj.addAll(
- addNewDependencies(getRealDependencies(depGraph.getUpstreamDependencies(project)),true));
+ addNewDependencies(depGraph.getUpstreamDependencies(project),true));
newProj.addAll(
- addNewDependencies(getRealDependencies(depGraph.getDownstreamDependencies(project)),false));
+ addNewDependencies(depGraph.getDownstreamDependencies(project),false));
}
}
visitedProj.addAll(newProj);
@@ -52,15 +49,7 @@ private void calculateNodesAndDependencies(Set<AbstractProject<?, ?>> fromProjec
}
}
- private Set<Dependency> getRealDependencies(Collection<Dependency> depGroups) {
- Set<Dependency> deps = new HashSet<Dependency>();
- for (Dependency dependency : depGroups) {
- deps.addAll(getDependenciesFromDepGroup(dependency));
- }
- return deps;
- }
-
- private Set<AbstractProject<?, ?>> addNewDependencies(Set<Dependency> dependencies, boolean isUpstream) {
+ private Set<AbstractProject<?, ?>> addNewDependencies(Collection<Dependency> dependencies, boolean isUpstream) {
Set<AbstractProject<?,?>> newProj = new HashSet<AbstractProject<?, ?>>();
for (Dependency dep : dependencies) {
AbstractProject<?,?> projectToAdd = isUpstream ? dep.getUpstreamProject() : dep.getDownstreamProject();
@@ -74,32 +63,6 @@ private void calculateNodesAndDependencies(Set<AbstractProject<?, ?>> fromProjec
return newProj;
}
- private Set<Dependency> getDependenciesFromDepGroup(Dependency dep) {
- Class<?>[] declaredClasses = DependencyGraph.class.getDeclaredClasses();
- Class<?> depGroup = null;
- for (Class<?> clazz : declaredClasses) {
- if (clazz.getName().endsWith("DependencyGroup")) {
- depGroup = clazz;
- break;
- }
- }
- if (depGroup == null) {
- LOGGER.log(Level.SEVERE,"Error extracting dependencies vom DependencyGroup");
- return Collections.singleton(dep);
- }
- try {
- Field declaredField = depGroup.getDeclaredField("group");
- declaredField.setAccessible(true);
- @SuppressWarnings("unchecked")
- Set<Dependency> subDeps = (Set<Dependency>) declaredField.get(dep);
- return subDeps;
- } catch (Exception e) {
- LOGGER.log(Level.SEVERE,"Error extracting dependencies vom DependencyGroup",e);
- return Collections.singleton(dep);
- }
- }
-
-
public Set<AbstractProject<?, ?>> getProjects() {
if (!calculated) {
calculateNodesAndDependencies();

0 comments on commit 7471936

Please sign in to comment.