How to Create a Jandex Index in Quarkus for Classes in a External Module

How to create a Jandex index in Quarkus for classes in a external module

Quarkus automatically indexes the main module but, when you have additional modules containing CDI beans, entities, objects serialized as JSON, you need to explicitly index them.

There are a couple of different (easy to implement) options to do so.

Using the Jandex Maven plugin

Just add the following to the additional module pom.xml:

<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

It's the most beneficial option if your dependency is external to your project and you want to build the index once and for all.

Using the Gradle Jandex plugin

If you are using Gradle, there is a third party plugin allowing to generate a Jandex index: https://github.com/kordamp/jandex-gradle-plugin .

Adding an empty META-INF/beans.xml

If you add an empty META-INF/beans.xml file in the additional module src/main/resources, the classes will also be indexed.

The classes will be indexed by Quarkus itself.

Indexing other dependencies

If you can't modify the dependency (think of a third-party dependency, for instance), you can still index it by adding an entry to your application.properties:

quarkus.index-dependency.<name>.group-id=
quarkus.index-dependency.<name>.artifact-id=
quarkus.index-dependency.<name>.classifier=(this one is optional)

with <name> being a name you choose to identify your dependency.

Quarkus cant find third party clasess for Jandex index even with jandex plugin and an empty META-INF/beans.xml

Creating this response knowing the question was not completely correct.

I understood is not an hibernate-orm error or "like jpa problem". In this case the error always was: "Cant find spring classes":

[ERROR]     - org.springframework.data.domain.Auditable
[ERROR] - org.springframework.data.domain.Persistable

And not "Cant up the hibernate libraries, etc..." So the correct answer to my question is, use the method of this page: How to create a Jandex index in Quarkus for classes in a external module. (like our partner Guillaume says!) but, to put the Spring classes into the index. (Spring are dependency of the Entities dependency of my proj.)

Just configured my application.properties like this:

quarkus.index-dependency.springd.group-id=org.springframework.data
quarkus.index-dependency.springd.artifact-id=spring-data-commons

And the result was:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.878 s
[INFO] Finished at: 2019-08-02T16:02:14-04:00
[INFO] ------------------------------------------------------------------------

Cause I just found this classes in that jar (org.springframework.data) in a mvn repo search, So just work as expected.

Thanks a lot.

How to create a Jandex index for RESTeasy Multipart Provider

Don’t worry, it’s not an issue and you can safely ignore the message.

We have an ignore list in Quarkus and I will add this one to the list as it’s not something that is either serialized or deserialized. The message is specifically for classes that will be used by a JSON/XML... serializer.

It should be fixed in the next release planned for Wednesday. I’ll open a PR tomorrow.

Override beans from an external library (Quarkus)

Well, the priority of the TestAuthController is indeed 3000 and therefore it takes precedence. Injection of CustomOidcAuthController works because there's no other bean that has CustomOidcAuthController in its set of bean types.

In other words, it works as expected (and defined by the spec).



Related Topics



Leave a reply



Submit