Maven - (Remote Repository|Server)

1 - About

Remote repository in maven

A remote repository (or server) can be defined as:

  • a source to resolve dependency (via HTTP)
  • or as a target to deploy the artifact (via SCP)

The definition dependent on lifecycle occurs in the pom.xml. See:

3 - Server

Wagons are the plugins that move the artifact to a remote repository


4 - Configuration

The configuration of a repository are in Settings.xml

4.1 - Get

Repository definition:

    <name>Sonatype repository</name>

4.2 - Upload

When uploading (ie deploying) an artifact, Maven will use SFTP or SCP and need to have their parameters (password, server hostname,..).

This configuration are defined in the servers node of the settings.xml file.

The link between the pom.xml and the settings.xml is done through the id

If the repository is secured, the credentials may be encrypted in the settings.xml file. See Maven - (Password|Credentials).
It's not obligatory to define it, if you give the username in the URL, a password will be asked

          <!-- The id is used as repository Id in the repository definition-->
          <!-- Default is: remote-repository -->
          <!-- (username, password) or (Private Key|PassPhrase) authentication -->
          <!-- (username, password) method takes precedence -->

          <!-- File Permission -->
          <!-- Extra Config: Mostly executable information -->

               <!-- If a SSH client is used to distribute the artifact -->
               <sshArgs>other arguments you may need</sshArgs>


4.3 - Default

The Central Repository is the the default repository for Apache Maven but also for other build system such SBT

5 - Management

5.1 - Add an artifact

Adding an artifact to a remote repository is called deploy in the maven jargon.

You can deploy two type of artifacts:

  • one that you build within your project
  • one that you have

See Maven - (Deploy|Distribution) Phase

5.2 - Verify the availability

The mojo dependency:analyze will verify the availability of dependency

mvn dependency:analyze

5.3 - Force Cache

mvn clean install -U
  • the -U option of Maven - Mvn forces a check for missing releases and updated snapshots on remote repositories

5.4 - List

mvn dependency:list-repositories
[INFO] Repositories Used by this build:
[INFO]       id: central
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => daily]

[INFO]       id: bytle-m2-repo
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => true, update => daily]

[INFO]       id:
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

[INFO]       id: apache.snapshots
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

6 - Public Remote Repository

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap