简体   繁体   中英

What is a maven settings.xml file and how it is different from pom.xml

I am working on build a Android Maven project, and learning how to set up and take advantages of maven in android application development.

While I am reading some documentation ( http://books.sonatype.com/mvnref-book/reference/android-dev-sect-config.html ) it mentioned we could config maven plug-in in either settings.xml file, or put configuration into the pom.xml file.

I am a little confused about the usage of the two files. Do I need to have settings.xml in the maven project. How Settings.xml different from pom.xml ?

Thank you, Allan

settings.xml is your user preferences. It lives in your main Maven directory (usually $HOME/.m2 ) and holds your own settings, like listings for non-public repositories, usernames, and other personalized configuration.

pom.xml is the control file for each Maven project or module. It tells Maven which dependencies the project needs, what processing to apply to build it, and how to package it when it's ready. The POM is part of the project itself, and so information that's necessary to build the project (such as listing which plug-ins to use when building) should go there.

I can imagine that the text is a bit confusing.

settings.xml contains system and/or user configuration, while the pom.xml contains project information. All build configuration ends up in the pom.xml . However, you cannot predict the andriod emulator avd, that depends on the system you are running this project on. So this is a property you can't set in the pom.xml . For these kind of things you can use the settings.xml .

An example would look like this:

<settings>
  <profiles>
    <profile>
      <id>android</id>
      <properties>
        <android.emulator.avd>21</android.emulator.avd>
      <properties>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>android</activeProfile>
  </activeProfiles>
</settings> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM