Skip to content

feat: add Gradle build with GraalVM Native Image support - #2

Open
Ryan-Miao wants to merge 1 commit into
abel533:mainfrom
Ryan-Miao:feature/gradle-graalvm-native
Open

feat: add Gradle build with GraalVM Native Image support#2
Ryan-Miao wants to merge 1 commit into
abel533:mainfrom
Ryan-Miao:feature/gradle-graalvm-native

Conversation

@Ryan-Miao

Copy link
Copy Markdown

Summary

  • Add Gradle build configuration as an alternative to Maven
  • Enable GraalVM Native Image compilation for dramatically improved CLI startup performance
  • Use JLine JNI provider for GraalVM compatibility (FFM as runtime fallback)
  • Gradle wrapper 9.0.0 with Tencent mirror for China users

Performance Benchmark (Ubuntu, JDK 25.0.2)

Metric JAR (Maven/Gradle) Native Image Improvement
Startup Time ~2500ms ~107ms 23x faster
Memory (RSS) 276 MB 96 MB 65% reduction
Binary Size 72 MB (JAR) 163 MB (native) Single file, no JRE needed

Usage

# Build JAR (same as Maven)
./gradlew bootJar

# Build native image (requires GraalVM JDK)
./gradlew nativeCompile

# Quick dev build (faster compilation, less optimized)
./gradlew nativeCompile -PquickBuild

# Run
java --enable-preview --enable-native-access=ALL-UNNAMED -jar build/libs/claude-code-java-0.2.0-SNAPSHOT.jar
# or native:
./build/native/nativeCompile/claude-code-java

Files Added/Modified

  • build.gradle — Gradle build config with Spring Boot + GraalVM plugin
  • settings.gradle — Project name
  • gradlew / gradlew.bat — Gradle wrapper scripts
  • gradle/wrapper/ — Wrapper jar + properties (Tencent mirror)
  • .gitignore — Added Gradle build artifacts

Notes

  • Maven is fully preserved — this PR adds Gradle as a parallel option, not a replacement
  • GraalVM Native Image requires GraalVM JDK installed (e.g., via SDKMAN: sdk install java 25.0.2-graal)
  • Native image is platform-specific — needs to be built on the target OS

Test plan

  • ./gradlew bootJar — JAR builds and runs successfully
  • ./gradlew nativeCompile — Native image compiles and runs
  • Startup benchmark: 2500ms → 107ms
  • Memory benchmark: 276MB → 96MB

🤖 Generated with Claude Code

Add Gradle build configuration as an alternative to Maven, with GraalVM
native image compilation support for dramatically improved startup performance.

Key changes:
- build.gradle with Spring Boot 4.1.0-M2 + GraalVM plugin 0.10.6
- Gradle wrapper 9.0.0 with Tencent mirror for China users
- JLine JNI provider for GraalVM compatibility (FFM as runtime fallback)
- .gitignore updated for Gradle build artifacts

Performance benchmark results (Ubuntu, JDK 25.0.2):
- Startup: 2500ms (JAR) → 107ms (native) = 23x faster
- Memory: 276MB (JAR) → 96MB (native) = 65% reduction

Usage:
  ./gradlew bootJar                  # Build JAR
  ./gradlew nativeCompile            # Build native image
  ./gradlew nativeCompile -PquickBuild  # Quick dev build (less optimized)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant