What is a maven settings.xml file and how it is different from pom.xml
Solution 1
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.
Solution 2
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>
Allan Jiang
Updated on June 04, 2022Comments
-
Allan Jiang almost 2 years
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 thepom.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 frompom.xml
?Thank you, Allan