Dependencies and repositories
How Maven finds the libraries you use, and how to point it at your own repositories.
Dependencies
How-to guides
- Find out where a dependency comes fromSee which of your dependencies brings in a library, which version won and why, and which libraries you use without declaring them.
- Control the version of a transitive dependencyChoose the version of a library that your dependencies bring in, for example to pick up a security fix, and make the build fail when a dependency needs a newer version than it gets.
- Exclude a transitive dependencyKeep a library that one of your dependencies brings in off your classpath, and make sure it does not come back through another path.
- Use a BOM, and publish oneImport a bill of materials to get matching versions of a library family, override one of its versions, and publish a BOM for your own library.
- Make a dependency optionalLet your library use a dependency for one feature without passing it on to every project that uses the library.
Reference
Explanation
- How Maven resolves dependenciesWhy your project gets the libraries and versions it gets: transitive dependencies, which version wins, managed versions, scopes and ranges.
- Common misconceptions about dependency resolutionHow Maven Resolver collects, transforms and resolves the dependency graph, and why the test graph is not a superset of the runtime graph.
Repositories
How-to guides
- Use a repository manager as a mirrorSend every download through your organisation's repository manager instead of Maven Central and the repositories projects declare.
- Use several repositoriesDeclare extra repositories in a POM or in a
settings.xmlprofile, and the order in which Maven asks them. - Install a third-party JAR locallyPut a JAR that is in no public repository into your local repository with
install:install-file. - Deploy a third-party JAR to a remote repositoryDeploy a JAR that is in no public repository to your organisation's repository with
deploy:deploy-file, with a generic POM or your own. - Use an HTTPS repository that asks for a client certificateStore the client certificate and the certificate of the server, and point Maven at both with
javax.net.sslsystem properties. - Run one repository manager for hundreds of projectsRoute the downloads and uploads of hundreds of projects through one repository manager, with
settings.xmlfiles that you manage centrally.
Reference
Explanation
- How Maven uses repositoriesThe local repository and remote repositories, mirrors of Maven Central, building offline, and an internal repository for your organisation.
- Why use a repository managerWhat a repository manager does for an organisation, and the open source and commercial products that serve Maven repositories.
Connecting to repositories
How-to guides
- Choose how Maven connects to repositoriesSwitch between the native transport of Maven Resolver and Wagon with
maven.resolver.transport, set HTTP headers and timeouts, and move from Wagon to the native transport. - Deploy over HTTP, FTP and SSHPoint
distributionManagementat a repository over HTTP, FTP or SSH, give Maven the credentials, and deploy over an unreliable network.