Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gradle.tooling
Class GradleConnector

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

    public class GradleConnector

extends 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.
3. Call `connect()` to create the connection to a build.
4. Optionally reuse the connector to create additional connections.
5. When finished with the connections, call `close()` to clean up.

`GradleConnector` instances are not thread-safe.

Method Summary
`void` | `close()` Closes this connector and all connections created by it.
`BuildConnection` | `connect()` Creates a connection to the build in the specified project directory.
`GradleConnector` | `forProjectDirectory(File projectDir)` Specifies the working directory to use.
`static GradleConnector` | `newConnector()` Creates a new connector instance.
`GradleConnector` | `useDistribution(URI gradleDistribution)` Specifies which Gradle distribution to use.
`GradleConnector` | `useGradleVersion(String gradleVersion)` Specifies which Gradle version to use.
`GradleConnector` | `useInstallation(File gradleHome)` Specifies which Gradle installation to use.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### newConnector

    public static GradleConnector newConnector()

  Creates a new connector instance.

  Returns:
    The instance. Never returns null.

### useInstallation

    public GradleConnector useInstallation(File gradleHome)

  Specifies which Gradle installation to use. This replaces any value specified using `useDistribution(java.net.URI)` or `useGradleVersion(String)`.

  Parameters:
    `gradleHome` - The Gradle installation directory.
  Returns:
    this

### useGradleVersion

    public GradleConnector useGradleVersion(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)`.

  Parameters:
    `gradleVersion` - The version to use.
  Returns:
    this

### useDistribution

    public GradleConnector useDistribution(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)`.

  Parameters:
    `gradleDistribution` - The distribution to use.
  Returns:
    this

### forProjectDirectory

    public GradleConnector forProjectDirectory(File projectDir)

  Specifies the working directory to use.

  Parameters:
    `projectDir` - The working directory.
  Returns:
    this

### connect

    public BuildConnection connect()
                            throws GradleConnectionException

  Creates a connection to the build in the specified project directory.

  Returns:
    The connection. Never return null.
  Throws:
    `UnsupportedVersionException` - When the target Gradle version does not support this version of the tooling API.
    `GradleConnectionException` - On failure to establish a connection with the target Gradle version.

### close

    public void close()

  Closes this connector and all connections created by it.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD