Maven - (Remote Repository|Server)

Card Puncher Data Processing

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:

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:

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

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
  • the -U option of Maven - Mvn forces a check for missing releases and updated snapshots on remote repositories

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





Discover More
Card Puncher Data Processing
Maven - (Deploy|Distribution) Phase

This deploy phase copies: a (final) package a web site or the Javadoc documentation to a remote repository for sharing with other developers and projects. In most project builds, the deploy phase...
Card Puncher Data Processing
Maven - Central Repository

The Central repository is the the default repository for Apache Maven but also for other build system such SBT. This is hosted on a nexus repository manager server. ...
Idea Maven Dependency Tree
Maven - Dependency

dependency management in Maven. Dependency are artifact where your software depends on. Dependency are defined in the pom.xml, section dependencies. When you build an application, Maven will search...
Card Puncher Data Processing
Maven - Distribution Management

The distribution Management pom.xml section is responsible to define: the remote repositories how to deploy the project's site and documentation....
Card Puncher Data Processing
Maven - Install (Local Package Installation)

Install is a phase that install the generated artifact in the local repository. deploy Plugin that can be used in this phase. install...
Card Puncher Data Processing
Maven - Repository

in Maven. A repository is a storage of artifacts (jar, war, zip ...) in a file system that is: local: or remote repository (ie via HTTP or SSH) Repository Client translate artifact coordinates...



Share this page:
Follow us:
Task Runner