Update to JDK21 and Gradle 9 by homfunc · Pull Request #1321 · grobidOrg/grobid (original) (raw)

@homfunc

Grobid Build Migration Summary

Migration Completed ✅

Migration from JDK 8 to JDK 21 and Gradle 6 to Gradle 9

Date: August 1-2, 2025 Status: SUCCESSFUL (Optimized)

What Was Done

1. Core Build System Updates

2. Plugin Updates

Updated all Gradle plugins to versions compatible with Gradle 9:

Plugin Old Version New Version Notes
Kotlin JVM 1.x 2.0.0 Compatible with Java 21
Shadow com.github.jengelman.gradle.shadow com.gradleup.shadow 8.3.8 Changed provider
Test Logger - 4.0.0 Added for better test output
Coveralls - 2.12.2 Updated for compatibility
Release - 3.1.0 Updated for compatibility

3. Build Configuration Fixes

4. Dependency Updates

Updated dependencies for Java 21 compatibility:

5. JaCoCo Configuration

6. Module System Compatibility

Added JVM arguments for Java 21 module system compatibility:

jvmArgs "--add-opens", "java.base/java.lang=ALL-UNNAMED",
        "--add-opens", "java.base/java.util=ALL-UNNAMED"

7. Git Integration Fix

Test Results

Before Migration

After Migration

Known Issues and Workarounds

1. PowerMock Compatibility (Temporary)

Issue: PowerMock has module system compatibility issues with Java 21 Workaround: Added JVM arguments to open required modules TODO: Replace PowerMock with Mockito (see TODO_REPLACE_POWERMOCK.md)

2. Git Revision Warning

Issue: Git revision extraction shows method not found warning Status: Non-critical, doesn't affect build success Impact: Git revision defaults to "unknown" but build remains successful

Files Modified

Core Build Files

New Files Created

Verification Commands

# Verify Java version
./gradlew -version

# Run full build
./gradlew build

# Run tests specifically
./gradlew test

# Check project info
./gradlew projects

High Priority

  1. PowerMock Replacement: Follow the plan in TODO_REPLACE_POWERMOCK.md
  2. Configuration Cache: Enable Gradle configuration cache for faster builds (suggested by Gradle)
  3. Dependency Audit: Review and update remaining dependencies

Medium Priority

  1. Build Optimization: Further optimize build performance and address deprecation warnings
  2. Documentation Update: Update project documentation for new build requirements
  3. Git Revision Fix: Resolve the git revision extraction warning (optional)

Low Priority

  1. Gradle 10 Preparation: Address deprecation warnings for future Gradle versions
  2. Java 21 Features: Consider adopting Java 21 language features where beneficial

Benefits Achieved

Performance

Compatibility

Development Experience

Conclusion

The migration was successful with all major functionality preserved. The build system is now modern, secure, and ready for future development. Recent optimizations have further streamlined the build configuration using minimal necessary changes.

Key Achievements:

The only remaining task is the PowerMock replacement, which is documented and can be addressed at a convenient time.

Migration Status: COMPLETE AND OPTIMIZED ✅