Java – how do I use the onejar Maven plug-in to set additional class path entries in the manifest?
Is there any way to use the onejar Maven plugin to add arbitrary classpath entries to the jar file manifest?
I found the way to configure Maven jar plugin to do this, but there seems to be no such choice for onejar Maven plugin
No additional classes can be found (otherwise why use the onejar plug-in, right?), Instead, find a configuration file that must be external to the jar
Is there a direct solution or solution?
Solution
Is it really necessary to use a jar package?
>Configure the class path entry in the application jar using Maven jar plugin and the approach mentioned in the question > package a single jar using Maven assembly plugin, including dependencies, as described here in another stackoverflow question / answer
An example of the one jar executable file (without using the one jar plug-in) can be as follows:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <!-- your further configuration here --> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.sample.MainApp</mainClass> <!-- your further configuration here --> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
If you need to play classpath and Maven further, I suggest checking this problem here in stack overflow