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:
Is it possible to generate the MANIFEST file in a custom location? If so, what is the plugin and execution configuration necessary?
If not, in which location is the file generated, so I may copy it my custom location using the maven-resources-plugin?
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.
Related
Probably I'm missing something very basic, I have a JAR file (Util) the artefact of my project, which will be used as a util lib in various of my projects. The Util has a list of runtime dependencies. I don't want to create a fat jar to assembly all dependencies there, instead I want to include all Util dependencies in the MANIFEST file in the way the MAVEN will be able to download them automatically if Util will be included in a project, also I don't want to bother a Util consumer be aware of these dependencies.
I want to instruct MAVEN to download Util dependencies automatically. My guess was to leverage somehow Jar manifest Class-Path: attribute to enable this but can't make it working. Tried to google it a lot without success, now I'm not sure if my guess was right. Any ideas how it could be implemented.
how are the pom settings for create a non-executable jar-with-dependencies? (multi-module)
I can‘t find anything working
The Maven shade plugin can help. When configuring the plugin, you can control the contents of the manifest, thus making the jar non-executable. A sample configuration is provided here.
When i export my eclipse rcp product with eclipse, then it creates my plugin as a folder and everthing works fine. but when i build my product with maven, i can't access images and audio files who are saved in the plugin jar file.
Is it's possible to package a eclipse-plugin as a folder?
Specify:
Eclipse-BundleShape: dir
in the MANIFEST.MF file for the plug-in to say you want a directory (folder) rather than a jar.
Note: If you use a Feature based build the unpack option in the feature.xml will override this.
See also the Eclipse help
Eclipse does also provide APIs to allow you to access files in the plug-in jar (mainly FileLocator).
I want to include source files also in Maven - War file . Some plugins in maven will do that but they are including source files in classes folder. But my requirement is that when I import the same war file again into eclipse I should be able to work on that war like any other normal war.
Basically I should be able to work on the same war after importing it to eclipse when I build maven project. (I'm using maven3. )
I remember that's not trivial because the war-plugin doesn't support the handy includes-configuration-element you know from the jar-plugin by default.
Therefore I suggest you to use the maven-assembly-plugin to configure the inclusion of your sourcefiles. You only need to define an assembly descriptor, where you list includes and excludes of your war-package. Maybe you can reuse one of the predefinied assembly descriptors to save some time.
I have a non-trivial maven build which produces a jar fille and I want Itellij Idea to pick up maven's output and then launch the jar but IDE doesn't allow me to specify a jar to use in 'Application' launch configuration. Please suggest a way to configure project this way.
Thanks in advance
You can create a new dummy module with this jar added to its Dependencies and attach sources to the library, then you can debug it by specifying the main class in the Run configuration. The module itself may not contain sources or other content roots.