Reputation: 402
I have dependencies in my pom.xml like this:
<dependency>3.jar</dependency>
<dependency>1.jar</dependency>
<dependency>4.jar</dependency>
<dependency>2.jar</dependency>
I have a maven project that when deployed, will have a directory structure like this:
myproj/
|_lib/
|_1.jar
|_2.jar
|_3.jar
|_4.jar
|_start.sh
The start.sh loads all the jars in the lib folder like this:
CLASSPATH=./lib/*
Problem is, when I echo the CLASSPATH, it loads the jars alphabetically:
CLASSPATH=/lib/1.jar;/lib/2.jar;/lib/3.jar;/lib/4.jar;
I want it to be what maven uses:
CLASSPATH=/lib/3.jar;/lib/1.jar;/lib/4.jar;/lib/2.jar;
I can do
mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
but it prints out the jars in my local repository:
CLASSPATH=C:\.m2\repository\com\project\3.jar;\.m2\repository\com\project\1.jar;...
I think I can modify the generated output but I am looking for a better solution.
Any ideas?
Thanks!
Upvotes: 1
Views: 1572
Reputation: 47905
You can use the prefix
parameter to dependency:build
. From the docs:
prefix
The prefix to prepend on each dependent artifact. If undefined, the paths refer to the actual files store in the local repository (the stripVersion parameter does nothing then).
User property is: mdep.prefix.
For example:
mvn dependency:build-classpath -Dmdep.outputFile=cp.txt -Dmdep.prefix=/lib
Upvotes: 1