api / org.gradle.testfixtures / ProjectBuilder

ProjectBuilder

open class ProjectBuilder

Creates dummy instances of org.gradle.api.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.

Constructors

<init>

ProjectBuilder()

Creates dummy instances of org.gradle.api.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.

Functions

build

open fun build(): Project

Creates the project.

builder

open static fun builder(): ProjectBuilder

Creates a project builder.

withGradleUserHomeDir

open fun withGradleUserHomeDir(dir: File): ProjectBuilder

Specifies the Gradle user home for the builder. If not set, an empty directory under the project directory will be used.

withName

open fun withName(name: String): ProjectBuilder

Specifies the name for the project

withParent

open fun withParent(parent: Project): ProjectBuilder

Specifies the parent project. Use it to create multi-module projects.

withProjectDir

open fun withProjectDir(dir: File): ProjectBuilder

Specifies the project directory for the project to build.