Table of Contents

Maven - (Remote Repository|Server)

About

Remote repository in maven

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

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

Server

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

Possibility:

Configuration

The configuration of a repository are in Settings.xml

Get

Repository definition:

<repositories>
  ...
  <repository>
    <id>Sonatype-public</id>
    <name>Sonatype repository</name>
    <url>http://oss.sonatype.org/content/groups/public/</url>
  </repository>
  ...
</repositories>

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

<servers>
	<server>

          <!-- The id is used as repository Id in the repository definition-->
          <!-- Default is: remote-repository -->
	  <id>myRepositoryId</id>
          
          <!-- (username, password) or (Private Key|PassPhrase) authentication -->
          <!-- (username, password) method takes precedence -->
          <username>my_login</username>
          <password>my_password</password>
          <privateKey>${user.home}/.ssh/id_dsa</privateKey>
          <passphrase>some_passphrase</passphrase>

          <!-- File Permission -->
	  <filePermissions>664</filePermissions>
	  <directoryPermissions>775</directoryPermissions>
          
          <!-- Extra Config: Mostly executable information -->
	  <configuration>

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

	</server>
</servers>

Default

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

Management

Add an artifact

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

You can deploy two type of artifacts:

See Maven - (Deploy|Distribution) Phase

Verify the availability

The mojo dependency:analyze will verify the availability of dependency

mvn dependency:analyze

Force Cache

mvn clean install -U

List

mvn dependency:list-repositories
[INFO] Repositories Used by this build:
[INFO]       id: central
      url: https://repo.maven.apache.org/maven2
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => daily]

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

[INFO]       id: codehaus.org
      url: http://snapshots.repository.codehaus.org
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

[INFO]       id: apache.snapshots
      url: https://repository.apache.org/content/repositories/snapshots/
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

Public Remote Repository