0

I want to read the current artifact version of my maven-project inside my of a RESTful service. My code is written in JAX-RS (Quarkus).

I am using a the following pom.xml snippet:

      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${quarkus.version}</version>
        <configuration>
          <archive>                   
            <manifest>
            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

I read the version with the following java snippet:

      String vendor = getClass().getPackage().getImplementationVendor();

It seems to me that the quarkus-maven-plugin is ignoring that line since maven-jar-plugin is working perfectly fine (I used this in a different project):

      <addDefaultImplementationEntries>true</addDefaultImplementationEntries>

I do not have a really profound knowledge of maven and quarkus yet.

Am I making a mistake setting up the quarkus-maven-plugin? Is there a workaround which does not include reading directly from the pom.xml?

Thank you for helping me.

EDIT: I will mark this thread as "answered" as soon as the following issue is resolved (opend by @Guillaume Smet): https://github.com/quarkusio/quarkus/issues/5023

EDIT: Issue is resolved as of today. https://github.com/quarkusio/quarkus/issues/5100

Yanick Senn
  • 81
  • 2
  • 9

1 Answers1

1

Adding addDefaultImplementationEntries won't help, we build the jar ourselves and we don't push any of this information to it.

I created https://github.com/quarkusio/quarkus/issues/5023 for this.

For the time being, you can either push the information to the manifest yourselves (we enhance it if you have an existing one) or inject the values we derive from the POM files in your REST resources with:

@ConfigProperty(name = "quarkus.application.name")
String name;

@ConfigProperty(name = "quarkus.application.version")
String version;
Guillaume Smet
  • 9,921
  • 22
  • 29
  • Thank you for answering and opening that issue, for now I will add the information myself (your first mentioned workaround). – Yanick Senn Oct 30 '19 at 15:28
  • The annotation loopup for version is not working. See also: https://stackoverflow.com/questions/58306053/how-can-i-get-the-version-of-the-application-defined-by-tag-version-im-pom-in?r=SearchResults – Serkan Dec 17 '19 at 16:40