Interface BuildService<T extends BuildServiceParameters>

  • Type Parameters:
    T - The type of parameters used by the service.
    All Known Subinterfaces:
    JavaToolchainResolver

    public interface BuildService<T extends BuildServiceParameters>
    Represents a user provided "service" that is used by a Gradle build. Often these services are shared by multiple tasks and hold some state that tasks use to do their work. A service implementation might hold, for example, an in-memory cache that tasks use to improve performance. Or, as another example, a service implementation might represent a web service that the build starts and uses.

    To create a service, create an abstract subclass of this interface and use BuildServiceRegistry.registerIfAbsent(String, Class, Action) to register one or more instances. This method returns a Provider that you can use to connect the service to tasks.

    A service implementation may optionally take parameters. To do this create a subtype of BuildServiceParameters and declare this type as the type parameter to the service implementation.

    A service may optionally implement AutoCloseable, in which case AutoCloseable.close() will be called when the service instance is no longer required. The implementation can release any resources it may be holding open.

    It is important to note that service implementations must be thread-safe, as they may be used by multiple tasks concurrently.

    Since:
    6.1
    • Method Detail

      • getParameters

        @Inject
        T getParameters()
        Returns the parameters of this service. You should not implement this method, but instead leave it abstract.