Skip to content

Commit

Permalink
Migrated gradle remote cache to the gradleEnterprise connector and wi…
Browse files Browse the repository at this point in the history
…th that to access key authentication (#653)
  • Loading branch information
ribafish authored Feb 12, 2024
1 parent dc2e2de commit c9cea1a
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
import org.gradle.caching.configuration.BuildCacheConfiguration;
import org.gradle.caching.http.HttpBuildCache;
import org.nosphere.gradle.github.ActionsPlugin;

import java.lang.reflect.InvocationTargetException;

import static io.micronaut.build.BuildEnvironment.PREDICTIVE_TEST_SELECTION_ENV_VAR;
import static io.micronaut.build.utils.ProviderUtils.envOrSystemProperty;

public class MicronautGradleEnterprisePlugin implements Plugin<Settings> {
private static final String[] SAFE_TO_LOG_ENV_VARIABLES = new String[] {
Expand Down Expand Up @@ -82,20 +80,14 @@ private void configureGradleEnterprise(Settings settings,
}
buildCache.getLocal().setEnabled(localEnabled);
if (remoteEnabled) {
buildCache.remote(HttpBuildCache.class, remote -> {
remote.setUrl("https://ge.micronaut.io/cache/");
buildCache.remote(ge.getBuildCache(), remote -> {
remote.setEnabled(true);
if (push) {
String username = envOrSystemProperty(providers, "GRADLE_ENTERPRISE_CACHE_USERNAME", "gradleEnterpriseCacheUsername", "");
String password = envOrSystemProperty(providers, "GRADLE_ENTERPRISE_CACHE_PASSWORD", "gradleEnterpriseCachePassword", "");
if (!username.isEmpty() && !password.isEmpty()) {
String accessKey = providers.systemProperty("GRADLE_ENTERPRISE_ACCESS_KEY").getOrNull();
if (accessKey != null && !accessKey.isEmpty()) {
remote.setPush(true);
remote.credentials(creds -> {
creds.setUsername(username);
creds.setPassword(password);
});
} else {
System.err.println("WARNING: No credentials for remote build cache, cannot configure push!");
System.err.println("WARNING: Access key missing for remote build cache, cannot configure push!");
}
}
});
Expand Down

0 comments on commit c9cea1a

Please sign in to comment.