Maven Best Practices - distributionManagement

Distributing artifacts to a remote repository
mvn install will install the artifacts generated by the project to the local Maven repository, and mvn deploy is used to distribute the artifacts generated by the project to the remote Maven repository. The artifacts of the local Maven repository can only be used by the current user. After distribution to the remote Maven repository, all users who can access the repository can use your artifacts.
We need to configure the distributionManagement of the POM to specify the location of the Maven distribution artifacts, as follows:

<settings>    
  ...    
  <servers>    
    <server>    
      <id>nexus-releases</id>    
      <username>admin</username>    
      <password>admin123</password>    
    </server>    
    <server>    
      <id>nexus-snapshots</id>    
      <username>admin</username>    
      <password>admin123</password>    
    </server>      
  </servers>    
  ...    
</settings>


It should be noted that the value of id under the server element in settings.xml must be exactly the same as the value of id under repository or snapshotRepository in POM. Put the authentication information under settings instead of POM, because POM is often visible to others, and settings.xml is local.

Summary
This article introduced the Maven repository, what is it? What do local warehouses, remote warehouses, and central warehouses refer to? And introduced how to configure project-level warehouse in POM, configure user-level warehouse in settings, and mirror. This article also describes how to install artifacts into a local repository and how to distribute artifacts to repositories.


Reprinted in: http://tianya23.blog.51cto.com/1081650/292205/


Basic configuration packaging and multi-module aggregation structure of Maven's pom.xml file structure
1. packaging

packaging gives the packaging type of the project, that is, as a project The release form and its possible types. In Maven 3, the available packaging types are as follows:

jar (default type), war, ejb, ear, rar, par, pom, maven-plugin, 2.multi-modules

Maven 3 supports multi-modules for Maven projects (multi-modules). modules) structure. Such a Maven project is also called an aggregate project, and usually consists of a parent module and several submodules.

Among them, the parent module must be packaged with the pom type, and all submodules must be given as <modules> . An example of the POM for the parent module is as follows:
...  
<packaging>pom</packaging>  
  
<modules>  
  <module>my-frontend-project</module>  
  <module>my-service-project</module>  
  <module>my-backend-project</module>  
</modules>  
...  

Each of these modules is another Maven project
http://blog.csdn.net/taiyangdao/article/details/52357132

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327017731&siteId=291194637