Launch a Maven build with a temporary empty local repository

Sometime you may want to check that your Maven build is passing with an empty repo.

To “quickly” (not so quickly as Maven will download all the earth) do it you can just call such command (that you may reuse in a shell alias or function) : REPO_PATH=/tmp/local-repo-$(date +"%m%d%Y-%H%M%S"); mkdir -p $REPO_PATH; mvn clean install -Dmaven.repo.local=$REPO_PATH

HTH

2 thoughts on “Launch a Maven build with a temporary empty local repository”

  1. I never though to use `date` in my temp repository names, Thanks.

    You don’t need to `mkdir` your new repository. If it doesn’t exist, Maven will create it for you. Also, put the `date` command in a variable is not necessary. It could have been fun if we could put the `REPO_PATH` in environment variable but in that case, `date` is only executed when we set the variable. So `mvn clean install -Dmaven.repo.local=/tmp/repo-$(date +”%m%d%Y-%H%M%S”)` could be enough, no?

Comments are closed.