提交 072556e8 编写于 作者: K Kohsuke Kawaguchi

allowing TopLevelItems to be used under ItemGroups other than Hudson.

上级 4207cf93
......@@ -61,7 +61,7 @@ THE SOFTWARE.
<plugin>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-injector</artifactId>
<version>1.3</version>
<version>1.4</version>
<executions>
<execution>
<goals>
......@@ -410,7 +410,7 @@ THE SOFTWARE.
<dependency>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-annotation</artifactId>
<version>1.2</version>
<version>1.4</version>
</dependency>
<dependency><!-- until we get this version through Stapler -->
......
......@@ -151,7 +151,11 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
private String customWorkspace;
public MatrixProject(String name) {
super(Hudson.getInstance(), name);
this(Hudson.getInstance(), name);
}
public MatrixProject(ItemGroup parent, String name) {
super(parent, name);
}
public AxisList getAxes() {
......@@ -471,11 +475,6 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
return f;
}
@Override
public Hudson getParent() {
return Hudson.getInstance();
}
/**
* @see #getJDKs()
*/
......
......@@ -24,6 +24,7 @@
*/
package hudson.model;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import hudson.XmlFile;
import hudson.Util;
import hudson.Functions;
......@@ -115,6 +116,10 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
return parent.getRootDirFor(this);
}
/**
* This bridge method is to maintain binary compatibility with {@link TopLevelItem#getParent()}.
*/
@WithBridgeMethods(value=Hudson.class,castRequired=true)
public ItemGroup getParent() {
assert parent!=null;
return parent;
......
......@@ -42,12 +42,11 @@ import java.io.IOException;
*/
public class ExternalJob extends ViewJob<ExternalJob,ExternalRun> implements TopLevelItem {
public ExternalJob(String name) {
super(Hudson.getInstance(),name);
this(Hudson.getInstance(),name);
}
@Override
public Hudson getParent() {
return (Hudson)super.getParent();
public ExternalJob(ItemGroup parent, String name) {
super(parent,name);
}
@Override
......
......@@ -46,18 +46,20 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i
*/
private String customWorkspace;
/**
* @deprecated as of 1.390
*/
public FreeStyleProject(Hudson parent, String name) {
super(parent, name);
}
@Override
protected Class<FreeStyleBuild> getBuildClass() {
return FreeStyleBuild.class;
public FreeStyleProject(ItemGroup parent, String name) {
super(parent, name);
}
@Override
public Hudson getParent() {
return Hudson.getInstance();
protected Class<FreeStyleBuild> getBuildClass() {
return FreeStyleBuild.class;
}
public String getCustomWorkspace() {
......
......@@ -23,8 +23,8 @@
*/
package hudson.model;
import hudson.ExtensionPoint;
import hudson.Extension;
import hudson.ExtensionPoint;
/**
* {@link Item} that can be directly displayed under {@link Hudson}.
......@@ -36,11 +36,6 @@ import hudson.Extension;
* @author Kohsuke Kawaguchi
*/
public interface TopLevelItem extends Item, ExtensionPoint, Describable<TopLevelItem> {
/**
* By definition the parent of the top-level item is always {@link Hudson}.
*/
Hudson getParent();
/**
*
* @see Describable#getDescriptor()
......
......@@ -76,10 +76,17 @@ public abstract class ViewJob<JobT extends ViewJob<JobT,RunT>, RunT extends Run<
reloadThread.start();
}
/**
* @deprecated as of 1.390
*/
protected ViewJob(Hudson parent, String name) {
super(parent,name);
}
protected ViewJob(ItemGroup parent, String name) {
super(parent,name);
}
public boolean isBuildable() {
return false;
}
......
......@@ -225,6 +225,10 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
new DescribableList<BuildWrapper, Descriptor<BuildWrapper>>(this);
public MavenModuleSet(String name) {
this(Hudson.getInstance(),name);
}
public MavenModuleSet(ItemGroup parent, String name) {
super(Hudson.getInstance(),name);
}
......@@ -233,10 +237,6 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
return ".";
}
public Hudson getParent() {
return Hudson.getInstance();
}
public Collection<MavenModule> getItems() {
return modules.values();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册