mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
to support exclusions in MavenModule, pushed up isApplicable to ItemDescriptor from TopLevelItemDescriptor
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16742 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
40a050dab6
commit
0c5ed03dfd
6 files changed
+49
-26
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package hudson.model;
|
||||
|
||||
/**
|
||||
* {@link Descriptor} for {@link Item}s.
|
||||
*
|
||||
* <p>
|
||||
* Historically, {@link TopLevelItemDescriptor} came into being first, so this descriptor is parametered
|
||||
* to retain that signature identical.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 1.296
|
||||
*/
|
||||
public abstract class ItemDescriptor<T extends Item&Describable<T>> extends Descriptor<T> {
|
||||
protected ItemDescriptor(Class<? extends T> clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
|
||||
protected ItemDescriptor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ItemDescriptor}s often uses other descriptors to decorate itself.
|
||||
* This method allows the subtype of {@link ItemDescriptor}s to filter them out.
|
||||
*
|
||||
* <p>
|
||||
* This is useful for a workflow/company specific job type that wants to eliminate
|
||||
* options that the user would see.
|
||||
*/
|
||||
public boolean isApplicable(Descriptor descriptor) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import hudson.tasks.BuildStepDescriptor;
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class TopLevelItemDescriptor extends Descriptor<TopLevelItem> {
|
||||
public abstract class TopLevelItemDescriptor extends ItemDescriptor<TopLevelItem> {
|
||||
protected TopLevelItemDescriptor(Class<? extends TopLevelItem> clazz) {
|
||||
super(clazz);
|
||||
}
|
||||
@@ -50,20 +50,6 @@ public abstract class TopLevelItemDescriptor extends Descriptor<TopLevelItem> {
|
||||
protected TopLevelItemDescriptor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link TopLevelItemDescriptor}s often uses other descriptors to decorate itself.
|
||||
* This method allows the subtype of {@link TopLevelItemDescriptor}s to filter them out.
|
||||
*
|
||||
* <p>
|
||||
* This is useful for a workflow/company specific job type that wants to eliminate
|
||||
* options that the user would see.
|
||||
*
|
||||
* @since 1.294
|
||||
*/
|
||||
public boolean isApplicable(Descriptor descriptor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
||||
@@ -40,6 +40,7 @@ import hudson.model.Node;
|
||||
import hudson.model.WorkspaceCleanupThread;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.ItemDescriptor;
|
||||
import hudson.model.AbstractProject.AbstractProjectDescriptor;
|
||||
|
||||
import java.io.File;
|
||||
@@ -377,9 +378,9 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint {
|
||||
for (SCMDescriptor<?> scmDescriptor : all()) {
|
||||
if(!scmDescriptor.isApplicable(project)) continue;
|
||||
|
||||
if (pd instanceof AbstractProjectDescriptor) {
|
||||
AbstractProjectDescriptor apd = (AbstractProjectDescriptor) pd;
|
||||
if(!apd.isApplicable(scmDescriptor)) continue;
|
||||
if (pd instanceof ItemDescriptor) {
|
||||
ItemDescriptor id = (ItemDescriptor) pd;
|
||||
if(!id.isApplicable(scmDescriptor)) continue;
|
||||
}
|
||||
|
||||
r.add(scmDescriptor);
|
||||
|
||||
@@ -27,6 +27,7 @@ import hudson.model.Describable;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.ItemDescriptor;
|
||||
import hudson.model.AbstractProject.AbstractProjectDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
@@ -61,7 +62,7 @@ public abstract class BuildStepDescriptor<T extends BuildStep & Describable<T>>
|
||||
*
|
||||
* @return
|
||||
* true to allow user to configure this post-promotion task for the given project.
|
||||
* @see AbstractProjectDescriptor#isApplicable(Descriptor)
|
||||
* @see AbstractProjectDescriptor#isApplicable(Descriptor)
|
||||
*/
|
||||
public abstract boolean isApplicable(Class<? extends AbstractProject> jobType);
|
||||
|
||||
@@ -76,7 +77,7 @@ public abstract class BuildStepDescriptor<T extends BuildStep & Describable<T>>
|
||||
|
||||
List<Descriptor<T>> r = new ArrayList<Descriptor<T>>(base.size());
|
||||
for (Descriptor<T> d : base) {
|
||||
if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor)pd).isApplicable(d))
|
||||
if (pd instanceof ItemDescriptor && !((ItemDescriptor)pd).isApplicable(d))
|
||||
continue;
|
||||
|
||||
if (d instanceof BuildStepDescriptor) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package hudson.tasks;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.ItemDescriptor;
|
||||
import hudson.model.AbstractProject.AbstractProjectDescriptor;
|
||||
import hudson.Extension;
|
||||
import hudson.util.DescriptorList;
|
||||
@@ -58,7 +59,7 @@ public class BuildWrappers {
|
||||
Descriptor pd = Hudson.getInstance().getDescriptor((Class)project.getClass());
|
||||
|
||||
for (Descriptor<BuildWrapper> w : BuildWrapper.all()) {
|
||||
if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor)pd).isApplicable(w))
|
||||
if (pd instanceof ItemDescriptor && !((ItemDescriptor)pd).isApplicable(w))
|
||||
continue;
|
||||
if (w instanceof BuildWrapperDescriptor) {
|
||||
BuildWrapperDescriptor bwd = (BuildWrapperDescriptor) w;
|
||||
|
||||
@@ -40,6 +40,8 @@ import hudson.model.Project;
|
||||
import hudson.model.PeriodicWork;
|
||||
import hudson.model.TopLevelItem;
|
||||
import hudson.model.TopLevelItemDescriptor;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.ItemDescriptor;
|
||||
import hudson.scheduler.CronTab;
|
||||
import hudson.scheduler.CronTabList;
|
||||
import hudson.util.DoubleLaunchChecker;
|
||||
@@ -270,15 +272,15 @@ public abstract class Trigger<J extends Item> implements Describable<Trigger<?>>
|
||||
* Returns a subset of {@link TriggerDescriptor}s that applys to the given item.
|
||||
*/
|
||||
public static List<TriggerDescriptor> for_(Item i) {
|
||||
Descriptor pd = Hudson.getInstance().getDescriptor((Class)i.getClass());
|
||||
|
||||
List<TriggerDescriptor> r = new ArrayList<TriggerDescriptor>();
|
||||
for (TriggerDescriptor t : all()) {
|
||||
if(!t.isApplicable(i)) continue;
|
||||
|
||||
if (i instanceof TopLevelItem) {// ugly
|
||||
TopLevelItemDescriptor tld = ((TopLevelItem) i).getDescriptor();
|
||||
// tld shouldn't be really null in contract, but we often write test Describables that
|
||||
// doesn't have a Descriptor.
|
||||
if(tld!=null && !tld.isApplicable(t)) continue;
|
||||
if (pd instanceof ItemDescriptor) {// ugly
|
||||
ItemDescriptor tld = (ItemDescriptor) pd;
|
||||
if(!tld.isApplicable(t)) continue;
|
||||
}
|
||||
|
||||
r.add(t);
|
||||
|
||||
Reference in new issue
Block a user