auth0-java-mvc-common icon indicating copy to clipboard operation
auth0-java-mvc-common copied to clipboard

Add jakarta support through bytecode transformation

Open luckpoint opened this issue 10 months ago • 0 comments

Changes

This PR introduces comprehensive Jakarta EE support for the auth0-java-mvc-common library through Eclipse Transformer-based bytecode transformation. This enables the library to work seamlessly with both traditional Java EE (javax.servlet) and modern Jakarta EE (jakarta.servlet) environments without requiring separate codebases.

Key Changes:

  • Build System Enhancements:

    • Added Jakarta test source set configuration (src/testJakarta/)
    • Implemented Eclipse Transformer integration for automatic javax→jakarta package transformation
    • Created performJakartaTransformation and transformJarToJakarta Gradle tasks
    • Added Jakarta-specific dependency configurations with jakarta.servlet-api:5.0.0
  • Test Coverage:

    • Added JakartaCompatibilityTest.java to verify Jakarta EE servlet API compatibility
    • Implemented comprehensive tests for HttpServletRequest, HttpServletResponse, HttpSession, and Cookie Jakarta classes
    • Added testJakarta task to run Jakarta-specific tests with transformed bytecode
  • Distribution:

    • Generates dual JAR artifacts: standard and Jakarta-compatible (with jakarta classifier)
    • Maintains backward compatibility with existing javax.servlet-based applications
    • Supports Tomcat 10+ and other Jakarta EE 9+ application servers
  • Documentation:

    • Updated README.md with Jakarta EE installation instructions for both Maven and Gradle
    • Added clear distinction between javax.servlet and jakarta.servlet usage patterns
    • Specified minimum version requirements (jakarta.servlet 5.0+)

Classes and Methods Added:

  • JakartaCompatibilityTest class with Jakarta servlet API verification tests
  • Gradle tasks: performJakartaTransformation, transformJarToJakarta, testJakarta
  • Jakarta source set configuration in build.gradle

Endpoints/APIs:

  • No public API changes - maintains full compatibility with existing codebase
  • Jakarta version accessible via Maven/Gradle classifier: mvc-auth-commons:1.12.0:jakarta

References

Testing

This change has been thoroughly tested to ensure compatibility across both servlet environments:

  • [x] This change adds test coverage

    • Added JakartaCompatibilityTest with comprehensive Jakarta servlet API tests
    • Tests verify HttpServletRequest, HttpServletResponse, HttpSession, and Cookie functionality
    • Integration tests confirm transformed bytecode works with Jakarta dependencies
  • [x] This change has been tested on the latest version of Java or why not

./gradlew testInJava-8 testInJava-11 testInJava-17 testInJava-21 --parallel

> Configure project :
Using version 1.12.0 for mvc-auth-commons group com.auth0
Test will be running in 8
Test will be running in 11
Test will be running in 17
Test will be running in 21

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 2s
7 actionable tasks: 7 up-to-date

Manual Testing:

  • Deploy to Tomcat 10+ with Jakarta classifier dependency
  • https://github.com/luckpoint/auth0-servlet-sample/tree/feat/jakarta-package

Checklist

luckpoint avatar Jun 03 '25 13:06 luckpoint