0

I am trying to retrieve the implementation title and version for a maven jar module. If I use Myclass.class.getPackage().getImplementationVersion() on the built jar, it works, but the same does not work in a debugging environment where the jar is not built, but classes are available.

I am aware of using the Maven JAR plugin to generate the MANIFEST for a maven jar module. So one approach I am considering is to somehow create a copy of the MANIFEST in the generated sources output folder, which I include in my debug classpath. To achieve this:

  1. Is it possible to generate the MANIFEST file in a custom location? If so, what is the plugin and execution configuration necessary?
  2. If not, in which location is the file generated, so I may copy it my custom location using the maven-resources-plugin?
Neel
  • 2,100
  • 5
  • 24
  • 47

1 Answers1

0

The Manifest file is created dynamically when the archive is assembled. There is no default way to do this. The easiest I would come up with is to put a MANIFEST.MF in a resource directory, let Maven filter it and add the directory with a profile. This would mimic the way Maven Archiver creates your MANIFEST.MF. The hard way would be to create a custom plugin around Maven Archiver and pass the very same config as to the JAR plugin and enable it with a profile again.

Michael-O
  • 18,123
  • 6
  • 55
  • 121