提交 5adf3997 编写于 作者: K kohsuke

introduced another convenience method.

See http://www.nabble.com/No-arg-Descriptor-constructor-td22154193.html

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15773 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e74ac2c7
......@@ -1654,6 +1654,19 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
return item;
}
/**
* Creates a new job.
*
* <p>
* This version infers the descriptor from the type of the top-level item.
*
* @throws IllegalArgumentException
* if the project of the given name already exists.
*/
public synchronized <T extends TopLevelItem> T createProject( Class<T> type, String name ) throws IOException {
return type.cast(createProject((TopLevelItemDescriptor)getDescriptor(type),name));
}
/**
* Called in response to {@link Job#doDoDelete(StaplerRequest, StaplerResponse)}
*/
......
......@@ -356,7 +356,7 @@ public abstract class HudsonTestCase extends TestCase {
}
protected FreeStyleProject createFreeStyleProject(String name) throws IOException {
return (FreeStyleProject)hudson.createProject(FreeStyleProject.DESCRIPTOR,name);
return hudson.createProject(FreeStyleProject.class,name);
}
protected MatrixProject createMatrixProject() throws IOException {
......@@ -364,7 +364,7 @@ public abstract class HudsonTestCase extends TestCase {
}
protected MatrixProject createMatrixProject(String name) throws IOException {
return (MatrixProject)hudson.createProject(MatrixProject.DESCRIPTOR,name);
return hudson.createProject(MatrixProject.class,name);
}
/**
......@@ -382,7 +382,7 @@ public abstract class HudsonTestCase extends TestCase {
* @see #configureDefaultMaven()
*/
protected MavenModuleSet createMavenProject(String name) throws IOException {
return (MavenModuleSet)hudson.createProject(MavenModuleSet.DESCRIPTOR,name);
return hudson.createProject(MavenModuleSet.class,name);
}
private String createUniqueProjectName() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册