Bundling external dependency jars in serviceloader jar with TestNG Listeners

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bundling external dependency jars in serviceloader jar with TestNG Listeners

Arun Kumaresan
Hi,

I have a question related to bundling external jars dependencies along with my serviceloader jar.

My current folder structure is 

META-INF/service/org.testng.ITestNGListener
com/mycompany/MyListener.class (that implements ISuiteListener)

But MyListener.class has reference/dependency on rest-assured for running some REST queries.

How do I bundle up these external jars (like rest-assured) along with my serviceloader jar (containing my customer listeners) so I dont have to bother about finding all the other dependencies and include them in my classpath. In a regular project those are taken care my pom/maven.

Any help on this is highly appreciated.

Regards,
Arun Kumaresan.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Bundling external dependency jars in serviceloader jar with TestNG Listeners

⇜Krishnan Mahadevan⇝

Based upon your build tool (Maven/Gradle/Ant) you would have to do this accordingly.

Basically you go about building an uber jar (jar of jars) 

 

If you were using Maven as your build tool, you can make use of either the assembly plugin or the shade plugin to do this.

Here’s a tutorial that shows how to use the maven shade plugin to build an uber jar : http://www.avajava.com/tutorials/lessons/how-do-i-build-a-jar-file-that-contains-its-dependencies.html

 

If you are using Gradle as your build tool, you can refer here : https://www.mkyong.com/gradle/gradle-create-a-jar-file-with-dependencies/

 

If you are not going to be deploying your jar anywhere (like how they do it for a web app or a restful service) then you don’t need an uber jar.

 

You basically have to just publish your artifact (as a gradle artifact or as a maven artifact) and after that Maven/Gradle should take care. Am guessing you are perhaps not using any build tool. If that’s the case, now is the time to switch to using one.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Arun Kumaresan <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, October 10, 2017 at 8:36 AM
To: testng-users <[hidden email]>
Subject: [testng-users] Bundling external dependency jars in serviceloader jar with TestNG Listeners

 

Hi,

 

I have a question related to bundling external jars dependencies along with my serviceloader jar.

 

My current folder structure is 

 

META-INF/service/org.testng.ITestNGListener

com/mycompany/MyListener.class (that implements ISuiteListener)

 

But MyListener.class has reference/dependency on rest-assured for running some REST queries.

 

How do I bundle up these external jars (like rest-assured) along with my serviceloader jar (containing my customer listeners) so I dont have to bother about finding all the other dependencies and include them in my classpath. In a regular project those are taken care my pom/maven.

 

Any help on this is highly appreciated.

 

Regards,

Arun Kumaresan.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.