MAVEN installation and global profile configuration

Source: Internet
Author: User

MAVEN 3.2 requires JDK 1.6, Maven 3.0/3.1 requires JDK 1.5

· Extract.

· environment variable m2_home

· M2 =%m2_home%\bin also added to path

· Optional : maven_opts =-xms256m-xmx512m-dmaven.artifact.threads=3 (multi-threaded download, default 5)

· Of course, there must be java_home.

Run the Mvn–version test

There are two settings.xml, unrelated to specific projects or users

    • Official Global settings: $M 2_home/conf/settings.xml
    • User settings: ${user.home}/.m2/settings.xml

A copy of the user settings can be copied directly

<Settingsxmlns= "http://maven.apache.org/SETTINGS/1.0.0"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">      <localrepository/>      <Interactivemode/>      <Usepluginregistry/> Useless       <Offline/>      <plugingroups/>       <Servers/> Slightly       <Mirrors/> Slightly      <proxies/> Slightly       <Profiles/>      <Activeprofiles/>    </Settings>

The settings inside can be expressed in the following expressions:

    1. ${user.home} system variable, which can be used in Java System.getproperty
    2. ${env. HOME} environment variable, that is System.getproperty ("Java.library.path")

However, properties defined in profiles cannot be referenced in this way

<localrepository>${user.home}/.m2/repository</localrepository> Local code base location, must be an absolute path  <Interactivemode>True</Interactivemode> If prompted, select 123  <Usepluginregistry>False</Usepluginregistry>  <Offline>False</Offline> Always online by default

< plugingroups >    < Plugingroup >org.mortbay.jetty</plugingroup> Default org.apache.maven.plugins Org.codehaus.mojo   </ plugingroups >

If you set it up like above, run Org.mortbay.jetty:jetty-maven-plugin:run

You can directly mvn Jetty:run.

Setting.xml's profile is a compressed version of profile pom.xml . Includes a

activation (activation condition), repositories, pluginrepositories , Properties (specific attributes can be defined)

Because he only cares about global settings, not specific to the project.

If effective, the specific pom or profiles.xml settings will be overwritten

1.

<Profiles>    < Profile>      <ID>Test</ID>      <activation> Activation conditions, to match all        <Activebydefault>False</Activebydefault> Default activation        <JDK>1.5</JDK>        <OS>          <name>Windows XP</name>          <Family>Windows</Family>          <Arch>x86</Arch>          <version>5.1.2600</version>        </OS>        < Property> If an attribute is met (Maven3 also search for settings.xml)          <name>Mavenversion</name>          <value>2.0.3</value> does not have value, which means that as long as it has been defined        </ Property>        <file>          <exists>${basedir}/file2.properties</exists>          <missing>Target/generated-sources/axistools/wsdl2java/org/apache/maven</missing> If a file does not exist        </file>      </activation>      ...    </ Profile>  </Profiles>

2.

<Profiles>    < Profile>      ...      <Properties> Specific properties at the time of entry into force        <User.install>${user.home}/our-project</User.install>      </Properties>      ...    </ Profile>  </Profiles>

The properties in profile can be arbitrarily referenced in pom.xml with an expression ${xx}, in the following ways:

    1. Env. X: Environment variables, such as ${env. PATH}
    2. Project.x or pom.x: an element corresponding to Pom.xml, such as ${project.version}
    3. Settings.x: Corresponds to settings.xml an element, such as ${settings.offline}
    4. All that can be accessed with java.lang.System.getProperties (), such as ${java.home}
    5. x: is defined by <properties/>, such as ${User.install}. Of course, this profile has to be activated first.

3.

<Profiles>    < Profile>      ...      <repositories> Specific code base        <Repository>          <ID>Codehaussnapshots</ID>          <name>Codehaus Snapshots</name>          <releases> Official version Settings            <enabled>False</enabled>            <Updatepolicy>Always</Updatepolicy> Update Policy            <Checksumpolicy>Warn</Checksumpolicy> Validation Policies          </releases>          <Snapshots> Preview Settings            <enabled>True</enabled>            <Updatepolicy>Never</Updatepolicy>            <Checksumpolicy>Fail</Checksumpolicy>          </Snapshots>          <URL>Http://snapshots.maven.codehaus.org/maven2</URL> Specific code base location          <Layout>Default</Layout> slightly        </Repository>      </repositories>      <pluginrepositories>        ...      </pluginrepositories>      ...    </ Profile>  </Profiles>

<updatePolicy> can be the following values: Always, daily (default), interval:x (minutes),never.

<checksumPolicy> can be the following values:ignore, fail, warn

4.pluginRepositories Plugin code base, structure ibid.

activation is not the only way to get the profile into effect. Activeprofile can do that.

< Activeprofiles >    < Activeprofile >env-test</activeprofile> Profile ID  </ Activeprofiles >

The profile will be found in Pom.xml and Profile.xml (Maven3 no longer uses profile.xml)

You can also explicitly enable –P on the command line

MVN groupid:artifactid:goal-p profile-1,profile-2

or display disabled

MVN groupid:artifactid:goal-p!profile-1,!profile-2

MVN help:active-profiles to view the currently enabled profile

MAVEN installation and global profile configuration

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.