Skip to content

Optimize build: share OpenAPI generator JAR across client modules#419

Merged
jiang95-dev merged 1 commit intolinkedin:mainfrom
cbb330:optimize-openapi-jar-caching
Jan 15, 2026
Merged

Optimize build: share OpenAPI generator JAR across client modules#419
jiang95-dev merged 1 commit intolinkedin:mainfrom
cbb330:optimize-openapi-jar-caching

Conversation

@cbb330
Copy link
Collaborator

@cbb330 cbb330 commented Dec 31, 2025

Summary

Share OpenAPI generator JAR across client modules to reduce build time by 10%.

Previously, each client module (hts, tableclient, jobsclient) downloaded the OpenAPI generator CLI JAR (~24MB) to its own $buildDir/bin directory. This change uses a shared location with file locking to ensure only one download occurs.

Build time improvement (./gradlew clean build -x test):

Time
Before 311s (5m 10s)
After 280s (4m 39s)
Improvement -31s (10% faster)

Changes

  • Client-facing API Changes
  • Internal API Changes
  • Bug Fixes
  • New Features
  • Performance Improvements
  • Code Style
  • Refactoring
  • Documentation
  • Tests

Performance Improvements

  • Modified client/common/codegen.build.gradle to use shared JAR location (${rootProject.buildDir}/openapi-cli)
  • Updated client/common/jar_download.sh with:
    • Portable file locking using mkdir (works on Linux/macOS)
    • Download to temp file then atomic mv to final location
    • Proper error handling and lock cleanup

Before (3 separate downloads):

> Task :client:hts:setUp
Downloading openapi generator JAR in bin folder .../build/hts/bin if needed...
> Task :client:jobsclient:setUp
Downloading openapi generator JAR in bin folder .../build/jobsclient/bin if needed...
> Task :client:tableclient:setUp  
Downloading openapi generator JAR in bin folder .../build/tableclient/bin if needed...

After (1 shared download):

> Task :client:hts:setUp
Downloading openapi generator JAR in bin folder .../build/openapi-cli if needed...
Downloading openapi-generator-cli-5.3.0.jar...
> Task :client:jobsclient:setUp
openapi-generator-cli-5.3.0.jar exists.
> Task :client:tableclient:setUp
openapi-generator-cli-5.3.0.jar exists.

Testing Done

  • Manually Tested on local docker setup. Please include commands ran, and their output.
  • Added new tests for the changes made.
  • Updated existing tests to reflect the changes made.
  • No tests added or updated. Please explain why. If unsure, please feel free to ask for help.
  • Some other form of testing like staging or soak time in production. Please explain.

Manual Testing

  1. Verified JAR is downloaded once to shared location and reused by other client modules
  2. Verified file locking works correctly with parallel builds (concurrent tasks wait for download)
  3. Measured before/after build times with ./gradlew clean build -x test

No Tests Added

This is a build infrastructure change that doesn't affect runtime behavior. The optimization is validated by the build output showing "exists" messages for subsequent client modules.

Additional Information

  • Breaking Changes
  • Deprecations
  • Large PR broken into smaller PRs, and PR plan linked in the description.

🤖 Generated with Claude Code

@jiang95-dev
Copy link
Collaborator

Thanks, the script is great and bulletproof! However, I think there's an alternative without using locks. We can make the setup() task only in :client:common (of course the folder must be shared), and then the clientCodeGen() task in each module to depend on the setup() task. Right now we are bringing the setup() task in each module so that's why it is executed multiple times. I think this will be more efficient since we don't need locks or temp files copy.

Instead of file locking in shell script, move setUp task to :client:common
and have each module's clientCodeGen depend on :client:common:setUp.
This leverages Gradle's built-in task ordering - simpler and more efficient.

Changes:
- Add client/common/build.gradle with single setUp task
- Update codegen.build.gradle to depend on :client:common:setUp
- Simplify jar_download.sh (no locking needed)
@cbb330 cbb330 force-pushed the optimize-openapi-jar-caching branch from 64759d7 to 7efb046 Compare January 3, 2026 02:41
@jiang95-dev jiang95-dev merged commit 6e6195a into linkedin:main Jan 15, 2026
1 check passed
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