Maven Repository Types

Explore artifact storage using repositories: local, central, and internal corporate. Learn how they streamline software development and simplify dependency management.

For storing artifacts such as jar/war files, pom files, javadoc, and sources, utilizing a repository is highly convenient.

There are three main types of repositories:

  1. Local repository: By default, it is located in the /.m2/repository directory and is personal to each user. It serves as a local cache for dependencies and artifacts.
  2. Central repository: This is a read-only repository accessible to all users on the Internet. It contains a vast collection of publicly available artifacts and dependencies.
  3. Internal “Corporate” repository: This is an additional repository that can be shared among multiple users within an organization. It allows for the storage and distribution of custom or internal artifacts.

By leveraging repositories, developers can efficiently manage and access dependencies, ensuring smooth software development processes and facilitating collaboration.

mvn install

In the current project, a jar (or war, pom depending on the packaging tag) will be built and installed in the local repository. You can find it at /.m2/repository/groupIdPath/-.jar.

In our case, the jar file will be located at: /.m2/repository/ru/gotoqa.repoTest/repo-test/1.0-SNAPSHOT/***-1.0-SNAPSHOT.jar.

Note: The actual path may vary based on the specific groupId, artifactId, version, and packaging of your project.

mvn install:install-file  -Dfile=dist/***.jar -DgroupId=ru.gotoqa.repoTest 
-DartifactId=repo-test -Dversion=1.0-SNAPSHOT -Dpackaging=jar

-Dfile=dist/***.jar — путь к jar-файлу
-DgroupId=ru.gotoqa.repoTest — groupId для pom.xml (уникальный)
-DartifactId=repo-test — artefactId для pom.xml (уникальный)
-Dversion=1.0-SNAPSHOT (любая версия)

For testing purposes, I utilize a free service called mymavenrepo.com. It offers 256 MB of disk space for storing artifacts.

The configuration is straightforward, involving two links: one for reading and one for writing. You can find the documentation for this service [here].

Note: Please refer to the provided documentation for detailed instructions on how to set up and use mymavenrepo.com for artifact storage.

For Maven pom.xml:

 
            myMavenRepo.write
            ${myMavenRepo.write.url}
 
 
            myMavenRepo.write
            ${myMavenRepo.write.url}

To upload artifacts use mvn deploy command.

Manage artifacts efficiently with repositories. Discover local, central, and internal corporate options. Also, explore mymavenrepo.com for free artifact storage. Simplify dependency management and enhance software development.

Related Posts