0

I have a local Jar file that I want to add as a dependency for a Maven project that I am working on.

That is easy to do as this answer states.

The problem is that this Jar file requires a foo.classifier file to work properly.

This Jar file is meant to be run by command line (java -jar bar.jar {argument}). The Jar and the classifier files are in the same directory, so everything works just fine.

However, from my project, I want to call the Jar file using its methods and not running a process.

I added the Jar file as a dependency and managed to call the main method that receives the argument, however, it doesn't work properly because of the foo.classifier the file is not set as a dependency for that Jar file to work.

Does anyone know how can I set it as a dependency of that Jar file?

Ashok Kumar N
  • 573
  • 6
  • 23
João Alves
  • 185
  • 1
  • 5
  • 14

3 Answers3

0

Put foo.classifier files in exact folder in .m2\repository folder where your local Jar file that you added as a dependency is present as dependency jar will be referred from local repository

Vikas
  • 6,868
  • 4
  • 27
  • 41
0

You can put your jar to libs directory,and add below code into your pom.xml file:


<dependency> <groupId>htmlunit</groupId> <artifactId>htmlunit</artifactId> <version>2.21-OSGi</version>`` <scope>system</scope> <systemPath>the full path of the jar</systemPath> </dependency>

bp zhang
  • 2,450
  • 1
  • 9
  • 10
0

Add the jar to maven repository with the follows command line, specify a group id, artifact id and a version

mvn install:install-file -Dfile="my-local.jar" -DgroupId="my.groupid" -DartifactId="name" -Dversion="1.0.0" -Dpackaging=jar

and then add as dependency to your pom

<dependency>
    <groupId>my.groupid</groupId>
    <artifactId>name</artifactId>
    <version>1.0.0</version>
</dependency>
imperezivan
  • 761
  • 5
  • 13