From the course: Gradle for Java-Based Applications and Libraries
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Declaring a dependency on an external library
From the course: Gradle for Java-Based Applications and Libraries
Declaring a dependency on an external library
- [Instructor] To declare a dependency for a Java-based project, you will need to understand three aspects. First of all, we need to know the coordinates of the dependency you want to consume. Maven calls this the group, artifact, and version of the dependency, in short GAV. Let's hop over to Maven Central and search for the dependency commons-cli. We'll use the dependency to write more sophisticated code for defining and parsing command line options for the program. To consume the dependency, we will first have to declare the repository using the repositories method. Assign the shortcut method, mavenCentral, so that Gradle knows where to resolve the dependency from. Next up, define the list of dependencies with the dependencies method call. Within the dependencies block, we will define the GAV of the commons-cli dependency with version 1.4. You can grab the notation from the Maven Central search result. The scope…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Mechanics of dependency management1m 59s
-
(Locked)
Declaring a dependency on an external library2m 38s
-
(Locked)
Rendering the dependency tree2m 36s
-
(Locked)
Declaring a project dependency3m 5s
-
(Locked)
Using the Maven Publish plugin to publish a library3m 7s
-
(Locked)
Challenge: Consuming an external dependency1m 44s
-
(Locked)
Solution: Consuming an external dependency3m 29s
-
(Locked)
-
-