如何从Maven 3.0插件获取本地存储库位置?

yeg*_*256 8 java maven-3 maven aether

如何从Maven 3.x插件中获取本地存储库位置(URI)?

Sea*_*oyd 6

使用此博客文章中描述的Aether .

/**
 * The current repository/network configuration of Maven.
 *
 * @parameter default-value="${repositorySystemSession}"
 * @readonly
 */
private RepositorySystemSession repoSession;
Run Code Online (Sandbox Code Playgroud)

现在通过RepositorySystemSession.getLocalRepository()以下方式获取当地的回购:

LocalRepository localRepo = repoSession.getLocalRepository();
Run Code Online (Sandbox Code Playgroud)

LocalRepository有一个getBasedir()方法,这可能是你想要的.