# service

@Incubating
abstract fun <T : ProjectService?> service(serviceType: Class<T>): T(source)

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

The services available for lookup are the Gradle types that implement ProjectService.

Perform this lookup at configuration time. The returned instance may be captured and used later from a task action, and is safe to store in the configuration cache. To look a service up from within a task action, use service instead.

This method does not provide access to shared build services; use org.gradle.api.services.ServiceReference or getSharedServices to access those.

#### Return

the service instance. Never returns null.

#### Since

9.8.0

#### Parameters

serviceType

the type of the service to look up

<T>

the service type

#### Throws

org.gradle.api.InvalidUserDataException

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