Is it possible to create an executable jar with maven where it is possible to replace a particular library with a newer version of the library without creating a new executable jar?
Yes, you should define a provided
dependency such as:
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
<version>[1.0,)</version>
<type>bar</type>
<scope>provided</scope>
</dependency>
And make sure the dependency is available on your application classpath when running. For example using java command to run an executable jar:
java -jar MyExecutableJar.jar -cp /path/to/my/library.jar
You can then build your executable jar and run it. Not there are several shortcoming using this method:
[1.0,)
to tell Maven I needed version 1.x or greater, you can adapt for your context.That being said, I don't know why you want to make a JAR with such conditions, but chances are you'll be better of rebuilding your JAR each time you need a newer version rather than keeping it, or change your dependency and project architecture. Doing this is against best practices and Maven design.
If you provide a little more context I'll try and explain more.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments