logo Apache Maven Dependency Plugin

Provides utility goals to work with dependencies like copying, unpacking, analyzing, resolving and many more.

homepage: maven.apache.org/plugins
fresh index:
last release: 7 months ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
dependency:analyze

Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared. This goal is intended to be used standalone, thus it always executes the test-compile phase - use the dependency:analyze-only goal instead when participating in the build lifecycle. By default, maven-dependency-analyzer is used to perform the analysis, with limitations due to the fact that it works at bytecode level, but any analyzer can be plugged in through analyzer parameter.

dependency:analyze-dep-mgt

This mojo looks at the dependencies after final resolution and looks for mismatches in your dependencyManagement section. This mojo is also useful for detecting projects that override the dependencyManagement directly. Set ignoreDirect to false to detect these otherwise normal conditions.

dependency:analyze-duplicate

Analyzes the <dependencies/> and <dependencyManagement/> tags in the pom.xml and determines the duplicate declared dependencies.

dependency:analyze-only (phase: verify)

Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared. This goal is intended to be used in the build lifecycle, thus it assumes that the test-compile phase has been executed - use the dependency:analyze goal instead when running standalone. By default, maven-dependency-analyzer is used to perform the analysis, with limitations due to the fact that it works at bytecode level, but any analyzer can be plugged in through analyzer parameter.

dependency:analyze-report

Analyzes the dependencies of this project and produces a report that summarizes which are: used and declared; used and undeclared; unused and declared.

dependency:build-classpath (phase: generate-sources)

This goal outputs a classpath string of dependencies from the local repository to a file or log.

dependency:collect (phase: generate-sources)

Goal that collects the project dependencies from the repository. This goal requires Maven 3.0 or higher to function because it uses "requiresDependencyCollection". This means that it lists the groupId:artifactId:version information by downloading the pom files without downloading the actual artifacts such as jar files. This is very useful when full dependency resolution might fail due to projects which haven't been built yet. It is identical to {@link ResolveDependenciesMojo} except for using the requiresDependencyCollection annotation attribute instead of requiresDependencyResolution.

dependency:copy (phase: process-sources)

Goal that copies a list of artifacts from the repository to defined locations.

dependency:copy-dependencies (phase: process-sources)

Goal that copies the project dependencies from the repository to a defined location.

dependency:display-ancestors (phase: validate)

Displays all ancestor POMs of the project. This may be useful in a continuous integration system where you want to know all parent poms of the project.

dependency:get

Resolves a single artifact, eventually transitively, from the specified remote repositories. Caveat: will always check the central repository defined in the super pom. You could use a mirror entry in your settings.xml

dependency:go-offline

Goal that resolves all project dependencies, including plugins and reports and their dependencies. Brian Fox

dependency:help

Display help information on maven-dependency-plugin. Call mvn dependency:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

dependency:list

Displays the list of dependencies for this project.

dependency:list-classes

Retrieves and lists all classes contained in the specified artifact from the specified remote repositories.

dependency:list-repositories

Goal that resolves all project dependencies and then lists the repositories used by the build and by the transitive dependencies

dependency:properties (phase: initialize)

Goal that sets a property pointing to the artifact file for each project dependency. For each dependency (direct and transitive) a project property will be set which follows the groupId:artifactId:type:[classifier] form and contains the path to the resolved artifact.

dependency:purge-local-repository

When run on a project, remove the project dependencies from the local repository, and optionally re-resolve them. Outside of a project, remove the manually given dependencies.

dependency:resolve (phase: generate-sources)

Goal that resolves the project dependencies from the repository. When using this goal while running on Java 9 the module names will be visible as well.

dependency:resolve-plugins (phase: generate-sources)

Goal that resolves all project plugins and reports and their dependencies.

dependency:sources (phase: generate-sources)

Goal that resolves the project source dependencies from the repository.

dependency:tree

Displays the dependency tree for this project. Multiple formats are supported: text (by default), but also DOT, GraphML, and TGF.

dependency:unpack (phase: process-sources)

Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location.

dependency:unpack-dependencies (phase: process-sources)

Goal that unpacks the project dependencies from the repository to a defined location.

Often used code snippets:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.6</version>
  <executions>
    <execution>
      <phase>validate</phase>
      <goals>
        <goal>copy</goal>
      </goals>
      <configuration>
        <outputDirectory>${endorsed.dir}</outputDirectory>
        <silent>true</silent>
        <artifactItems>
          <artifactItem>
            <groupId>javax</groupId>
            <artifactId>javaee-endorsed-api</artifactId>
            <version>7.0</version>
            <type>jar</type>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.1</version>
  <executions>
    <execution>
      <phase>validate</phase>
      <goals>
        <goal>copy</goal>
      </goals>
      <configuration>
        <outputDirectory>${endorsed.dir}</outputDirectory>
        <silent>true</silent>
        <artifactItems>
          <artifactItem>
            <groupId>javax</groupId>
            <artifactId>javaee-endorsed-api</artifactId>
            <version>6.0</version>
            <type>jar</type>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.4</version>
  <executions>
    <execution>
      <id>copy-dependencies</id>
      <phase>package</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>install</id>
      <phase>install</phase>
      <goals>
        <goal>sources</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <goals>
        <goal>properties</goal>
      </goals>
    </execution>
  </executions>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.