Skip to content

Commit

Permalink
Convert init-script based on reference implementation
Browse files Browse the repository at this point in the history
- Renamed various input parameters (removing 'develocity-plugin' prefix)
- Modified implementation based on latest reference
- Extracted ENV_VAR_PREFIX into a separate line
  • Loading branch information
bigdaz committed May 15, 2024
1 parent 2defecd commit 51775ee
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,17 @@ private void inject(BuildContext buildContext, Collection<RuntimeTaskDefinition>
private void prepareEnvironment(BuildContext buildContext, GradleConfiguration config) {
VariableContext variableContext = buildContext.getVariableContext();

Objects.runIfNotNull(config.server, it -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_DEVELOCITY_URL", it));
Objects.runIfTrue(config.allowUntrustedServer, () -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_DEVELOCITY_ALLOW_UNTRUSTED_SERVER", "true"));
Objects.runIfNotNull(config.develocityPluginVersion, it -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_DEVELOCITY_PLUGIN_VERSION", it));
Objects.runIfNotNull(config.ccudPluginVersion, it -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_CCUD_PLUGIN_VERSION", it));
Objects.runIfNotNull(config.pluginRepository, it -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_GRADLE_PLUGIN_REPOSITORY_URL", it));
Objects.runIfTrue(config.enforceUrl, () -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_DEVELOCITY_ENFORCE_URL", "true"));
Objects.runIfTrue(config.gradleCaptureFileFingerprints, () -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_DEVELOCITY_CAPTURE_FILE_FINGERPRINTS", "true"));
variableContext.addLocalVariable("DEVELOCITY_INJECTION_ENABLED", "true");
variableContext.addLocalVariable("DEVELOCITY_INJECTION_INIT_SCRIPT_NAME", GradleEmbeddedResources.INIT_SCRIPT_NAME);
variableContext.addLocalVariable("DEVELOCITY_AUTO_INJECTION_CUSTOM_VALUE", "Bamboo");
Objects.runIfNotNull(config.server, it -> variableContext.addLocalVariable("DEVELOCITY_URL", it));
Objects.runIfTrue(config.enforceUrl, () -> variableContext.addLocalVariable("DEVELOCITY_ENFORCE_URL", "true"));
Objects.runIfTrue(config.allowUntrustedServer, () -> variableContext.addLocalVariable("DEVELOCITY_ALLOW_UNTRUSTED_SERVER", "true"));
Objects.runIfNotNull(config.develocityPluginVersion, it -> variableContext.addLocalVariable("DEVELOCITY_PLUGIN_VERSION", it));
Objects.runIfNotNull(config.ccudPluginVersion, it -> variableContext.addLocalVariable("CCUD_PLUGIN_VERSION", it));
Objects.runIfTrue(config.gradleCaptureFileFingerprints, () -> variableContext.addLocalVariable("DEVELOCITY_CAPTURE_FILE_FINGERPRINTS", "true"));

Objects.runIfNotNull(config.pluginRepository, it -> variableContext.addLocalVariable("GRADLE_PLUGIN_REPOSITORY_URL", it));
Objects.runIfNotNull(
config.pluginRepositoryCredentialName,
it -> {
Expand All @@ -148,8 +152,8 @@ private void prepareEnvironment(BuildContext buildContext, GradleConfiguration c
if (credentials.getUsername() == null || credentials.getPassword() == null) {
LOGGER.warn("Plugin repository credentials {} do not have username or password set.", it);
} else {
variableContext.addLocalVariable("DEVELOCITY_PLUGIN_GRADLE_PLUGIN_REPOSITORY_USERNAME", credentials.getUsername());
variableContext.addLocalVariable("DEVELOCITY_PLUGIN_GRADLE_PLUGIN_REPOSITORY_PASSWORD", credentials.getPassword());
variableContext.addLocalVariable("GRADLE_PLUGIN_REPOSITORY_USERNAME", credentials.getUsername());
variableContext.addLocalVariable("GRADLE_PLUGIN_REPOSITORY_PASSWORD", credentials.getPassword());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public final class GradleEmbeddedResources {

private static final String INIT_SCRIPT_NAME = "develocity-init-script.gradle";
public static final String INIT_SCRIPT_NAME = "develocity-init-script.gradle";

File copyInitScript(String home) {
try (InputStream is = GradleEmbeddedResources.class.getResourceAsStream(String.format("/develocity/gradle/%s", INIT_SCRIPT_NAME))) {
Expand Down
Loading

0 comments on commit 51775ee

Please sign in to comment.