Yes, yes, you should not do that. It is better to use a custom Maven repository such as Nexus or Archiva.

However, sometimes there's this library that you want to use in a one-shot project, that you cannot deploy in a custom repository for any reason.

In that case, you can create a custom maven repository in your source code and add the item that way :

mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file \
-Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DlocalRepositoryPath=path-to-specific-local-repo

source : Maven Install Plugin documentation

In the pom.xml, add the following repository configuration :

<repository>
<id>localRepo</id>
<url>file:${basedir}/repository</url>
</repository>