21
Feb

Configuring external jars via POM.xml in Maven

Configuring external jars via POM.xml in Maven

Maven uses the concept of Repositories to configure dependencies at run time. In case if required dependency is not available in maven repositorie, You can configure your Maven project in following way to resolve external jars dependency.

Step 1. Add lib folder to the src folder.

Step 2. Copy external jar to the lib folder. (eg. sikuli-script.jar, which is dependent jar for sikuli operations)

Now our project structure should look like the following −

Project
|-> src
|->lib
|-> external Jar

Here what we hae done is to specify your own jars, pom.xml needs to be updated as follow:

4.0.0
com.companyname.bank
consumerBanking jar 1.0-SNAPSHOT
consumerBanking
http://maven.apache.org


junit
junit
3.8.1
test


myExternalJar
myExternalJar
system
1.0
${basedir}\src\lib\sikuli-script.jar

This way external jars can be configured via pom.xml.

Best practices to configure external jars to system:
1. Specify groupId same as the name of the library.
2. Specify artifactId same as the name of the library.
3. Specify scope as system.
4. Specify system path relative to the project location.