Search in sources :

Example 1 with AbstractProjectDescriptor

use of hudson.model.AbstractProject.AbstractProjectDescriptor in project hudson-2.x by hudson.

the class SCM method _for.

/**
     * Returns the list of {@link SCMDescriptor}s that are applicable to the given project.
     */
public static List<SCMDescriptor<?>> _for(final AbstractProject project) {
    if (project == null)
        return all();
    final Descriptor pd = Hudson.getInstance().getDescriptor((Class) project.getClass());
    List<SCMDescriptor<?>> r = new ArrayList<SCMDescriptor<?>>();
    for (SCMDescriptor<?> scmDescriptor : all()) {
        if (!scmDescriptor.isApplicable(project))
            continue;
        if (pd instanceof AbstractProjectDescriptor) {
            AbstractProjectDescriptor apd = (AbstractProjectDescriptor) pd;
            if (!apd.isApplicable(scmDescriptor))
                continue;
        }
        r.add(scmDescriptor);
    }
    return r;
}
Also used : ArrayList(java.util.ArrayList) Descriptor(hudson.model.Descriptor) AbstractProjectDescriptor(hudson.model.AbstractProject.AbstractProjectDescriptor) AbstractProjectDescriptor(hudson.model.AbstractProject.AbstractProjectDescriptor)

Example 2 with AbstractProjectDescriptor

use of hudson.model.AbstractProject.AbstractProjectDescriptor in project hudson-2.x by hudson.

the class BuildStepDescriptor method filter.

/**
     * Filters a descriptor for {@link BuildStep}s by using {@link BuildStepDescriptor#isApplicable(Class)}.
     */
public static <T extends BuildStep & Describable<T>> List<Descriptor<T>> filter(List<Descriptor<T>> base, Class<? extends AbstractProject> type) {
    // descriptor of the project
    Descriptor pd = Hudson.getInstance().getDescriptor((Class) type);
    List<Descriptor<T>> r = new ArrayList<Descriptor<T>>(base.size());
    for (Descriptor<T> d : base) {
        if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor) pd).isApplicable(d))
            continue;
        if (d instanceof BuildStepDescriptor) {
            BuildStepDescriptor<T> bd = (BuildStepDescriptor<T>) d;
            if (!bd.isApplicable(type))
                continue;
            r.add(bd);
        } else {
            // old plugins built before 1.150 may not implement BuildStepDescriptor
            r.add(d);
        }
    }
    return r;
}
Also used : ArrayList(java.util.ArrayList) Descriptor(hudson.model.Descriptor) AbstractProjectDescriptor(hudson.model.AbstractProject.AbstractProjectDescriptor) AbstractProjectDescriptor(hudson.model.AbstractProject.AbstractProjectDescriptor)

Example 3 with AbstractProjectDescriptor

use of hudson.model.AbstractProject.AbstractProjectDescriptor in project hudson-2.x by hudson.

the class BuildWrappers method getFor.

/**
     * List up all {@link BuildWrapperDescriptor}s that are applicable for the given project.
     *
     * @return
     *      The signature doesn't use {@link BuildWrapperDescriptor} to maintain compatibility
     *      with {@link BuildWrapper} implementations before 1.150.
     */
public static List<Descriptor<BuildWrapper>> getFor(AbstractProject<?, ?> project) {
    List<Descriptor<BuildWrapper>> result = new ArrayList<Descriptor<BuildWrapper>>();
    Descriptor pd = Hudson.getInstance().getDescriptor((Class) project.getClass());
    for (Descriptor<BuildWrapper> w : BuildWrapper.all()) {
        if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor) pd).isApplicable(w))
            continue;
        if (w instanceof BuildWrapperDescriptor) {
            BuildWrapperDescriptor bwd = (BuildWrapperDescriptor) w;
            if (bwd.isApplicable(project))
                result.add(bwd);
        } else {
            // old BuildWrapper that doesn't implement BuildWrapperDescriptor
            result.add(w);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Descriptor(hudson.model.Descriptor) AbstractProjectDescriptor(hudson.model.AbstractProject.AbstractProjectDescriptor) AbstractProjectDescriptor(hudson.model.AbstractProject.AbstractProjectDescriptor)

Aggregations

AbstractProjectDescriptor (hudson.model.AbstractProject.AbstractProjectDescriptor)3 Descriptor (hudson.model.Descriptor)3 ArrayList (java.util.ArrayList)3