Package org.gradle.testfixtures
Class ProjectBuilder
- java.lang.Object
-
- org.gradle.testfixtures.ProjectBuilder
-
public class ProjectBuilder extends java.lang.ObjectCreates dummy instances of
Projectwhich you can use in testing custom task and plugin implementations.To create a project instance:
- Create a
ProjectBuilderinstance by callingbuilder(). - Optionally, configure the builder.
- Call
build()to create theProjectinstance.
You can reuse a builder to create multiple
Projectinstances.The
ProjectBuilderimplementation bundled with Gradle 3.0 and 3.1 suffers from a binary compatibility issue exposed by applying plugins compiled with Gradle 2.7 and earlier. Applying those pre-compiled plugins in a ProjectBuilder context will result in aClassNotFoundException. - Create a
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Projectbuild()Creates the project.static ProjectBuilderbuilder()Creates a project builder.ProjectBuilderwithGradleUserHomeDir(java.io.File dir)Specifies the Gradle user home for the builder.ProjectBuilderwithName(java.lang.String name)Specifies the name for the projectProjectBuilderwithParent(Project parent)Specifies the parent project.ProjectBuilderwithProjectDir(java.io.File dir)Specifies the project directory for the project to build.
-
-
-
Method Detail
-
builder
public static ProjectBuilder builder()
Creates a project builder.- Returns:
- The builder
-
withProjectDir
public ProjectBuilder withProjectDir(@Nullable java.io.File dir)
Specifies the project directory for the project to build.- Parameters:
dir- The project directory- Returns:
- The builder
-
withGradleUserHomeDir
public ProjectBuilder withGradleUserHomeDir(@Nullable java.io.File dir)
Specifies the Gradle user home for the builder. If not set, an empty directory under the project directory will be used.- Returns:
- The builder
-
withName
public ProjectBuilder withName(java.lang.String name)
Specifies the name for the project- Parameters:
name- project name- Returns:
- The builder
-
withParent
public ProjectBuilder withParent(@Nullable Project parent)
Specifies the parent project. Use it to create multi-module projects.- Parameters:
parent- parent project- Returns:
- The builder
-
build
public Project build()
Creates the project.- Returns:
- The project
-
-