Skip to content

Commit e257e6b

Browse files
Fix redundant git clone and build delays in setup-workspace.sh (#4290)
* Fix redundant profile activation in setup-workspace.sh Explicitly disable the `download-cn1-binaries` Maven profile during the `setup-workspace.sh` script execution. The script already provisions these binaries externally and passes the path via `-Dcn1.binaries`, but the profile was still activating and attempting a redundant `git clone` into the target directory, causing concurrency errors (exit code 128) and significant delays. * Optimize setup-workspace.sh performance Enhance build performance in `scripts/setup-workspace.sh` by: 1. Adding `-T 1C` to Maven commands to enable parallel builds using one thread per core. 2. Adding `-Dmaven.javadoc.skip=true` and `-Dmaven.source.skip=true` to skip time-consuming and unnecessary documentation and source artifact generation during the workspace setup phase. 3. Explicitly disabling the `download-cn1-binaries` profile (`-P !download-cn1-binaries`) to prevent redundant `git clone` operations that were causing "Result: 128" errors and delays. * Optimize setup-workspace.sh and trigger CI on changes 1. Optimize `scripts/setup-workspace.sh` build time by enabling parallel builds (`-T 1C`) and skipping unnecessary Javadoc/Source generation. 2. Fix "Result: 128" git errors by explicitly disabling the `download-cn1-binaries` profile (`-P !download-cn1-binaries`). 3. Fix "Stubber.jar not found" build failure by explicitly passing `-Dcn1.binaries="$CN1_BINARIES"` to Maven commands, ensuring the external binaries are located. 4. Update `.github/workflows/pr.yml` to trigger the PR CI workflow when `scripts/setup-workspace.sh` is modified, enabling validation of these changes. * Fix Android port build script and PR CI triggers 1. **Optimize `scripts/setup-workspace.sh`:** * Enable parallel builds (`-T 1C`) for faster execution. * Skip Javadoc and Source generation to save time. * Explicitly disable the `download-cn1-binaries` profile (`-P !download-cn1-binaries`) to prevent redundant git operations and "Result: 128" errors. * Pass `-Dcn1.binaries="$CN1_BINARIES"` to ensure the build can locate the pre-provisioned binaries. 2. **Fix `scripts/build-android-port.sh`:** * Apply the same fixes as above (disable download profile, pass binaries path, optimization flags) to resolve "Result: 128" errors during the Android port build stage. 3. **Update `.github/workflows/pr.yml`:** * Add `!scripts/setup-workspace.sh` to the `paths-ignore` list for both `push` and `pull_request` triggers. This ensures that changes to the setup script properly trigger the CI workflow for validation. * Fix Android port build scripts and CI triggers 1. **Optimize `scripts/setup-workspace.sh`**: * Enable parallel Maven builds (`-T 1C`) for faster execution. * Skip Javadoc and source generation (`-Dmaven.javadoc.skip=true`, `-Dmaven.source.skip=true`). * Disable the `download-cn1-binaries` profile (`-P !download-cn1-binaries`) to prevent redundant cloning and "Result: 128" errors. * Explicitly pass `-Dcn1.binaries="$CN1_BINARIES"` to ensure binaries are located correctly. 2. **Fix `scripts/build-android-port.sh`**: * Define `CN1_BINARIES` variable with fallback logic to prevent "unbound variable" errors. * Apply the same Maven optimizations and profile deactivation as in `setup-workspace.sh` to resolve build failures. 3. **Update `.github/workflows/pr.yml`**: * Add `!scripts/setup-workspace.sh` to `paths-ignore` for both `push` and `pull_request` triggers to ensure CI runs when this script is modified. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 7affe5a commit e257e6b

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.github/workflows/pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- '.github/workflows/scripts-android.yml'
99
- '.github/workflows/scripts-ios.yml'
1010
- 'scripts/**'
11+
- '!scripts/setup-workspace.sh'
1112
- 'docs/**'
1213
- '**/*.md'
1314
- '.github/workflows/developer-guide-docs.yml'
@@ -20,6 +21,7 @@ on:
2021
- '.github/workflows/scripts-android.yml'
2122
- '.github/workflows/scripts-ios.yml'
2223
- 'scripts/**'
24+
- '!scripts/setup-workspace.sh'
2325
- 'docs/**'
2426
- '**/*.md'
2527
- '.github/workflows/developer-guide-docs.yml'

scripts/build-android-port.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ TMPDIR="${TMPDIR%/}"
1515
DOWNLOAD_DIR="${TMPDIR%/}/codenameone-tools"
1616
log "The DOWNLOAD_DIR is ${DOWNLOAD_DIR}"
1717

18+
CN1_BINARIES_PARENT="$(cd .. && pwd -P)"
19+
CN1_BINARIES="${CN1_BINARIES_PARENT%/}/cn1-binaries"
20+
if [ ! -d "$CN1_BINARIES" ]; then
21+
# Fallback to the maven build dir if the external one doesn't exist
22+
CN1_BINARIES="$(pwd)/maven/target/cn1-binaries"
23+
fi
24+
1825
ENV_DIR="$DOWNLOAD_DIR/tools"
1926
ENV_FILE="$ENV_DIR/env.sh"
2027

@@ -119,9 +126,9 @@ run_maven() {
119126

120127
BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar"
121128
if [ ! -f "$BUILD_CLIENT" ]; then
122-
if ! run_maven -q -f maven/pom.xml cn1:install-codenameone "$@"; then
129+
if ! run_maven -q -f maven/pom.xml -Dcn1.binaries="$CN1_BINARIES" -P !download-cn1-binaries cn1:install-codenameone "$@"; then
123130
[ -f maven/CodeNameOneBuildClient.jar ] && cp maven/CodeNameOneBuildClient.jar "$BUILD_CLIENT" || true
124131
fi
125132
fi
126133

127-
run_maven -q -f maven/pom.xml -pl android -am -Dmaven.javadoc.skip=true -Djava.awt.headless=true clean install "$@"
134+
run_maven -q -f maven/pom.xml -pl android -am -Dcn1.binaries="$CN1_BINARIES" -P !download-cn1-binaries -T 1C -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Djava.awt.headless=true clean install "$@"

scripts/setup-workspace.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,21 @@ if [ ! -d "$CN1_BINARIES/.git" ]; then
226226
fi
227227

228228
log "Building Codename One core modules"
229-
"$MAVEN_HOME/bin/mvn" -f maven/pom.xml -DskipTests -Djava.awt.headless=true -Dcn1.binaries="$CN1_BINARIES" -Dcodename1.platform=javase -P local-dev-javase,compile-android install "$@"
229+
"$MAVEN_HOME/bin/mvn" -f maven/pom.xml -T 1C -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -DskipTests -Djava.awt.headless=true -Dcn1.binaries="$CN1_BINARIES" -Dcodename1.platform=javase -P local-dev-javase,compile-android,!download-cn1-binaries install "$@"
230230

231231
log "Building Codename One Maven plugin"
232232
"$MAVEN_HOME/bin/mvn" -f maven/pom.xml \
233233
-pl codenameone-maven-plugin -am \
234+
-T 1C -Dmaven.javadoc.skip=true -Dmaven.source.skip=true \
234235
-DskipTests -Djava.awt.headless=true \
236+
-Dcn1.binaries="$CN1_BINARIES" \
237+
-P !download-cn1-binaries \
235238
install "$@"
236239

237240
BUILD_CLIENT="$HOME/.codenameone/CodeNameOneBuildClient.jar"
238241
log "Ensuring CodeNameOneBuildClient.jar is installed"
239242
if [ ! -f "$BUILD_CLIENT" ]; then
240-
if ! "$MAVEN_HOME/bin/mvn" -f maven/pom.xml cn1:install-codenameone "$@"; then
243+
if ! "$MAVEN_HOME/bin/mvn" -f maven/pom.xml -Dcn1.binaries="$CN1_BINARIES" -P !download-cn1-binaries cn1:install-codenameone "$@"; then
241244
log "Falling back to copying CodeNameOneBuildClient.jar"
242245
mkdir -p "$(dirname "$BUILD_CLIENT")"
243246
cp maven/CodeNameOneBuildClient.jar "$BUILD_CLIENT" || true
@@ -272,6 +275,6 @@ if [ "${skip_archetypes:-0}" -eq 0 ]; then
272275
log "Updating cn1-maven-archetypes version from $current_version to $CN1_VERSION to match local snapshot"
273276
"$MAVEN_HOME/bin/mvn" -q -B versions:set -DnewVersion="$CN1_VERSION" -DgenerateBackupPoms=false
274277
fi
275-
"$MAVEN_HOME/bin/mvn" -DskipTests -DskipITs=true -Dinvoker.skip=true install
278+
"$MAVEN_HOME/bin/mvn" -T 1C -DskipTests -DskipITs=true -Dinvoker.skip=true install
276279
) || log "Archetype mvn install failed; continuing."
277280
fi

0 commit comments

Comments
 (0)