I am using an external, proprietary jar in my project. When I hard-code the path as follows in my pom.xml, it works fine:
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>bar</artifactId>
<version>5.2</version>
<scope>system</scope>
<type>jar</type>
<systemPath>D:\workspace\myproj\external\companyname\lib\proprietary_api.jar</systemPath>
</dependency>
However, when I try to use the ${basedir} variable, maven can't find the jar:
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>bar</artifactId>
<version>5.2</version>
<scope>system</scope>
<type>jar</type>
<systemPath>${basedir}\external\companyname\lib\proprietary_api.jar</systemPath>
</dependency>
The pom is located in D:\workspace\myproj
This also needs to be cross-platform compatible (dev on Windows, deploy on Linux).
Thanks!
project. basedir : The directory that the current project resides in. This means this points to where your Maven projects resides on your system. It corresponds to the location of the pom. xml file.
A general advantage of using path variables instead of hard-coded paths is that if the source files are moved to a different directory on the development system, you need to change only the value of the path variable. That is, you do not need to update each hard-coded path to all of your source files.
Add a Java Maven Dependency to the Utility Project field (e.g., commons-logging) to search for a dependency. Select the dependency, and click OK. Expand the utility project, right-click the pom. xml file, and select Run As>Maven Install to install the file into the local repository.
It is wrong to use system scope for your proprietary JARs. You should deploy or install it into the local/central repository.
I'm not sure this will help, but try using forward (/
) instead of backward (\
) slashes. Also, try running it with mvn -e
and mvn -X
(the latter will produce a lot of debugging lines) - this might help you pinpoint the problem.
Here's an example:
of using ${basedir}
in the same way you want.
Btw, why don't you mvn install:install-file
the dependency instead of using systemPath
? See:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With