提交 7e93f894 编写于 作者: K kohsuke

rolling back 16742 and 16743. we don't allow publisher configuration at MavenModule anyway

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16744 71c3de6d-444a-0410-be80-ed276b4c234a
上级 143bdbda
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 ItemDescriptor<TopLevelItem> {
public abstract class TopLevelItemDescriptor extends Descriptor<TopLevelItem> {
protected TopLevelItemDescriptor(Class<? extends TopLevelItem> clazz) {
super(clazz);
}
......@@ -50,6 +50,20 @@ public abstract class TopLevelItemDescriptor extends ItemDescriptor<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,7 +40,6 @@ 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;
......@@ -378,9 +377,9 @@ public abstract class SCM implements Describable<SCM>, ExtensionPoint {
for (SCMDescriptor<?> scmDescriptor : all()) {
if(!scmDescriptor.isApplicable(project)) continue;
if (pd instanceof ItemDescriptor) {
ItemDescriptor id = (ItemDescriptor) pd;
if(!id.isApplicable(scmDescriptor)) continue;
if (pd instanceof AbstractProjectDescriptor) {
AbstractProjectDescriptor apd = (AbstractProjectDescriptor) pd;
if(!apd.isApplicable(scmDescriptor)) continue;
}
r.add(scmDescriptor);
......
......@@ -27,7 +27,6 @@ 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;
......@@ -62,7 +61,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);
......@@ -77,7 +76,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 ItemDescriptor && !((ItemDescriptor)pd).isApplicable(d))
if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor)pd).isApplicable(d))
continue;
if (d instanceof BuildStepDescriptor) {
......
......@@ -26,7 +26,6 @@ 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;
......@@ -59,7 +58,7 @@ public class BuildWrappers {
Descriptor pd = Hudson.getInstance().getDescriptor((Class)project.getClass());
for (Descriptor<BuildWrapper> w : BuildWrapper.all()) {
if (pd instanceof ItemDescriptor && !((ItemDescriptor)pd).isApplicable(w))
if (pd instanceof AbstractProjectDescriptor && !((AbstractProjectDescriptor)pd).isApplicable(w))
continue;
if (w instanceof BuildWrapperDescriptor) {
BuildWrapperDescriptor bwd = (BuildWrapperDescriptor) w;
......
......@@ -40,8 +40,6 @@ 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;
......@@ -272,15 +270,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 (pd instanceof ItemDescriptor) {// ugly
ItemDescriptor tld = (ItemDescriptor) pd;
if(!tld.isApplicable(t)) 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;
}
r.add(t);
......
......@@ -58,7 +58,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>${maven.version}</version>
<version>${maven.embedder.version}</version>
<!--exclusions> These are needed for Maven embedder to resolve parent POMs in remote repositories
<exclusion>
<groupId>org.apache.maven.wagon</groupId>
......@@ -81,7 +81,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0.9</version>
<version>${maven.version}</version>
<exclusions>
<exclusion><!-- we'll add our own patched version. see http://www.nabble.com/Issue-1680-td18383889.html -->
<groupId>jtidy</groupId>
......
......@@ -42,8 +42,6 @@ import hudson.model.Label;
import hudson.model.Node;
import hudson.model.Resource;
import hudson.model.Saveable;
import hudson.model.ItemDescriptor;
import hudson.model.Describable;
import hudson.tasks.LogRotator;
import hudson.tasks.Publisher;
import hudson.tasks.Maven.MavenInstallation;
......@@ -68,7 +66,7 @@ import org.kohsuke.stapler.export.Exported;
*
* @author Kohsuke Kawaguchi
*/
public final class MavenModule extends AbstractMavenProject<MavenModule,MavenBuild> implements Saveable, Describable<MavenModule> {
public final class MavenModule extends AbstractMavenProject<MavenModule,MavenBuild> implements Saveable {
private DescribableList<MavenReporter,Descriptor<MavenReporter>> reporters =
new DescribableList<MavenReporter,Descriptor<MavenReporter>>(this);
......@@ -449,22 +447,4 @@ public final class MavenModule extends AbstractMavenProject<MavenModule,MavenBui
return reporters;
}
public DescriptorImpl getDescriptor() {
return (DescriptorImpl)Hudson.getInstance().getDescriptor(getClass());
}
public static class DescriptorImpl extends ItemDescriptor<MavenModule> {
public String getDisplayName() {
return null; // never used
}
/**
* Do the same exclusion as {@link MavenModuleSet} does.
*/
@Override
public boolean isApplicable(Descriptor descriptor) {
return Hudson.getInstance().getDescriptorByType(MavenModuleSet.DescriptorImpl.class).isApplicable(descriptor);
}
}
}
......@@ -184,7 +184,8 @@ THE SOFTWARE.
</dependencies>
<properties>
<maven.version>2.0.4</maven.version>
<maven.version>2.0.9</maven.version>
<maven.embedder.version>2.0.4</maven.embedder.version>
</properties>
<profiles>
......
......@@ -63,7 +63,7 @@ public class MavenProjectTest extends HudsonTestCase {
* This is to make sure that the exclusion in {@link MavenModuleSet.DescriptorImpl#isApplicable(Descriptor)}
* is working.
*/
public void testConfig() throws Exception {
public void testExclusion() throws Exception {
MavenModuleSet p = createMavenProject();
HtmlPage page = new WebClient().getPage(p, "configure");
assertFalse(page.getWebResponse().getContentAsString().contains(hudson.getDescriptorByType(ArtifactArchiver.DescriptorImpl.class).getDisplayName()));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册