Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gradle.tooling
[Java] Class GradleConnector

    java.lang.Object
      org.gradle.tooling.GradleConnector

    public abstract class GradleConnector
    extends java.lang.Object

A `GradleConnector` is the main entry point to the Gradle tooling API. You use this API as follows:

1. Call newConnector() to create a new connector instance.
2. Configure the connector. You must call forProjectDirectory(java.io.File) to specify which project you wish to connect to. Other methods are optional.
3. Call connect() to create the connection to a project.
4. Optionally reuse the connector to create additional connections.
5. When finished with the connection, call ProjectConnection.close to clean up.

`GradleConnector` instances are not thread-safe.

Method Summary
`ProjectConnection` | `connect()` Creates a connection to the project in the specified project directory.
`GradleConnector` | `forProjectDirectory(java.io.File projectDir)` Specifies the working directory to use.
`static GradleConnector` | `newConnector()` Creates a new connector instance.
`GradleConnector` | `useDistribution(java.net.URI gradleDistribution)` Specifies which Gradle distribution to use.
`GradleConnector` | `useGradleUserHomeDir(java.io.File gradleUserHomeDir)` Specifies the user's Gradle home directory to use.
`GradleConnector` | `useGradleVersion(java.lang.String gradleVersion)` Specifies which Gradle version to use.
`GradleConnector` | `useInstallation(java.io.File gradleHome)` Specifies which Gradle installation to use.

Methods inherited from class java.lang.Object
java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString()

Method Detail

### connect

    public ProjectConnection connect()

  Creates a connection to the project in the specified project directory. You should call ProjectConnection.close when you are finished with the connection.
  throws:
    UnsupportedVersionException When the target Gradle version does not support this version of the tooling API.
  throws:
    GradleConnectionException On failure to establish a connection with the target Gradle version.
  Returns:
    The connection. Never return null.

### forProjectDirectory

    public GradleConnector forProjectDirectory(java.io.File projectDir)

  Specifies the working directory to use.
  Parameters:
    `projectDir` - The working directory.
  Returns:
    this

### newConnector

    public static GradleConnector newConnector()

  Creates a new connector instance.
  Returns:
    The instance. Never returns null.

### useDistribution

    public GradleConnector useDistribution(java.net.URI gradleDistribution)

  Specifies which Gradle distribution to use. The appropriate distribution is downloaded and installed into the user's Gradle home directory. This replaces any value specified using useInstallation(java.io.File) or useGradleVersion(String). Defaults to a project-specific Gradle version.
  Parameters:
    `gradleDistribution` - The distribution to use.
  Returns:
    this

### useGradleUserHomeDir

    public GradleConnector useGradleUserHomeDir(java.io.File gradleUserHomeDir)

  Specifies the user's Gradle home directory to use. Defaults to `~/.gradle`
  Parameters:
    `gradleUserHomeDir` - The user's Gradle home directory to use.
  Returns:
    this

### useGradleVersion

    public GradleConnector useGradleVersion(java.lang.String gradleVersion)

  Specifies which Gradle version to use. The appropriate distribution is downloaded and installed into the user's Gradle home directory. This replaces any value specified using useInstallation(java.io.File) or useDistribution(java.net.URI). Defaults to a project-specific Gradle version.
  Parameters:
    `gradleVersion` - The version to use.
  Returns:
    this

### useInstallation

    public GradleConnector useInstallation(java.io.File gradleHome)

  Specifies which Gradle installation to use. This replaces any value specified using useDistribution(java.net.URI) or useGradleVersion(String). Defaults to a project-specific Gradle version.
  Parameters:
    `gradleHome` - The Gradle installation directory.
  Returns:
    this

Groovy Documentation