Skip to content

Commit f6d7996

Browse files
committed
Add workspace environment logging to android scripts
1 parent d0acdc1 commit f6d7996

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

scripts/build-android-app.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ ba_log "Loading workspace environment from $ENV_FILE"
2121
if [ -f "$ENV_FILE" ]; then
2222
ba_log "Workspace environment file metadata"
2323
ls -l "$ENV_FILE" | while IFS= read -r line; do ba_log "$line"; done
24+
ba_log "Workspace environment file contents"
25+
sed 's/^/[build-android-app] ENV: /' "$ENV_FILE"
2426
# shellcheck disable=SC1090
2527
source "$ENV_FILE"
2628
ba_log "Loaded environment: JAVA_HOME=${JAVA_HOME:-<unset>} JAVA_HOME_17=${JAVA_HOME_17:-<unset>} MAVEN_HOME=${MAVEN_HOME:-<unset>}"

scripts/build-android-port.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,35 @@ DOWNLOAD_DIR="${TMPDIR%/}/codenameone-tools"
1616
log "The DOWNLOAD_DIR is ${DOWNLOAD_DIR}"
1717

1818
ENV_DIR="$DOWNLOAD_DIR/tools"
19+
ENV_FILE="$ENV_DIR/env.sh"
1920

20-
if [ -f "$ENV_DIR/env.sh" ]; then
21-
source "$ENV_DIR/env.sh"
21+
log "Loading workspace environment from $ENV_FILE"
22+
if [ -f "$ENV_FILE" ]; then
23+
log "Workspace environment file metadata"
24+
ls -l "$ENV_FILE" | while IFS= read -r line; do log "$line"; done
25+
log "Workspace environment file contents"
26+
sed 's/^/[build-android-port] ENV: /' "$ENV_FILE"
27+
# shellcheck disable=SC1090
28+
source "$ENV_FILE"
2229
else
30+
log "Workspace tools not found. Running setup-workspace.sh"
2331
./scripts/setup-workspace.sh -q -DskipTests
24-
source "$ENV_DIR/env.sh"
32+
if [ -f "$ENV_FILE" ]; then
33+
log "Workspace environment file metadata after setup"
34+
ls -l "$ENV_FILE" | while IFS= read -r line; do log "$line"; done
35+
log "Workspace environment file contents after setup"
36+
sed 's/^/[build-android-port] ENV: /' "$ENV_FILE"
37+
# shellcheck disable=SC1090
38+
source "$ENV_FILE"
39+
else
40+
log "Failed to create workspace environment at $ENV_FILE" >&2
41+
exit 1
42+
fi
2543
fi
2644

27-
if ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\.0'; then
45+
log "Loaded environment: JAVA_HOME=${JAVA_HOME:-<unset>} JAVA_HOME_17=${JAVA_HOME_17:-<unset>} MAVEN_HOME=${MAVEN_HOME:-<unset>}"
46+
47+
if [ -z "${JAVA_HOME_17:-}" ] || ! "${JAVA_HOME_17:-}/bin/java" -version 2>&1 | grep -q '17\\.0'; then
2848
echo "Failed to provision JDK 17" >&2
2949
exit 1
3050
fi

scripts/setup-workspace.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,21 @@ mkdir -p ../cn1-binaries
2525
CN1_BINARIES="$(cd ../cn1-binaries && pwd -P)"
2626
rm -Rf ../cn1-binaries
2727

28+
ENV_FILE="$ENV_DIR/env.sh"
29+
2830
log "The DOWNLOAD_DIR is ${DOWNLOAD_DIR}"
2931

3032
mkdir -p ~/.codenameone
3133
cp maven/CodeNameOneBuildClient.jar ~/.codenameone
3234

3335
# Reuse previously saved environment if present (so we can skip downloads)
34-
if [ -f "$ENV_DIR/env.sh" ]; then
36+
if [ -f "$ENV_FILE" ]; then
37+
log "Found existing workspace environment at $ENV_FILE"
38+
ls -l "$ENV_FILE" | while IFS= read -r line; do log "$line"; done
39+
log "Existing workspace environment file contents"
40+
sed 's/^/[setup-workspace] ENV: /' "$ENV_FILE"
3541
# shellcheck disable=SC1090
36-
source "$ENV_DIR/env.sh"
42+
source "$ENV_FILE"
3743
fi
3844

3945
JAVA_HOME="${JAVA_HOME:-}"
@@ -131,16 +137,25 @@ else
131137
log "Using existing Maven at $MAVEN_HOME"
132138
fi
133139

134-
log "Writing environment to $ENV_DIR/env.sh"
135-
cat > "$ENV_DIR/env.sh" <<ENV
140+
log "Writing environment to $ENV_FILE"
141+
cat > "$ENV_FILE" <<ENV
136142
export JAVA_HOME="$JAVA_HOME"
137143
export JAVA_HOME_17="$JAVA_HOME_17"
138144
export MAVEN_HOME="$MAVEN_HOME"
139145
export PATH="\$JAVA_HOME/bin:\$MAVEN_HOME/bin:\$PATH"
140146
ENV
141147

148+
log "Workspace environment file metadata"
149+
if [ -f "$ENV_FILE" ]; then
150+
ls -l "$ENV_FILE" | while IFS= read -r line; do log "$line"; done
151+
log "Workspace environment file contents"
152+
sed 's/^/[setup-workspace] ENV: /' "$ENV_FILE"
153+
else
154+
log "Environment file was not created at $ENV_FILE" >&2
155+
fi
156+
142157
# shellcheck disable=SC1090
143-
source "$ENV_DIR/env.sh"
158+
source "$ENV_FILE"
144159

145160
log "JDK 8 version:"; "$JAVA_HOME/bin/java" -version
146161
log "JDK 17 version:"; "$JAVA_HOME_17/bin/java" -version

0 commit comments

Comments
 (0)