smallrye / jandex

Java Annotation Indexer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrating from Jandex maven plugin 1.1.1 to 3.1.3 fails to create intermediate directories when generating an index

rlubke opened this issue · comments

Consider the following jandex plugin configuration:

          <execution>
            <id>make-index-country</id>
            <goals>
              <goal>jandex</goal>
            </goals>
            <!-- phase is 'process-classes by default' -->
            <phase>pre-integration-test</phase>
            <configuration>
              <indexName>country-index/custom.idx</indexName>
              <fileSets>
                <fileSet>
                  <directory>${testClassesDirectory}/data/portabletype</directory>
                  <includes>
                    <include>Country.class</include>
                  </includes>
                </fileSet>
              </fileSets>
            </configuration>
          </execution>

This fails with the following:

Caused by: java.nio.file.NoSuchFileException: /Users/rlubke/files/coh/dev/release/coherence-v14.1.1.2206/prj/test/functional/io/target/classes/META-INF/address-index/custom.idx
    at sun.nio.fs.UnixException.translateToIOException (UnixException.java:92)
    at sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:111)
    at sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:116)
    at sun.nio.fs.UnixFileSystemProvider.newFileChannel (UnixFileSystemProvider.java:182)
    at java.nio.channels.FileChannel.open (FileChannel.java:292)
    at java.nio.channels.FileChannel.open (FileChannel.java:345)
    at org.codehaus.plexus.util.io.CachingOutputStream.<init> (CachingOutputStream.java:57)
    at org.codehaus.plexus.util.io.CachingOutputStream.<init> (CachingOutputStream.java:51)
    at org.codehaus.plexus.util.io.CachingOutputStream.<init> (CachingOutputStream.java:46)
    at org.jboss.jandex.maven.JandexGoal.execute (JandexGoal.java:176)

Workaround: use the antrun plugin to create the target directories prior to generating the indexes.

In previous Jandex Maven plugin versions (before 3.0), each fileset got its own index, whose name (and, coincidentally, also path, though I don't think that was ever intended) was always META-INF/<indexName>.

Since 3.0, all filesets contribute to a single index, whose location is configured using <indexDir> and <indexName> (see https://smallrye.io/jandex/jandex/3.1.3/maven/advanced.html#_index_location_and_version).

If you need to create multiple indices, you need to use multiple executions of the Jandex Maven plugin.

Specifically the example above can be fixed by splitting <indexName>country-index/custom.idx</indexName> into <indexDir>${project.build.outputDirectory}/META-INF/country-index</indexDir> <indexName>custom.idx</indexName>.

On the other hand, maybe we should support <indexName> containing a path, if that worked before (even if perhaps unintentionally). I'll fix that, should be easy.