Starting with versions 3.17 and 1.21 respectively, the Gradle Enterprise Gradle plugin and Maven extension are available under the “Develocity” brand. Several core functionalities have been deprecated with the rebranding. This repository provides adapter classes for both versions of the API to enable a smooth upgrade to the new API and support developers in providing compatibility with both “Gradle Enterprise” and “Develocity” plugins/extensions.
All adapters are located in the com.gradle.develocity.agent.(gradle|maven).adapters
.
See the in-code documentation for the corresponding Gradle plugin or Maven extension classes.
implementation("com.gradle:develocity-gradle-plugin-adapters:1.0.2")
<dependency>
<groupId>com.gradle</groupId>
<artifactId>develocity-maven-extension-adapters</artifactId>
<version>1.0</version>
</dependency>
In the following, we illustrate how a plugin developer can configure conditional Build Scan publication with and without adapter layer.
// configure conditional publication for the Develocity plugin
DevelocityConfiguration develocity = settings.getExtensions().getByType(DevelocityConfiguration.class);
develocity.getBuildScan().publishing(p -> p.onlyIf(ctx -> Boolean.getBoolean("publish")));
// configure conditional publication for Gradle Enterprise plugin
GradleEnterpriseExtension gradleEnterprise = settings.getExtensions().getByType(GradleEnterpriseExtension.class);
gradleEnterprise.getBuildScan().publishAlwaysIf(Boolean.getBoolean("publish"));
// configure conditional publication using the unified API
private static void publishConditionally(DevelocityAdapter develocity) {
develocity.getBuildScan().publishAlwaysIf(Boolean.getBoolean("publish"));
}
Object develocity = settings.getExtensions().getByName("develocity");
publishConditionally(new DevelocityConfigurationAdapter(develocity));
Object gradleEnterprise = settings.getExtensions().getByName("gradleEnterprise");
publishConditionally(new GradleEnterpriseExtensionAdapter(gradleEnterprise));