Working with repositories

To browse through the repository, navigate to Window | Show View and click on Other... as follows:

Working with repositories

Next, the Show View window appears. Search for maven repository, as shown in the following screenshot, and click on Maven Repositories:

Working with repositories

The Maven Repositories view constitutes of the following types:

  • Local Repositories
  • Global Repositories
  • Project Repositories
  • Custom Repositories

The repositories that are of interest are local, global, and project repositories.

Local Repositories

It shows the artifacts of the local repository, and we can drill down to see its POM contents. It also consists of Eclipse workspace projects. The following is the screenshot of the local repository:

Local Repositories

Global Repositories

It references the artifacts of the central repository. We can browse through the artifacts of the central repository and view its POM. Right-click on Global repositories, which provides the ability to re-index, build full index, minimum index, and update index from the central repository. The following screenshot illustrates the global repository:

Global Repositories

Project Repositories

This repository shows the project-based repositories. Maven discourages the inclusion of repositories mentioned in the project POM file; however, we tend to disobey it when we have to reference local custom artifacts not available in the central repository, or where we may have to package repositories along with distribution. For example, let's take a scenario where we have to reference the artifacts from a libs folder in the Eclipse workspace. To achieve this, add the following snippet in the pom.xml file:

<repositories>
    <repository>
      <id>project-based-repository</id>
      <name>Project-specific jars</name>
      <url>file:///${basedir}/libs</url>
    </repository>
<repositories>

Refresh the Maven Repositories window by clicking on the two cyclic arrows on the top-right side of the window. We can see the corresponding reference in Project Repositories as follows:

Project Repositories
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.85.135