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

Viewed 2135

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?

1 Answers

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.

Related