mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-30 13:05:19 +00:00
refactoring BuildStep so that it can be used for other project types.
This is so far done in a way that maintains the binary/source compatibility with old plugins. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@5546 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
c4156324ef
commit
5d1ea5c523
9 files changed
+150
-12
No files matched your search
@@ -1,7 +1,10 @@
|
||||
package hudson;
|
||||
|
||||
import hudson.maven.ExecutedMojo;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Action;
|
||||
import hudson.model.Describable;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.Item;
|
||||
import hudson.model.ItemGroup;
|
||||
@@ -15,6 +18,10 @@ import hudson.model.Run;
|
||||
import hudson.model.TopLevelItem;
|
||||
import hudson.model.View;
|
||||
import hudson.search.SearchableModelObject;
|
||||
import hudson.tasks.BuildStep;
|
||||
import hudson.tasks.BuildStepDescriptor;
|
||||
import hudson.tasks.Builder;
|
||||
import hudson.tasks.Publisher;
|
||||
import org.apache.commons.jexl.parser.ASTSizeFunction;
|
||||
import org.apache.commons.jexl.util.Introspector;
|
||||
import org.kohsuke.stapler.Ancestor;
|
||||
@@ -37,6 +44,7 @@ import java.lang.management.ThreadInfo;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -429,6 +437,31 @@ public class Functions {
|
||||
return JobPropertyDescriptor.getPropertyDescriptors(clazz);
|
||||
}
|
||||
|
||||
public static List<Descriptor<Builder>> getBuilderDescriptors(AbstractProject<?,?> project) {
|
||||
return filterBuildStepDescriptors(BuildStep.BUILDERS,project);
|
||||
}
|
||||
|
||||
public static List<Descriptor<Publisher>> getPublisherDescriptors(AbstractProject<?,?> project) {
|
||||
return filterBuildStepDescriptors(BuildStep.PUBLISHERS,project);
|
||||
}
|
||||
|
||||
private static <T extends BuildStep&Describable<T>> List<Descriptor<T>> filterBuildStepDescriptors(List<Descriptor<T>> list,AbstractProject<?,?> project) {
|
||||
List<Descriptor<T>> result = new ArrayList<Descriptor<T>>();
|
||||
for (Descriptor<T> b : list) {
|
||||
if (b instanceof BuildStepDescriptor) {
|
||||
BuildStepDescriptor bsd = (BuildStepDescriptor) b;
|
||||
if(bsd.isApplicable(project))
|
||||
result.add(b);
|
||||
} else {
|
||||
// old plugins built before 1.150 may not implement BuildStepDescriptor
|
||||
if(project instanceof Project) {
|
||||
result.add(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the path to the icon of the given action
|
||||
* from the context path.
|
||||
|
||||
Reference in new issue
Block a user