Class DefaultGradleConnector
- java.lang.Object
-
- org.gradle.tooling.GradleConnector
-
- org.gradle.tooling.internal.consumer.DefaultGradleConnector
-
- All Implemented Interfaces:
ProjectConnectionCloseListener
public class DefaultGradleConnector extends GradleConnector implements ProjectConnectionCloseListener
-
-
Constructor Summary
Constructors Constructor Description DefaultGradleConnector(ConnectionFactory connectionFactory, DistributionFactory distributionFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
close()
Closes the tooling API, releasing all resources.ProjectConnection
connect()
Creates a connection to the project in the specified project directory.void
connectionClosed(ProjectConnection connection)
GradleConnector
daemonBaseDir(java.io.File daemonBaseDir)
GradleConnector
daemonMaxIdleTime(int timeoutValue, java.util.concurrent.TimeUnit timeoutUnits)
void
disconnect()
Disconnects all ProjectConnection instances created by this connector.GradleConnector
embedded(boolean embedded)
GradleConnector
forProjectDirectory(java.io.File projectDir)
Specifies the working directory to use.GradleConnector
searchUpwards(boolean searchUpwards)
DefaultGradleConnector
setVerboseLogging(boolean verboseLogging)
If true then debug log statements will be shownGradleConnector
useBuildDistribution()
Specifies to use the Gradle distribution defined by the target Gradle build.GradleConnector
useClasspathDistribution()
GradleConnector
useDistribution(java.net.URI gradleDistribution)
Specifies which Gradle distribution to use.GradleConnector
useDistributionBaseDir(java.io.File distributionBaseDir)
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 org.gradle.tooling.GradleConnector
newCancellationTokenSource, newConnector
-
-
-
-
Constructor Detail
-
DefaultGradleConnector
public DefaultGradleConnector(ConnectionFactory connectionFactory, DistributionFactory distributionFactory)
-
-
Method Detail
-
close
public static void close()
Closes the tooling API, releasing all resources. Blocks until completed.May attempt to expire some or all daemons started by this tooling API client. The exact behaviour here is implementation-specific and not guaranteed. The expiration is best effort only. This method may return before the daemons have stopped.
Note: this is not yet part of the public tooling API yet.
TODO - need to model this as a long running operation, and allow stdout, stderr and progress listener to be supplied. TODO - need to define exceptions. TODO - no further operations are allowed after this has been called TODO - cancel current operations or block until complete TODO - introduce a 'tooling API client' interface and move this method there
-
connectionClosed
public void connectionClosed(ProjectConnection connection)
- Specified by:
connectionClosed
in interfaceProjectConnectionCloseListener
-
disconnect
public void disconnect()
Description copied from class:GradleConnector
Disconnects all ProjectConnection instances created by this connector.Calling this method tries to do a best effort to clean up resources used by the tooling API. It tries to cancel any builds and shut down running daemons.
After calling
disconnect
, creating new project connections will be rejected and the existing ones created by this instance will also deny future build operations.- Specified by:
disconnect
in classGradleConnector
-
useInstallation
public GradleConnector useInstallation(java.io.File gradleHome)
Description copied from class:GradleConnector
Specifies which Gradle installation to use. This replaces any value specified usingGradleConnector.useDistribution(URI)
,GradleConnector.useGradleVersion(String)
, orGradleConnector.useBuildDistribution()
. Defaults to a project-specific Gradle version.- Specified by:
useInstallation
in classGradleConnector
- Parameters:
gradleHome
- The Gradle installation directory.- Returns:
- this
-
useGradleVersion
public GradleConnector useGradleVersion(java.lang.String gradleVersion)
Description copied from class:GradleConnector
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 usingGradleConnector.useInstallation(File)
,GradleConnector.useDistribution(URI)
, orGradleConnector.useBuildDistribution()
. Defaults to a project-specific Gradle version.- Specified by:
useGradleVersion
in classGradleConnector
- Parameters:
gradleVersion
- The version to use.- Returns:
- this
-
useDistribution
public GradleConnector useDistribution(java.net.URI gradleDistribution)
Description copied from class:GradleConnector
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 usingGradleConnector.useInstallation(File)
,GradleConnector.useGradleVersion(String)
, orGradleConnector.useBuildDistribution()
. Defaults to a project-specific Gradle version.- Specified by:
useDistribution
in classGradleConnector
- Parameters:
gradleDistribution
- The distribution to use.- Returns:
- this
-
useClasspathDistribution
public GradleConnector useClasspathDistribution()
-
useBuildDistribution
public GradleConnector useBuildDistribution()
Description copied from class:GradleConnector
Specifies to use the Gradle distribution defined by the target Gradle build. The appropriate distribution defined by the target Gradle build is downloaded and installed into the user's Gradle home directory. If the target Gradle build does not define the distribution that it should be built with, the Gradle version of this connector is used. This replaces any value specified usingGradleConnector.useInstallation(File)
,GradleConnector.useDistribution(URI)
, orGradleConnector.useGradleVersion(String)
. Acts as the default behavior.- Specified by:
useBuildDistribution
in classGradleConnector
- Returns:
- this
-
useDistributionBaseDir
public GradleConnector useDistributionBaseDir(java.io.File distributionBaseDir)
-
forProjectDirectory
public GradleConnector forProjectDirectory(java.io.File projectDir)
Description copied from class:GradleConnector
Specifies the working directory to use.- Specified by:
forProjectDirectory
in classGradleConnector
- Parameters:
projectDir
- The working directory.- Returns:
- this
-
useGradleUserHomeDir
public GradleConnector useGradleUserHomeDir(java.io.File gradleUserHomeDir)
Description copied from class:GradleConnector
Specifies the user's Gradle home directory to use. Defaults to~/.gradle
.- Specified by:
useGradleUserHomeDir
in classGradleConnector
- Parameters:
gradleUserHomeDir
- The user's Gradle home directory to use.- Returns:
- this
-
searchUpwards
public GradleConnector searchUpwards(boolean searchUpwards)
-
embedded
public GradleConnector embedded(boolean embedded)
-
daemonMaxIdleTime
public GradleConnector daemonMaxIdleTime(int timeoutValue, java.util.concurrent.TimeUnit timeoutUnits)
-
daemonBaseDir
public GradleConnector daemonBaseDir(java.io.File daemonBaseDir)
-
setVerboseLogging
public DefaultGradleConnector setVerboseLogging(boolean verboseLogging)
If true then debug log statements will be shown
-
connect
public ProjectConnection connect() throws GradleConnectionException
Description copied from class:GradleConnector
Creates a connection to the project in the specified project directory. You should callProjectConnection.close()
when you are finished with the connection.- Specified by:
connect
in classGradleConnector
- 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.
-
-