Notice that the application developer did not explicitly declare a dependency on these other six libraries! Instead, this dependency was brought in implicitly and automatically. ![]() Here, a single dependency ( guava) included six more. The above is an example of a Maven dependency tree for a project with a single dependency. ![]() \- 2objc:j2objc-annotations:jar:1.3:compile +- :error_prone_annotations:jar:2.7.1:compile +- org.checkerframework:checker-qual:jar:3.12.0:compile +- :listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile org.example:maven_dependecy_desmystified:jar:1.0-SNAPSHOT This command will show all project dependencies in a tree format, revealing what other dependencies have been imported to the project. You can check all imported libraries running the command mvn dependency:tree. This is how dependencies declare their own dependencies, which we call the “transitive dependencies” (as opposed to “direct dependencies”) of your program. Maven dependencies are also Maven projects, so they also have their own “pom.xml” file. The default repository is Maven Central, although Maven can also use other repositories for alternative distributions or private dependencies. In this example, our project is declaring that it needs guava library, version 31.0-jre, from the group .ĭuring the build process, Maven will search for this artifact in its configured repositories, download it to the local machine, and use it to compile the code. This file also includes the project’s dependencies: This file describes a project’s name, version, plugins, build steps, and more. Maven projects are defined in their top-level “pom.xml” file. MORE: Dependency Management in Visual Studio - Nuget and Beyond Declaring Dependencies in Maven
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |