Get only the Jar from maven repository through build.gradle file

56 views Asked by At

I need to use a Jar from a remote repository. I am providing the dependency details in the dependencies section in build.gradle like this -

compile("com.rhuldip.artifactId:com.rhuldip.projectId:1-SNAPSHOT")

But in my remote repository there are 3 files maven-metadata.xml,com.rhuldip.projectId-1-SNAPSHOT.jar and com.rhuldip.projectId-1-SNAPSHOT.pom. com.rhuldip.projectId-1-SNAPSHOT.pom contains multiple dependencies which i dont need in my project.

I just need com.rhuldip.projectId-1-SNAPSHOT.jar in my project. Is there any way i can get only the specified jar and not the pom dependencies?

1

There are 1 answers

2
SiKing On

Your jar, and your project, will not work without the other dependencies.

You need to read the documentation on transitive dependencies.

Updates:

Maven assumes that all jars are thin-jars, and therefore it always reads the accompanying pom to determine what other dependencies it needs to download.

For your case, if you are using a fat-jar, you have two options:

  1. If you control building of the fat-jar, it should be named differently: something like projectId-jar-with-dependencies-1-SNAPSHOT, with appropriately named pom. Have a look at Building a fat jar using maven.
  2. If you do not control building of the fat jar, you could download it manually into your project, and then install it from Maven. Have a look at How to add local jar files to a Maven project?