Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

xvik/guice-jakartaee

Repository files navigation

Guice converted to jakarta namespace

DEPRECATED Guice 7 introduced native jakarta support.

Google guice does not support jakarta namespace yet.

This project is not a fork. It just converts guice automatically using tomcat migration tool and re-publish converted jars into maven central (with different group).

  • Source jars loaded from maven central and converted automatically
  • Project compiles converted sources producing all required artifacts for maven central
  • POM files are manually re-worked (to contain correct jakarta dependencies)
  • MANIFEST re-applied (to keep OSGI exports)

Migrated apis:

  • jakarta.inject (all modules)
  • jakarta.servlet (guice-servlet)
  • jakarta.persistence (guice-persist)

Migration project was created for dropwizard-guicey to make it compatible with dropwizard 4.

Attention

Migration from javax.inject means that your code should not use javax.inject.Inject and other annotations. All such places must be changed either to jakarta jakarta.inject.Inject or to google com.google.inject.Inject (same for Singleton, Provider, etc.)

Guice will simply ignore old annotations! As a result, if you use some 3rd party library, it must also not use javax.inject classes or guice might work incorrectly.

For gradle, there is a special plugin which could convert dependencies automatically (assuming you building application and bundle all dependencies in it).

For library authors

The simplest migration startegy for 3rd party guice libraries is to avoid javax.inject annotations and use native guice com.google.inject annotations instead. This way library would be compatible with both javax and jakarta namespaces.

No need to depend libraries on this re-packaged guice version - simply avoid javax usage.

Setup

Currently published 5.1.0-rc.2 in order to gather feedback and finally release 5.1.0 without issues (in order to strictly follow guice version). Where problems could be: wrong dependencies in POM, incorrect METADATA (for OSGI)

Maven Central

Notable differences with original guice:

  • ASM not bundled inside guice jar, asm updated to 9.5
  • Guava updated to 31.1

Gradle:

dependencies {
    implementation platform('ru.vyarus.guice.jakarta:guice-bom:5.1.0-rc.2')

    implementation 'ru.vyarus.guice.jakarta:guice'
    implementation 'ru.vyarus.guice.jakarta:guice-servlet'
}

Maven:

<dependencyManagement>  
    <dependencies>
        <dependency>
            <groupId>ru.vyarus.guice.jakarta</groupId>
            <artifactId>guice-bom</artifactId>
            <version>5.1.0-rc.2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>          
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>ru.vyarus.guice.jakarta</groupId>
        <artifactId>guice</artifactId>
    </dependency>
    <dependency>
        <groupId>ru.vyarus.guice.jakarta</groupId>
        <artifactId>guice-servlet</artifactId>
    </dependency>
</dependencies>

Dependencies could, of course, be used without BOM too.

Usage

Original (javax.) dependency Migrated (jakarta.) dependency
com.google.inject:guice-bom ru.vyarus.guice.jakarta:guice-bom
com.google.inject:guice ru.vyarus.guice.jakarta:guice
com.google.inject.extensions:guice-assistedinject ru.vyarus.guice.jakarta:guice-assistedinject
com.google.inject.extensions:guice-grapher ru.vyarus.guice.jakarta:guice-grapher
com.google.inject.extensions:guice-jmx ru.vyarus.guice.jakarta:guice-jmx
com.google.inject.extensions:guice-jndi ru.vyarus.guice.jakarta:guice-jndi
com.google.inject.extensions:guice-persist ru.vyarus.guice.jakarta:guice-persist
com.google.inject.extensions:guice-servlet ru.vyarus.guice.jakarta:guice-servlet
com.google.inject.extensions:guice-testlib ru.vyarus.guice.jakarta:guice-testlib
com.google.inject.extensions:guice-throwingproviders ru.vyarus.guice.jakarta:guice-throwingproviders

NOTE: spring and struct2 modules are missed (anyone need them?)

About

Google guice repackaged for jakartaee

Resources

License

Stars

Watchers

Forks

Packages

No packages published