Application of Maven2-snapshot Snapshot library and release release Library

Source: Internet
Author: User

To apply the snapshot and release libraries in the project, apply the snapshot and release libraries to achieve different releases in different environments, first look at the definition of a pom file:

<Project>    <modelversion>4.0.0</modelversion>    <groupId>Cc.mzone</groupId>    <Artifactid>Myjar</Artifactid>    <version>${project.release.version}</version>    <Packaging>Jar</Packaging>     <distributionmanagement>        <Repository>        <ID>Mzone-release</ID>        <URL>Http://192.168.1.88/nexus/content/repositories/mzone-release</URL>        </Repository>        <snapshotrepository>        <ID>Mzone-snapshot</ID>        <URL>Http://192.168.1.88/nexus/content/repositories/mzone-snapshot</URL>        </snapshotrepository>    </distributionmanagement>     <Properties>        <project.release.version>0.1-snapshot</project.release.version>    </Properties>     <Profiles>        < Profile>            <ID>Product</ID>        <Properties>             <project.release.version>0.1</project.release.version>        </Properties>        </ Profile>    </Profiles></Project>

First we see that the definition of version in the Pom file is in the form of a placeholder, so the benefit is that the version information can be replaced by different profiles, such as Maven using 0.1-snapshot as the default version of the module.

1. If you use the MVN deploy-p product command at the time of publishing, Then will automatically use 0.1 as the release version, then according to MAVEN processing snapshot and release rules, because the version number is not with-snapshot as a formal release version, will be published to the release warehouse;

2. If you use the MVN Deploy command when publishing, the default version number 0.1-snapshot will be used, and Maven will assume that it is a snapshot version and will be automatically published to the snapshot repository.

The address of the snapshot snapshot library and release publishing library is configured in the Distributionmanagement segment, and I use the Nexus as the mirror server. For the repository is primarily the configuration of the ID and URL, after the configuration is completed can be released through MVN deploy, of course, if your mirror server requires a user name and password, then you need to do the following configuration in Maven's Settings.xml file:

<Servers>    <Server>        <ID>Mzone-release</ID>        <username>Deployment</username>        <Password>Deployment</Password>    </Server>    <Server>        <ID>Mzone-snapshot</ID>        <username>Deployment</username>        <Password>Deployment</Password>    </Server></Servers>

Note that the ID of the server configured here must be consistent with the ID of the Distributionmanagement repository in the Pom file, and Maven will look up the user name and password for login and file upload publication based on ID when processing the publication.

We can use the profile definition here to flexibly switch the snapshot snapshot version and release the official version of the release, in the dependent components can also be used to define the use of the snapshot library during the development phase, the use of the formal library in the release phase of the function, You only need to override the default properties property values in different profiles.

Application of Maven2-snapshot Snapshot library and release release Library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.