Skip to content

Commit 31d3955

Browse files
committed
Revert "Add offline mode for exp3-gradle"
This reverts commit 1071db5.
1 parent 1071db5 commit 31d3955

File tree

11 files changed

+173
-247
lines changed

11 files changed

+173
-247
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ val mavenComponents by configurations.creating
4141
dependencies {
4242
argbash("argbash:argbash:2.10.0@zip")
4343
commonComponents(project(path = ":fetch-build-scan-data-cmdline-tool", configuration = "shadow"))
44-
commonComponents(project(path = ":mock-scan-dump-to-csv-tool", configuration = "shadow"))
4544
mavenComponents(project(":capture-build-scan-url-maven-extension"))
4645
mavenComponents("com.gradle:gradle-enterprise-maven-extension:1.15.4")
4746
mavenComponents("com.gradle:common-custom-user-data-maven-extension:1.11.1")

components/mock-scan-dump-to-csv-tool/build.gradle.kts

Lines changed: 0 additions & 28 deletions
This file was deleted.

components/mock-scan-dump-to-csv-tool/src/main/java/com/gradle/enterprise/Main.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

components/scripts/gradle/03-validate-local-build-caching-different-locations.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,8 @@ execute_second_build() {
154154
}
155155

156156
fetch_build_cache_metrics() {
157-
if [ "${offline_mode}" == "on" ]; then
158-
read_build_scan_from_scan_dump
159-
else
160-
read_build_scan_metadata
161-
fetch_and_read_build_scan_data build_cache_metrics_only "${build_scan_urls[@]}"
162-
fi
157+
read_build_scan_metadata
158+
fetch_and_read_build_scan_data build_cache_metrics_only "${build_scan_urls[@]}"
163159
}
164160

165161
# Overrides info.sh#print_performance_metrics

components/scripts/lib/build_scan.sh

Lines changed: 171 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
#!/usr/bin/env bash
22

33
readonly FETCH_BUILD_SCAN_DATA_JAR="${LIB_DIR}/export-api-clients/fetch-build-scan-data-cmdline-tool-${SCRIPT_VERSION}-all.jar"
4-
readonly MOCK_SCAN_DUMP_TO_CSV_JAR="${LIB_DIR}/export-api-clients/mock-scan-dump-to-csv-tool-${SCRIPT_VERSION}-all.jar"
4+
5+
# Arrays used by callers to access the fetched build scan data
6+
project_names=()
7+
base_urls=()
8+
build_scan_urls=()
9+
build_scan_ids=()
10+
git_repos=()
11+
git_branches=()
12+
git_commit_ids=()
13+
requested_tasks=()
14+
build_outcomes=()
15+
# shellcheck disable=SC2034 # not all scripts use this data
16+
remote_build_cache_urls=()
17+
# shellcheck disable=SC2034 # not all scripts use this data
18+
remote_build_cache_shards=()
19+
20+
# Build caching performance metrics
21+
avoided_up_to_date_num_tasks=()
22+
avoided_up_to_date_avoidance_savings=()
23+
avoided_from_cache_num_tasks=()
24+
avoided_from_cache_avoidance_savings=()
25+
executed_cacheable_num_tasks=()
26+
executed_cacheable_duration=()
27+
executed_not_cacheable_num_tasks=()
28+
executed_not_cacheable_duration=()
529

630
read_build_scan_metadata() {
731
# This isn't the most robust way to read a CSV,
@@ -23,10 +47,114 @@ read_build_data_from_current_dir() {
2347
requested_tasks+=("${tasks}")
2448
}
2549

50+
fetch_build_scan_data() {
51+
# OS specific support (must be 'true' or 'false').
52+
cygwin=false
53+
msys=false
54+
case "$(uname)" in
55+
CYGWIN* )
56+
cygwin=true
57+
;;
58+
MINGW* )
59+
msys=true
60+
;;
61+
esac
62+
63+
# Determine the Java command to use to start the JVM.
64+
if [ -n "$JAVA_HOME" ] ; then
65+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
66+
# IBM's JDK on AIX uses strange locations for the executables
67+
JAVACMD="$JAVA_HOME/jre/sh/java"
68+
else
69+
JAVACMD="$JAVA_HOME/bin/java"
70+
fi
71+
if [ ! -x "$JAVACMD" ] ; then
72+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
73+
74+
Please set the JAVA_HOME variable in your environment to match the
75+
location of your Java installation."
76+
fi
77+
else
78+
JAVACMD="java"
79+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
80+
81+
Please set the JAVA_HOME variable in your environment to match the
82+
location of your Java installation."
83+
fi
84+
85+
# For Cygwin or MSYS, switch paths to Windows format before running java
86+
if [ "$cygwin" = "true" ] || [ "$msys" = "true" ] ; then
87+
APP_HOME=$(cygpath --path --mixed "$APP_HOME")
88+
CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
89+
JAVACMD=$(cygpath --unix "$JAVACMD")
90+
91+
# We build the pattern for arguments to be converted via cygpath
92+
ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
93+
SEP=""
94+
for dir in $ROOTDIRSRAW ; do
95+
ROOTDIRS="$ROOTDIRS$SEP$dir"
96+
SEP="|"
97+
done
98+
OURCYGPATTERN="(^($ROOTDIRS))"
99+
# Add a user-defined pattern to the cygpath arguments
100+
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
101+
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
102+
fi
103+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
104+
i=0
105+
for arg in "$@" ; do
106+
CHECK=$(echo "$arg"|grep -E -c "$OURCYGPATTERN" -)
107+
CHECK2=$(echo "$arg"|grep -E -c "^-") ### Determine if an option
108+
109+
# shellcheck disable=SC2046 # we actually want word splitting
110+
# shellcheck disable=SC2116 # using echo to expand globs
111+
if [ "$CHECK" -ne 0 ] && [ "$CHECK2" -eq 0 ] ; then ### Added a condition
112+
eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg")
113+
else
114+
eval $(echo args$i)="\"$arg\""
115+
fi
116+
# shellcheck disable=SC2003
117+
i=$(expr $i + 1)
118+
done
119+
# shellcheck disable=SC2154
120+
case $i in
121+
0) set -- ;;
122+
1) set -- "$args0" ;;
123+
2) set -- "$args0" "$args1" ;;
124+
3) set -- "$args0" "$args1" "$args2" ;;
125+
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
126+
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
127+
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
128+
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
129+
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
130+
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
131+
esac
132+
fi
133+
134+
# Escape application args
135+
save () {
136+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
137+
echo " "
138+
}
139+
APP_ARGS=$(save "$@")
140+
141+
CLASSPATH="${FETCH_BUILD_SCAN_DATA_JAR}"
142+
# Collect all arguments for the java command, following the shell quoting and substitution rules
143+
eval set -- -Dpicocli.ansi=true -jar "\"$CLASSPATH\"" "$APP_ARGS"
144+
145+
# shellcheck disable=SC2154
146+
if [[ "$_arg_debug" == "on" ]]; then
147+
debug "$JAVACMD $*" 1>&2
148+
print_bl 1>&2
149+
fi
150+
151+
exec "$JAVACMD" "$@"
152+
}
153+
26154
fetch_and_read_build_scan_data() {
27155
# This isn't the most robust way to read a CSV,
28156
# but we control the CSV so we don't have to worry about various CSV edge cases
29-
local args build_cache_metrics_only
157+
local args build_cache_metrics_only fetched_data header_row_read idx
30158
args=()
31159

32160
if [[ "$_arg_debug" == "on" ]]; then
@@ -51,14 +179,49 @@ fetch_and_read_build_scan_data() {
51179
fi
52180
shift
53181
args+=( "$@" )
182+
fetched_data="$(fetch_build_scan_data "${args[@]}")"
54183

55-
raw_build_scan_data="$(invoke_java "$FETCH_BUILD_SCAN_DATA_JAR" "${args[@]}")"
56-
parse_raw_build_scan_data "$raw_build_scan_data" "$build_cache_metrics_only"
57-
}
184+
debug "Raw fetched build scan data"
185+
debug "---------------------------"
186+
debug "${fetched_data}"
187+
debug ""
188+
189+
header_row_read=false
190+
idx=0
191+
192+
# shellcheck disable=SC2034 # not all scripts use all of the fetched data
193+
while IFS=, read -r field_1 field_2 field_3 field_4 field_5 field_6 field_7 field_8 field_9 field_10 field_11 field_12 field_13 field_14 field_15 field_16 field_17 field_18 field_19; do
194+
if [[ "$header_row_read" == "false" ]]; then
195+
header_row_read=true
196+
continue;
197+
fi
198+
199+
if [[ "${build_cache_metrics_only}" != "true" ]]; then
200+
project_names[idx]="$field_1"
201+
base_urls[idx]="$field_2"
202+
build_scan_urls[idx]="$field_3"
203+
build_scan_ids[idx]="$field_4"
204+
git_repos[idx]="$field_5"
205+
git_branches[idx]="$field_6"
206+
git_commit_ids[idx]="$field_7"
207+
requested_tasks[idx]="$(remove_clean_task "${field_8}")"
208+
build_outcomes[idx]="$field_9"
209+
remote_build_cache_urls[idx]="${field_10}"
210+
remote_build_cache_shards[idx]="${field_11}"
211+
fi
212+
213+
# Build caching performance metrics
214+
avoided_up_to_date_num_tasks[idx]="${field_12}"
215+
avoided_up_to_date_avoidance_savings[idx]="${field_13}"
216+
avoided_from_cache_num_tasks[idx]="${field_14}"
217+
avoided_from_cache_avoidance_savings[idx]="${field_15}"
218+
executed_cacheable_num_tasks[idx]="${field_16}"
219+
executed_cacheable_duration[idx]="${field_17}"
220+
executed_not_cacheable_num_tasks[idx]="${field_18}"
221+
executed_not_cacheable_duration[idx]="${field_19}"
58222

59-
read_build_scan_from_scan_dump() {
60-
raw_build_scan_data="$(invoke_java "$MOCK_SCAN_DUMP_TO_CSV_JAR")"
61-
parse_raw_build_scan_data "$raw_build_scan_data"
223+
((idx++))
224+
done <<< "${fetched_data}"
62225
}
63226

64227
detect_warnings_from_build_scans() {

components/scripts/lib/cli-parsers/gradle/03-cli-parser.m4

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# Created by argbash-init v2.10.0
44
# ARG_OPTIONAL_BOOLEAN([fail-if-not-fully-cacheable],[f],[])
55
# ARG_HELP([This function is overridden later on.])
6-
# ARG_OPTIONAL_BOOLEAN([offline],[],[],[off])
76
# ARG_VERSION([print_version],[v],[version],[])
87
# ARGBASH_WRAP([common])
98
# ARGBASH_SET_INDENT([ ])

components/scripts/lib/config.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ process_arguments() {
6262
if [ -n "${_arg_interactive+x}" ]; then
6363
interactive_mode="${_arg_interactive}"
6464
fi
65-
66-
if [ -n "${_arg_offline+x}" ]; then
67-
offline_mode="${_arg_offline}"
68-
fi
6965
}
7066

7167
validate_required_config() {

components/scripts/lib/java.sh

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)