With a little help of Gradle one can have a local Maven repository literally with a single line of code in the build configuration file:
repositories {
maven { url 'file:///Users/me/.maven-local' }
}
It can be used to release your local artifacts also. For example, if you are using gradle-mvn-push:
if (project.hasProperty('local') {
ext.RELEASE_REPOSITORY_URL = 'file:///Users/me/.maven-local'
}
./gradlew upA -Plocal
BTW upA
here stands for uploadArchives
but Gradle allows us to shorten task name a bit
If this repository is intended to be used by multiple projects it's better to introduce a system variable, so there is little to none of copy/paste. Head to the gradle.properties
file in your HOME directory (create one if it's missing) and add a line:
LOCAL_MAVEN_URL=file:///Users/me/.maven-local
Then we can use this variable in all our Gradle scripts:
repositories {
maven { url LOCAL_MAVEN_URL }
}