Search code examples
javamavenmaven-3aether

How to get local repository location from Maven 3.0 plugin?


How to get local repository location (URI) from within Maven 3.x plugin?


Solution

  • Use Aether as described in this blog post.

    /**
     * The current repository/network configuration of Maven.
     *
     * @parameter default-value="${repositorySystemSession}"
     * @readonly
     */
    private RepositorySystemSession repoSession;
    

    now get the local Repo through RepositorySystemSession.getLocalRepository():

    LocalRepository localRepo = repoSession.getLocalRepository();
    

    LocalRepository has a getBasedir() method, which is probably what you want.