0

I want to include one .jar file which has classes of my core automation framework. I created a "lib" folder in my selenium project and then gave its path in the pom.xml dependency. This Jar file of framework is not a runnable jar. I exported the framework project as a jar and want to use its classes in my project.

However, im not able to use any class/method from that jar(framework) in my test scripts. Am i doing something wrong.

enter image description here

enter image description here

2 Answers 2

0

Try changing this line in your pom.xml:

<url>file://${basedir}/lib</url>

to:

<url>${project.basedir}/lib</url>

Do confirm is it works.

7
  • NO, this does not work. I cant use my classes from jar. Not sure what's the issue? :/
    – harry234
    Feb 3, 2023 at 7:34
  • Do i need to use something like Maven assembly plugin or else. I dont want to use classes directly in a package, i want to just use a .jar file.
    – harry234
    Feb 3, 2023 at 7:38
  • You mean for using classes from a Jar file included in the configure build path? Feb 3, 2023 at 7:43
  • Yes. Do i need to add the jar to the build path or only in pom.xml?
    – harry234
    Feb 3, 2023 at 7:46
  • I have added jar in the build path as well. Still project doesnt recognise the classes inside the jar file. Am i doing something wrong here?
    – harry234
    Feb 3, 2023 at 7:58
0

This is a very crucial part of automation, especially for parent-child project structure in POM-based automation. I also faced a similar issue when I worked on a project related to data quality testing. We have created a core framework that contains all the actions, drivers, utilities, etc. The purpose was to use this core framework in the automation of multiple projects. When I tried to use this core framework in the automation of the core project, I used the below steps to resolve that.

Let's consider, your Parent project's POM looks like this:

<groupId>com.abc</groupId>
<artifactId>xyz</artifactId>
<version>0.0.1-SNAPSHOT</version>

Run mvn clean install in the command prompt on the parent project directory. This will create a jar file of your parent project and place it in the .m2 repository of your user's folder in C drive.

Next Step, open the child's project POM file and add the above jar file as a dependency in it as mentioned below:

<dependency>
   <groupId>com.abc</groupId>
   <artifactId>xyz</artifactId>
   <version>0.0.1-SNAPSHOT</version>
</dependency>

Now, you will be able to use all the classes of the parent project in the child project. Hope this information is helpful for you. Thanks!!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.