ProjectBuilder (Gradle API 8.14)
Description: declaration: package: org.gradle.testfixtures, class: ProjectBuilder

Package org.gradle.testfixtures

# Class ProjectBuilder

java.lang.Object
org.gradle.testfixtures.ProjectBuilder

public class ProjectBuilder extends Object

Creates dummy instances of `Project` which you can use in testing custom task and plugin implementations.

To create a project instance:

1. Create a `ProjectBuilder` instance by calling `builder()`.
2. Optionally, configure the builder.
3. Call `build()` to create the `Project` instance.

You can reuse a builder to create multiple `Project` instances.

The `ProjectBuilder` implementation 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 a `ClassNotFoundException`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Project`
  `build()`
  Creates the project.
  `static ProjectBuilder`
  `builder()`
  Creates a project builder.
  `ProjectBuilder`
  `withGradleUserHomeDir(File dir)`
  Specifies the Gradle user home for the builder.
  `ProjectBuilder`
  `withName(String name)`
  Specifies the name for the project
  `ProjectBuilder`
  `withParent(Project parent)`
  Specifies the parent project.
  `ProjectBuilder`
  `withProjectDir(File dir)`
  Specifies the project directory for the project to build.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### builder

    public static ProjectBuilder builder()
    Creates a project builder.
    Returns:
      The builder

  - ### withProjectDir

    public ProjectBuilder withProjectDir(@Nullable File dir)
    Specifies the project directory for the project to build.
    Parameters:
      `dir` - The project directory
    Returns:
      The builder

  - ### withGradleUserHomeDir

    public ProjectBuilder withGradleUserHomeDir(@Nullable 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(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