You often need to generate .bat and .sh files for your java project.
Using Maven, this can be a tricky task because, basically, you don’t know at all times what libraries and what versions are included.
As Maven « controls » the library dependencies for you, it’s impossible to add manually the classpath into the script files.
Here is a solution, where maven automatically generates the classpath for you. The solution comes (as often with Maven) from a plugin, the dependency plugin.
Basically, we will do the following:
– Generate the classpath for windows and unix in a file using the dependency plugin.
– Dynamically insert the classpath into batch files
– Assemble all the libraries in a single subdirectory referenced by the classpath.