Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Must you create the .m2/repository folder manually

Tags:

Will the .m2 folder be created automatically by Maven, or do you need to create it manually?

What does the .m2/repository, contain and from where does it come?

like image 943
ram Avatar asked Jan 04 '13 22:01

ram


People also ask

Do we need to create .m2 folder?

Note that you don't actually need the . m2 location unless you want to create a distinct user settings file, which is optional (see the Settings reference for more details).

How is .m2 folder created in maven?

The Local Repository Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.

Why do we need .m2 folder?

m2 folder is the default folder used by maven to store its: settings. xml file which specifies properties, like the central repository to download your dependencies, the location of the so-called localRepository. by default, the localRepository in which maven stores all the dependencies your project might need to run.


2 Answers

First, it will be created by Maven when you execute a build, such as:

mvn clean install 

Note, you could find this out just be executing mvn your self ;)

Second, the contents of .m2 are:

A settings.xml file that contains global settings for all maven executions.

A folder called repository that holds all of the local copies of various maven artifacts, either caches of artifacts pulled down from remote repositories, such as Maven Central, or artifacts built by your local maven builds. The artifacts are organized in there in folder structures that mirror the groupId's of the artifacts.

like image 151
chad Avatar answered Sep 29 '22 07:09

chad


It will be created automatically. The repository folder (also called local repository) will download its content from repositories specified in your user's settings.xml, the global settings.xml and possibly in your poms.

Most artifacts will be downloaded from repo1.maven.org.

like image 36
asgoth Avatar answered Sep 29 '22 06:09

asgoth