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

VN:F [1.9.22_1171]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Launch a Maven build with a temporary empty local repository, 9.0 out of 10 based on 1 rating
This entry was posted in Technologie and tagged , . Bookmark the permalink.

2 Responses to Launch a Maven build with a temporary empty local repository

  1. Adrien says:

    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?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. Ansgar says:

    mktemp -d shell command in backticks might save a few keystrokes.

    VA:F [1.9.22_1171]
    Rating: 4.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>