Table of Contents

Managing dependencies in Maven projects


Prerequisites

Maven project is opened in Visual Studio. You can find instructions how to create a Maven project in this section. You can also find an overview of Maven projects in this section.

Actions

Dependencies are other projects required to build your project. Usually they contain Java libraries in JAR format. This is analogous to references in C# projects or dependencies among Visual Studio projects. The difference is that Maven has more advanced management system for dependencies and can actually download them from the network.

Dependent projects are stored in a centralized location on your system, called the local repository. On the network, they are stored in remote repositories from which Maven downloads them to the local repository. You can browse remote repositories and select projects to be downloaded and added to your project.

You can find more info on repositories in this section of Maven docs.

Detailed info about Maven dependency engine is located in this section of Maven docs. Note that the Maven documentation describes a direct way of configuration (by writing XML), but all of these concepts and options are valid also when working with IntegraStudio. You will create new nodes in Solution Explorer and edit their properties, instead of writing XML code. IntegraStudio generates and maintains the POM XML file for you.

Naming dependencies in Maven

There is a standard naming system for Maven projects. A name constists of several components:

When you add a dependency, you need to specify the group, artifact and version (and optionally a classifier). As a result, Maven knows exactly which project archive has to be downloaded and linked.

You can read more on naming conventions in this section of Maven docs.

Adding dependencies to a project

Right-click on the Dependencies node (under the Configuration node) and choose Add / New item. A window will appear, allowing you to configure added dependency:

The most important properties are Group id, Artifact id and Version. You can find more information on remaining properties in this section of Maven docs.

You can also click the Browse repositories button to open the Repository Browser window, which allows you to pick a dependent project from Maven repository:

When you select a project (group, artifact and version) to be added as a dependency, click OK.

Removing dependencies

Removing dependencies is done in a standard way, by right-clicking on a dependency node and choosing Remove.

Editing dependencies

Editing parameters of dependencies is done by right-clicking on a dependency node and choosing Properties.

Excluding transitive dependencies

Dependencies in Maven are transitive. That means if your dependency specifies a dependency itself, both will be added to your project. This can lead to somewhat unpredictable recursive dependency inclusion, which may be undesirable in some cases. Dependency exclusion is a feature meant to solve this problem. You can specify an artifact and group id, which will be filtered out when including dependencies recursively. That is, if a dependency matches the specification, it will be ignored.

You can add exclusions to the Exclusions node under the dependency node. Just right-click on the node and choose Add / New item. You can enter the group and artifact id now (or change them later, using Properties). You can also Remove an exclusion.

More info on exclusions is located in this section of Maven docs.

Table of Contents


Copyright (C) 2014-2016 SOFT-ERG. All rights reserved.