# ProjectConnection

interface ProjectConnection : Closeable(source)

Represents a long-lived connection to a Gradle project. You obtain an instance of a `ProjectConnection` by using connect.

    try (ProjectConnection connection = GradleConnector.newConnector()
           .forProjectDirectory(new File("someFolder"))
           .connect()) {

       //obtain some information from the build
       BuildEnvironment environment = connection.model(BuildEnvironment.class).get();

       //run some tasks
       connection.newBuild()
         .forTasks("tasks")
         .setStandardOutput(System.out)
         .run();

    }

Content copied to clipboard

## Thread safety information

All implementations of `ProjectConnection` are thread-safe, and may be shared by any number of threads.

All notifications from a given `ProjectConnection` instance are delivered by a single thread at a time. Note, however, that the delivery thread may change over time.

#### Since

1.0-milestone-3

## Functions

action
Link copied to clipboard
abstract fun action(): BuildActionExecuter.Builder
Creates a builder for an executer which can be used to run actions in different phases of the build.
abstract fun <T> action(buildAction: BuildAction<T>): BuildActionExecuter<T>
Creates an executer which can be used to run the given action when the build has finished.
close
Link copied to clipboard
abstract fun close()
Closes this connection.
getModel
Link copied to clipboard
abstract fun <T> getModel(modelType: Class<T>): T
Fetches a snapshot of the model of the given type for this project.
abstract fun <T> getModel(modelType: Class<T>, handler: ResultHandler<in T>)
Starts fetching a snapshot of the given model, passing the result to the given handler when complete.
getModel
Link copied to clipboard
inline fun <T : Any> ProjectConnection. getModel(modelType: KClass<T>): T
inline fun <T : Any> ProjectConnection. getModel(modelType: KClass<T>, handler: ResultHandler<in T>)

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.tooling.ProjectConnection.getModel.

model
Link copied to clipboard
abstract fun <T> model(modelType: Class<T>): ModelBuilder<T>
Creates a builder which can be used to query the model of the given type.
model
Link copied to clipboard
inline fun <T : Any> ProjectConnection. model(modelType: KClass<T>): ModelBuilder<T>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.tooling.ProjectConnection.model.

newBuild
Link copied to clipboard
abstract fun newBuild(): BuildLauncher
Creates a launcher which can be used to execute a build.
newTestLauncher
Link copied to clipboard
abstract fun newTestLauncher(): TestLauncher
Creates a test launcher which can be used to execute tests.
notifyDaemonsAboutChangedPaths
Link copied to clipboard
abstract fun notifyDaemonsAboutChangedPaths(changedPaths: List<Path>)
Notifies all daemons about file changes made by an external process, like an IDE.