Does adding this repository entry to a pom.xml
make sense?
...
<distributionManagement>
<repository>
<id>dev</id>
<name>Local repository</name>
<url>file://${user.home}/.m2/repository</url>
</repository>
...
I always thought the local repo would be included by default anyways.
I am aware of the fact this won't build on Windows. I found the entry above in a pom.xml
at my company.
In case of the project managed in Maven, package repository in which artifact is stored, should be specified using <distributionManagement> tag of pom. xml. The mvn deploy command uploads the artifact with HTTP PUT for the URL specified using <distributionManagement> tag.
A repository in Maven holds build artifacts and dependencies of varying types. There are exactly two types of repositories: local and remote: the local repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.
Where as the repositories element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project, distributionManagement specifies where (and how) this project will get to a remote repository when it is deployed.
There are several concerns here. No, it does not make sense to do that, but not because it is included by default—it's not—but because it's a very wrong thing to do.
Keep in mind that <distributionManagement>
configures where Maven will deploy and release your artifacts. With this bit of configuration, Maven will release artifacts into your local repository; this is problematic:
In short, this is the difference between your local repository, used when installing and downloading, and a remote repository, used when deploying or releasing. They can be confused because the remote repository can very well be a file-based repository (like the local repository), but their semantics are really different. See also in the Maven docs:
The local repository refers to a copy on your own installation that is a cache of the remote downloads, and also contains the temporary build artifacts that you have not yet released.
Remote repositories refer to any other type of repository, accessed by a variety of protocols such as
file://
andhttp://
. These repositories might be a truly remote repository set up by a third party to provide their artifacts for downloading [...]. Other "remote" repositories may be internal repositories set up on a file or HTTP server within your company, used to share private artifacts between development teams and for releases.
You should remove that configuration entirely, and use mvn clean install
if you really want to put artifacts into the local repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With