Dependency Management

Skip to end of metadata
Go to start of metadata

Maven dependency management is integrated with Eclipse JDT using "Maven Dependencies" classpath container. Here are a few things to note:

  • The classpath container contains a dependency list computed by Maven based on the project's pom.xml
  • By default, dependencies are resolved from the Eclipse Workspace if the corresponding projects have Maven management enabled and the groupId, artifactId, and version for that project completely match with the required dependency
  • Dependencies for attached tests with the "tests" classifier are also resolved from the Eclipse Workspace. You don't need to run jar:test-jar goal to make it work, unless you have Workspace dependency resolution disabled for the project
  • Because Eclipse limits you to only a single compile-time classpath for the entire project, the "Maven Dependencies" classpath container represents Maven's "test" scope, which is required to compile tests.
  • Excludes listed on dependency that is resolved from the Eclipse workspace project are not respected, because of the direct project link, so JDT directly exposes all dependencies from that project
  • The "Maven Dependencies" container is not used to construct the "runtime" and "test" classpaths for "Java Application" and "JUnit" launch configurations in Eclipse. A special classpath provider is contributed to those launch configurations and it uses the appropriate Maven classpath scope.

You can force a refresh of the Maven Dependencies container and force downloading of artifact snapshots (regardless of the Maven repository refresh policy) by using the "Update Depdencies" and "Update Snapshots" actions from the Maven popup menu on the selected project or pom.xml.

The "Update Project Configuration" action can be used to refresh or recreate the Eclipse project configuration based on the content of the Maven pom.xml, for example, when changes in pom.xml affect the project structure (folders settings, plugins that dynamically add folders or have other configuration).

Dependencies are resolved from the Eclipse Workspace or from the local Maven repository:

  • If a referenced dependency is not available from the local repository it is automatically downloaded from the remote repositories specified in the pom.xml and Maven's settings.xml that can be specified in Maven Settings.
  • If the Eclipse Workspace has Maven projects with exact matching for the required dependencies (including groupId, artifactId, and version), these projects will be used instead of the jars from the Maven repository. If an exact match is not found, the Maven repositories will be used for the dependency.

Dependency resolution and other Maven settings can be configured from the Maven page in the project properties dialog:

  • Active Maven Profiles
    If specified, dependencies from these profiles will be picked up
  • Goals to invoke after project clean
    Default - process-test-resources
  • Goals to invoke on resource changes
    Default - process-resources resources:testResources
  • Resolve dependencies from Workspace projects
    When unchecked, disables resolving dependencies from the Eclipse workspace
  • Include modules
    When enabled, dependencies from all nested modules are added to the "Maven Dependencies" container and source folders from nested modules are added to the current project build path when running "Update Sources" action
    This option is enabled when you import multiple Maven projects as single Eclipse project, e.g. when "Separate projects for modules" option is turned off in the project import wizards


jdt jdt Delete
m2eclipse m2eclipse Delete
maven maven Delete
eclipse eclipse Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.