Search code examples
javamavengradlequerydsl

Service loader not can't find providers when using gradle but works with maven


I have created a repository here https://github.com/bigbang4u2/query-dsl-hibernate-types (This has been copied from here).

Repository created by me here contains both gradle and maven. When using maven all providers are loaded correctly in service loader (see querydsl-ext-apt where providers are present and also listed in META-INF/services). For some reason don't know why maven is able to generate all querydsl QClass with extensions listed in META-INF but when I use gradle all these are ignored and just generate QClasses which are native to querydsl

I need to to work with gradle as that's what I am using in my project

Kindly help


Solution

  • Because Maven throws together things that should not be thrown together which Gradle properly separates. The class using the services you define is run as part of annotation processing. So your services are not needed as implementation dependencies, but as annotationProcessor dependencies.

    Replace

    implementation project(':querydsl-ext-apt')
    

    by

    annotationProcessor project(':querydsl-ext-apt')
    

    and your services are found where necessary.