Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Use environment variables to configure Gradle init scripts"
This reverts commit 5fd0927.
  • Loading branch information
erichaagdev committed Nov 20, 2024
commit 64f48ec26c9fb43c51d62d281a9c3a99554342e1
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,19 @@ validate_build_config() {
}

execute_build() {
info "Running build:"
print_gradle_command
local args
args=(--build-cache --init-script "${INIT_SCRIPTS_DIR}/configure-remote-build-caching.gradle")
if [ -n "${remote_build_cache_url}" ]; then
args+=("-Ddevelocity.build-validation.remoteBuildCacheUrl=${remote_build_cache_url}")
fi

# shellcheck disable=SC2086 # we want tasks to expand with word splitting in this case
invoke_gradle 1 \
--build-cache \
--init-script "${INIT_SCRIPTS_DIR}/configure-remote-build-caching.gradle" \
clean ${tasks}
}
# shellcheck disable=SC2206 # we want tasks to expand with word splitting in this case
args+=(clean ${tasks})

print_gradle_command() {
info "Running build:"
info "./gradlew --build-cache -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} -Dpts.enabled=false clean ${tasks}$(print_extra_args)"

invoke_gradle 1 "${args[@]}"
}

# Overrides summary.sh#print_experiment_specific_summary_info
Expand Down
59 changes: 23 additions & 36 deletions components/scripts/lib/gradle.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

invoke_gradle() {
local run_num
local run_num args
args=()
run_num=$1
shift

Expand All @@ -11,45 +12,35 @@ invoke_gradle() {
cd "${project_dir}" > /dev/null 2>&1 || die "ERROR: Subdirectory ${project_dir} (set with --project-dir) does not exist in ${project_name}" "${INVALID_INPUT}"
fi

envs+=(
DEVELOCITY_INJECTION_INIT_SCRIPT_NAME=develocity-injection.gradle
DEVELOCITY_INJECTION_ENABLED=true
args+=(
--init-script "${INIT_SCRIPTS_DIR}/develocity-injection.gradle"
--init-script "${INIT_SCRIPTS_DIR}/configure-build-validation.gradle"
-Ddevelocity.injection.init-script-name=develocity-injection.gradle
-Ddevelocity.injection-enabled=true
)

if [ "$enable_ge" == "on" ]; then
envs+=(
GRADLE_PLUGIN_REPOSITORY_URL=https://plugins.gradle.org/m2
DEVELOCITY_PLUGIN_VERSION="3.14.1"
DEVELOCITY_CCUD_PLUGIN_VERSION="2.0.2"
args+=(
-Dgradle.plugin-repository.url=https://plugins.gradle.org/m2
-Ddevelocity.plugin.version="3.14.1"
-Ddevelocity.ccud.plugin.version="2.0.2"
)
fi

if [ -n "${ge_server}" ]; then
envs+=(
DEVELOCITY_BUILD_VALIDATION_URL="${ge_server}"
DEVELOCITY_BUILD_VALIDATION_ALLOW_UNTRUSTED_SERVER=false
)
fi

if [ -n "${remote_build_cache_url}" ]; then
envs+=(
DEVELOCITY_BUILD_VALIDATION_REMOTEBUILDCACHEURL="${remote_build_cache_url}"
args+=(
-Ddevelocity.build-validation.url="${ge_server}"
-Ddevelocity.build-validation.allow-untrusted-server=false
)
fi

envs+=(
DEVELOCITY_BUILD_VALIDATION_EXPDIR="${EXP_DIR}"
DEVELOCITY_BUILD_VALIDATION_EXPID="${EXP_SCAN_TAG}"
DEVELOCITY_BUILD_VALIDATION_RUNID="${RUN_ID}"
DEVELOCITY_BUILD_VALIDATION_RUNNUM="${run_num}"
DEVELOCITY_BUILD_VALIDATION_SCRIPTSVERSION="${SCRIPT_VERSION}"
DEVELOCITY_CAPTURE_FILE_FINGERPRINTS=true
)

local args
args=(
--init-script "${INIT_SCRIPTS_DIR}/develocity-injection.gradle"
--init-script "${INIT_SCRIPTS_DIR}/configure-build-validation.gradle"
args+=(
-Ddevelocity.build-validation.expDir="${EXP_DIR}"
-Ddevelocity.build-validation.expId="${EXP_SCAN_TAG}"
-Ddevelocity.build-validation.runId="${RUN_ID}"
-Ddevelocity.build-validation.runNum="${run_num}"
-Ddevelocity.build-validation.scriptsVersion="${SCRIPT_VERSION}"
-Ddevelocity.capture-file-fingerprints=true
-Dpts.enabled=false
)

Expand All @@ -66,13 +57,9 @@ invoke_gradle() {
rm -f "${EXP_DIR}/errors.txt"

debug "Current directory: $(pwd)"
# shellcheck disable=SC2145
debug export "${envs[@]}"';' ./gradlew "${args[@]}"
debug ./gradlew "${args[@]}"

# The parenthesis below will intentionally create a subshell. This causes the
# environment variables to only be exported for the child process and not leak
# to the rest of the script.
if (export "${envs[@]}"; ./gradlew "${args[@]}"); then
if ./gradlew "${args[@]}"; then
build_outcomes+=("SUCCESSFUL")
else
build_outcomes+=("FAILED")
Expand Down