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 classGradleEnterpriseBuildCache.UsernameAndPasswordA 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 booleangetAllowInsecureProtocol()Whether the use of plain/unencrypted HTTP is allowed when communicating with the build cache server.booleangetAllowUntrustedServer()Whether it is acceptable to communicate with a build cache server with an untrusted SSL certificate.java.lang.StringgetPath()The custom request path for the build cache server.java.lang.StringgetServer()The address of the build cache server to use, if not using the built-in build cache of the server specified byGradleEnterpriseExtension.getServer().GradleEnterpriseBuildCache.UsernameAndPasswordgetUsernameAndPassword()The username/password to use to authenticate with the build cache server.voidsetAllowInsecureProtocol(boolean allowInsecureProtocol)Sets whether the use of plain/unencrypted HTTP is allowed when communicating with the build cache server.voidsetAllowUntrustedServer(boolean allowUntrustedServer)Specifies whether it is acceptable to communicate with the build cache server using an untrusted SSL certificate.voidsetPath(java.lang.String path)Set a custom request path for the build cache server specified bygetServer()orGradleEnterpriseExtension.getServer().voidsetServer(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().voidsetUsernameAndPassword(GradleEnterpriseBuildCache.UsernameAndPassword usernameAndPassword)Sets the username/password to use to authenticate with the build cache server.voidusernameAndPassword(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:
nullif 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
public boolean getAllowUntrustedServer()
Whether it is acceptable to communicate with a build cache server with an untrusted SSL certificate.If
GradleEnterpriseExtension.getAllowUntrustedServer()is true, untrusted connections will be allowed regardless of this setting.- Returns:
- whether it is acceptable to communicate with a build scan server with an untrusted SSL certificate
-
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
trueto 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).
If
GradleEnterpriseExtension.getAllowUntrustedServer()istrue, untrusted connections will be allowed regardless of this setting.- 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)
-
-