Skip to content

Conversation

@sergehuber
Copy link
Contributor

Summary

This PR implements UNOMI-887 by introducing a single, enhanced build.sh for Unomi 3.x that standardizes build, deploy, and optional Karaf run. It replaces multiple ad‑hoc scripts and adds strong error handling, readable output, and comprehensive environment validation.

What’s changed

  • Added: build.sh (unified build/deploy/run, colorized output, progress, traps with line/function traces).
  • Removed: buildAndRun.sh, buildAndRunNoTests.sh, compileDeploy.sh, generate-package.sh.
  • Preflight validation: Java/Maven/GraphViz, memory/disk, Maven settings, port availability.
  • Flexible flags: --skip-tests, --integration-tests, --single-test, --use-opensearch, --it-debug/ports/suspend, -X/--offline, --no-maven-cache/--purge-maven-cache, --deploy/--karaf-home, --debug/ports/suspend, --no-karaf, --auto-start.
  • Deployment helpers: copy KAR to Karaf deploy, purge Karaf caches; optional GeoLite2/Geonames copy if present.
  • Environment: honors NO_COLOR; macOS/Linux friendly with Apple Silicon guidance.

Rationale

  • Improve developer experience and reduce troubleshooting time via proactive checks and clearer, structured feedback.
  • Standardize and simplify common workflows into one entrypoint that’s easier to maintain as Unomi evolves.

How to use

  • Show help and examples:
    • ./build.sh --help
  • Typical builds:
    • ./build.sh
    • ./build.sh --integration-tests --use-opensearch
    • ./build.sh --skip-tests
  • Deploy to an existing Karaf:
    • export UNOMI_VERSION=3.0.0-SNAPSHOT
    • ./build.sh --deploy --karaf-home ~/apache-karaf
  • Debug:
    • ./build.sh --debug --debug-port 5005 --debug-suspend
    • ./build.sh --integration-tests --single-test org.apache.unomi.itests.graphql.GraphQLEventIT --it-debug --it-debug-suspend

Testing done

  • Verified all CLI flags, including integration-test selection and debug modes.
  • Validated error handling (traps, line numbers, function traces) and color output on supported terminals.
  • Tested deployment to an existing Karaf instance and optional data file copy.

Backwards compatibility

  • Removes legacy scripts in favor of build.sh; workflows are preserved with clearer flags.
  • No functional changes to product modules; only build ergonomics improved.

Documentation

  • Self-documented via ./build.sh --help with examples; aligns with NO_COLOR standard.

Add build.sh: unified build/deploy/run script with robust error handling, colorized/structured output, and preflight checks (tools, system resources, Maven settings, ports).
Support rich CLI options: tests/integration, OpenSearch, debug/ports/suspend, offline/cache control, migration-test skip, single-test, deploy to Karaf.
Replace legacy scripts: remove buildAndRun.sh, buildAndRunNoTests.sh, compileDeploy.sh, generate-package.sh.
Improve DX: clearer failures, consistent workflows across environments, NO_COLOR adherence, macOS/Linux friendly (incl. Apple Silicon hints).
Notes: deployment expects UNOMI_VERSION for KAR/package paths; optional Geo databases copied when present.
No code changes to modules; build behavior is unchanged unless new flags are used.
@jsinovassin
Copy link
Contributor

Thanks for the PR!
What do you think of adding a part in the documentation, in the Building section to inform the users that this script exists
https://unomi.apache.org/manual/3_0_x/index.html#_building_2

- Fix color readability in build.sh examples section: replace GRAY with NC
  (no color) for better terminal readability. Use NC once at the start
  instead of wrapping each line with color codes.

- Add comprehensive documentation for build.sh script in Building section:
  * Add brief mention at the start of Building section with cross-reference
  * Add new "Using the build.sh script" subsection with:
    - Overview of script features and benefits
    - Step-by-step usage instructions
    - Complete set of examples matching build.sh --help output
    - All examples use plain commands without prompt markers

- Minor formatting: align help output option descriptions for consistency

The documentation examples now exactly match those displayed by build.sh --help,
ensuring consistency between the script and its documentation.
@sergehuber
Copy link
Contributor Author

Hello @jsinovassin thanks for the review. I have addressed your change request and also added documentation about the script in the building documentation.

Copy link
Contributor

@jsinovassin jsinovassin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good! Thank you for the update.

@sergehuber sergehuber merged commit 205f581 into master Nov 28, 2025
5 checks passed
@sergehuber sergehuber deleted the UNOMI-887-build-scripts branch November 28, 2025 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants