How to create a Jandex index in Quarkus for classes in a external module for Gradle
Asked Answered
L

1

9

Based on the following maven configuration from this SO question, answered for Maven builds, I need an equivalent bit of code for a Gradle setup. Looking around, I can't find a setup that does this for Gradle.

Synopsis of issue from other question: Essentially that classes from external projects aren't indexed so that Quarkus can use them. The solution below rebuilds the index and allows access to the classes.

Code from other question:

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

Also... after more digging, it appears that there might already be a fix in the works here (github merge request. At time of writing, this is merged but doesn't look like it is part of a release. Will follow up if this changes, and if it fixes ths issue.

Update:

With the release of 0.18.0, I am still having issues, but I believe I am closer. I still get the following (very similar) error:

2019-06-27 19:45:52,741 INFO  [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation
2019-06-27 19:45:53,241 WARN  [io.qua.dep.ste.ReflectiveHierarchyStep] (build-8) Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
- com.ebp.reasonadle.shared.pojos.user.User
Consider adding them to the index either by creating a Jandex index for your dependency via the Maven plugin, an empty META-INF/beans.xml or quarkus.index-dependency properties.");.

This is with the empty beans.xml, and at this point I am unsure how to attempt the entries in application.properties.

Entries suggested in other question:

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

I am confused as for what the placeholder <name> is supposed to be. Classname? Gradle project name? Also I assume the empty assignments are intentional?

The structure of my overall gradle project:

| Main
| \ (API folder)
|  | User API (Quarkus Project, pulls in pojos)
| \ (Common resource folder)
|  | Common pojo's (Java library, done with Gradle's plugin)

For the Quarkus devs viewing this, I would argue that this shouldn't be necessary. Sharing pojos between projects is quite common, and what I would call good design. Maybe a quickstart is in order for explaining how to make this work?

Larrup answered 26/6, 2019 at 23:6 Comment(10)
I don't think there's a Gradle plugin for Jandex. The 2 other options from the answer you link should still be possible (adding beans.xml or adding quarkus.index-dependency.* to application.properties). EDIT: it seems I was wrong, there seems to be a Gradle plugin for Jandex here: github.com/galaxx-org/org.galaxx.gradleAptitude
@Aptitude perhaps you should convert your comment into an answer?Rate
@Aptitude Unfortunately, I could not get it to work with the other two fixes (beans.xml or entries in application.properties), hence my continued issues. I have also seen that plugin, but it looks like a dead project, as there haven't been any commits since 2016. Even after trying the galaxx plugin, still hitting the same issue anyways.Larrup
@Snappawapa: Did you ever find a solution to this? I have the same problem and opened an issue for Quarkus here: github.com/quarkusio/quarkus/issues/6635Shrunken
@Shrunken I have not, sadly. Since then I have moved to Jackson based serialization to handle all thatLarrup
@Shrunken I am back into being stuck with this problem.... turns out even with jackson, it still wants the index.... pain in the butt for sure, and no solution yetLarrup
Maybe try to reach out to the devs on their Zulip chat (quarkusio.zulipchat.com). Sometimes they are very responsive.Shrunken
@Larrup did you find a solution meanwhile? I'm facing the same issue with a Gradle multi-module project where the Jandex.idx files inside my shared libraries are not detected.Geter
Still nothing sadly :(Larrup
is this still a problem after github.com/quarkusio/quarkus/issues/6635 got solved? use quarkus 1.3+ to try out.Drusilla
L
0

This was eventually solved by https://github.com/quarkusio/quarkus/issues/6635

There was a relapse in 1.5.0, but it was quickly resolved.

For me, it doesn't seem like I needed anything extra in the META-INF folder or manual/ explicit indexing of other submodules.

Larrup answered 14/7, 2020 at 16:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.