Class GradleEnterpriseBuildCache
- java.lang.Object
-
- org.gradle.caching.configuration.AbstractBuildCache
-
- com.gradle.enterprise.gradleplugin.GradleEnterpriseBuildCache
-
- All Implemented Interfaces:
BuildCache
public class GradleEnterpriseBuildCache extends AbstractBuildCache
Allows configuring the use of a Gradle Enterprise build cache.This can be used with
BuildCacheConfiguration.remote(Class, Action)
to enable use of the Gradle Enterprise remote build caching. The methodGradleEnterpriseExtension.getBuildCache()
must be used to obtain the type object to use. This type cannot be used directly.The following example demonstrates usage in a build's settings script:
buildCache { remote(gradleEnterprise.buildCache) { // configure } }
Without any explicit configuration, the default build cache provided by the installation specified by
GradleEnterpriseExtension.getServer()
will be used.If an access key is available for the
GradleEnterpriseExtension.getServer()
value it will be used to authenticate with the build cache.- Since:
- 3.11
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GradleEnterpriseBuildCache.UsernameAndPassword
A value type representing both a username and password.
-
Constructor Summary
Constructors Constructor Description GradleEnterpriseBuildCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getAllowInsecureProtocol()
Whether the use of plain/unencrypted HTTP is allowed when communicating with the build cache server.java.lang.Boolean
getAllowUntrustedServer()
Whether it is acceptable to communicate with a build cache server with an untrusted SSL certificate.java.lang.String
getPath()
The custom request path for the build cache server.java.lang.String
getServer()
The address of the build cache server to use, if not using the built-in build cache of the server specified byGradleEnterpriseExtension.getServer()
.boolean
getUseExpectContinue()
Whether to use HTTP Expect-Continue when storing data on the build cache server.GradleEnterpriseBuildCache.UsernameAndPassword
getUsernameAndPassword()
The username/password to use to authenticate with the build cache server.void
setAllowInsecureProtocol(boolean allowInsecureProtocol)
Sets whether the use of plain/unencrypted HTTP is allowed when communicating with the build cache server.void
setAllowUntrustedServer(boolean allowUntrustedServer)
Specifies whether it is acceptable to communicate with the build cache server using an untrusted SSL certificate.void
setPath(java.lang.String path)
Set a custom request path for the build cache server specified bygetServer()
orGradleEnterpriseExtension.getServer()
.void
setServer(java.lang.String server)
Sets the build cache server address to use, if not using the default build cache of the server specified byGradleEnterpriseExtension.getServer()
.void
setUseExpectContinue(boolean useExpectContinue)
Sets whether to use HTTP Expect-Continue when storing data on the build cache server.void
setUsernameAndPassword(GradleEnterpriseBuildCache.UsernameAndPassword usernameAndPassword)
Sets the username/password to use to authenticate with the build cache server.void
usernameAndPassword(java.lang.String username, java.lang.String password)
Sets the username/password to use to authenticate with the build cache server.-
Methods inherited from class org.gradle.caching.configuration.AbstractBuildCache
isEnabled, isPush, setEnabled, setPush
-
-
-
-
Method Detail
-
getServer
@Nullable public java.lang.String getServer()
The address of the build cache server to use, if not using the built-in build cache of the server specified byGradleEnterpriseExtension.getServer()
.- Returns:
null
if the built-in build cache of the Gradle Enterprise server should be used, or the address of the build cache server that should be used- See Also:
setServer(String)
-
setServer
public void setServer(@Nullable java.lang.String server)
Sets the build cache server address to use, if not using the default build cache of the server specified byGradleEnterpriseExtension.getServer()
.Setting this option is necessary when using a dedicated build cache node instead of the Gradle Enterprise built-in build cache.
The value set must not include any request path or query string. It must only specify the protocol, hostname and port.
If an access key is available for the
GradleEnterpriseExtension.getServer()
value it will be used to authenticate with the build cache, regardless of the build cache server address set with this method.- Parameters:
server
- the server address
-
getPath
@Nullable public java.lang.String getPath()
The custom request path for the build cache server.It is generally not necessary to set this value, as the default value used is suitable for the default configuration of Gradle Enterprise build cache nodes (including the built-in build cache).
- Returns:
- the custom request path for the build cache server
- See Also:
setPath(String)
-
setPath
public void setPath(@Nullable java.lang.String path)
Set a custom request path for the build cache server specified bygetServer()
orGradleEnterpriseExtension.getServer()
.It is generally not necessary to set this value, as the default value used is suitable for the default configuration of Gradle Enterprise build cache nodes (including the built-in build cache).
- Parameters:
path
- a custom request path for the build cache server
-
getAllowUntrustedServer
@Nullable public java.lang.Boolean getAllowUntrustedServer()
Whether it is acceptable to communicate with a build cache server with an untrusted SSL certificate.If not set then will be inherited from
GradleEnterpriseExtension.getAllowUntrustedServer()
.- Returns:
null
if the value should be inherited fromGradleEnterpriseExtension.getAllowUntrustedServer()
, or whether it is acceptable to communicate with a build scan server with an untrusted SSL certificate- See Also:
setAllowUntrustedServer(boolean)
-
setAllowUntrustedServer
public void setAllowUntrustedServer(boolean allowUntrustedServer)
Specifies whether it is acceptable to communicate with the build cache server using an untrusted SSL certificate.If the build cache server are uses an internally provisioned or self-signed certificate it will not be trusted by default. Allowing communication with untrusted servers keeps data encrypted during transmission, but makes it easy for a man-in-the-middle to impersonate the intended server and capture data.
In such a scenario, you can either configure the build JVM environment to trust the certificate, or call this method with
true
to disable verification of the server's identity.This value has no effect if communicating with the server using the HTTP protocol (i.e. has SSL disabled).
- Parameters:
allowUntrustedServer
- whether to allow communication with an HTTPS server with an untrusted certificate
-
getAllowInsecureProtocol
public boolean getAllowInsecureProtocol()
Whether the use of plain/unencrypted HTTP is allowed when communicating with the build cache server.- Returns:
- whether the use of plain/unencrypted HTTP is allowed when communicating with the build cache server
- See Also:
setAllowInsecureProtocol(boolean)
-
setAllowInsecureProtocol
public void setAllowInsecureProtocol(boolean allowInsecureProtocol)
Sets whether the use of plain/unencrypted HTTP is allowed when communicating with the build cache server.This value defaults to
false
.Use of unencrypted HTTP allows interception of build cache entries while in transit and is a significant privacy risk. Use of HTTPS instead of enabling this setting is strongly recommended
- Parameters:
allowInsecureProtocol
- whether to allow the use of plain/unencrypted HTTP
-
usernameAndPassword
public void usernameAndPassword(java.lang.String username, java.lang.String password)
Sets the username/password to use to authenticate with the build cache server.This is a convenient variant of
setUsernameAndPassword(UsernameAndPassword)
.- Parameters:
username
- the usernamepassword
- the password
-
setUsernameAndPassword
public void setUsernameAndPassword(@Nullable GradleEnterpriseBuildCache.UsernameAndPassword usernameAndPassword)
Sets the username/password to use to authenticate with the build cache server.If specified, the username/password will be used instead of any available Gradle Enterprise access key. Use of access keys should be preferred.
- Parameters:
usernameAndPassword
- the username and password
-
getUsernameAndPassword
@Nullable public GradleEnterpriseBuildCache.UsernameAndPassword getUsernameAndPassword()
The username/password to use to authenticate with the build cache server.- Returns:
- the username/password to use to authenticate with the build cache server
- See Also:
setUsernameAndPassword(UsernameAndPassword)
-
getUseExpectContinue
public boolean getUseExpectContinue()
Whether to use HTTP Expect-Continue when storing data on the build cache server.- Returns:
- whether the use of HTTP Expect-Continue is configured when communicating with the build cache server
- Since:
- 3.12
- See Also:
setUseExpectContinue(boolean)
-
setUseExpectContinue
public void setUseExpectContinue(boolean useExpectContinue)
Sets whether to use HTTP Expect-Continue when storing data on the build cache server.This causes PUT requests to happen in two parts: first a check whether a body would be accepted, then transmission of the body if the server indicates it will accept it. This is particularly suitable for Build Cache servers that routinely redirect or reject PUT requests, as it avoids transmitting the cache entry just to have it rejected. This additional check incurs extra latency when the server accepts the request, but reduces latency when the request is rejected or redirected.
This value defaults to
false
.While the Gradle Enterprise Build Cache Node supports Expect-Continue, not all HTTP servers and proxies reliably do. Be sure to check that your Build Cache server does support it before enabling.
- Parameters:
useExpectContinue
- whether to use HTTP Expect-Continue- Since:
- 3.12
-
-