inquizitive
inquizitive

Reputation: 632

How to specify dependency in a JAR library

I am creating a JAR library and publishing it to nexus using Gradle for other projects to use. How can I specify that my JAR has a dependency on another library (Commons Lang 3)?

Upvotes: 0

Views: 54

Answers (1)

Louis Jacomet
Louis Jacomet

Reputation: 14500

I strongly recommend you follow the guide on building a Java library with Gradle. It contains the information you are looking for.

In short, your build file needs something like:

repositories {
  mavenCentral()
}

dependencies {
  implementation 'org.apache.commons:commons-lang3:3.7'
}

And the publication to a maven repository will take care of adding that information to the Maven pom file that will be used by consumers of your library.

Upvotes: 1

Related Questions