# service

@Incubating
inline fun <T : GradleService> Gradle. service(serviceType: KClass<T>): T(source)

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.invocation.Gradle.service.

#### Since

9.8.0

#### See also

org.gradle.api.invocation.Gradle.service

@Incubating
inline fun <T : TaskService> Task. service(serviceType: KClass<T>): T(source)

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.Task.service.

#### Since

9.8.0

#### See also

org.gradle.api.Task.service

@Incubating
inline fun <T : ProjectService> Project. service(serviceType: KClass<T>): T(source)

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.Project.service.

#### Since

9.8.0

#### See also

org.gradle.api.Project.service

@Incubating
inline fun <T : SettingsService> Settings. service(serviceType: KClass<T>): T(source)

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.initialization.Settings.service.

#### Since

9.8.0

#### See also

org.gradle.api.initialization.Settings.service

@Incubating
inline fun <T : ProjectService> Project. service(): T(source)

Looks up a service provided by Gradle for use in this project.

#### Return

the service instance

#### Since

9.8.0

#### Type Parameters

T

the type of the service to look up

#### See also

Project.service

#### Throws

org.gradle.api.InvalidUserDataException

when the given type is not one of the services available in this scope

@Incubating
inline fun <T : TaskService> Task. service(): T(source)

Looks up a service provided by Gradle for use in this task.

The lookup can be used both at configuration time and from task actions at execution time, and is safe to use with the configuration cache:

    tasks.register("cleanThing") {
        doLast {
            service<FileSystemOperations>().delete {
                delete("thing")
            }
        }
    }

Content copied to clipboard

#### Return

the service instance

#### Since

9.8.0

#### Type Parameters

T

the type of the service to look up

#### See also

Task.service

#### Throws

org.gradle.api.InvalidUserDataException

when the given type is not one of the services available in this scope

@Incubating
inline fun <T : SettingsService> Settings. service(): T(source)

Looks up a service provided by Gradle for use in this build.

#### Return

the service instance

#### Since

9.8.0

#### Type Parameters

T

the type of the service to look up

#### See also

Settings.service

#### Throws

org.gradle.api.InvalidUserDataException

when the given type is not one of the services available in this scope

@Incubating
inline fun <T : GradleService> Gradle. service(): T(source)

Looks up a service provided by Gradle for use in init scripts and Gradle plugins.

#### Return

the service instance

#### Since

9.8.0

#### Type Parameters

T

the type of the service to look up

#### See also

Gradle.service

#### Throws

org.gradle.api.InvalidUserDataException

when the given type is not one of the services available in this scope