我正在使用 API v3.1.1 开发一个新的 Maven 插件,因为我需要升级到 Maven 3.1.1,并且需要 Aether 方式来处理工件存储库,以及检索工件版本的完整列表。我使用的是 Eclipse Aether (0.9.0.M4),而不是Sonatype Aether。
我已经阅读了http://wiki.eclipse.org/Aether并尝试了演示http://git.eclipse.org/c/aether/aether-demo.git/tree/,但我无法了解为什么子类中的AbstractMojo
以下内容不起作用。
RepositorySystem repoSystem
, RepositorySystemSession repoSession
,List<RemoteRepository> projectRepos
和都是. List<RemoteRepository> pluginRepos
_null
我也尝试过使用@Component
注入具有相同结果的那些。
为了将这些对象注入 mojo,我错过了什么吗?
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;
...
public MyMojo extends AbstractMojo
{
/**
* The entry point to Aether, i.e. the component doing all the work.
*
* @component
*/
private RepositorySystem repoSystem;
/**
* The current repository/network configuration of Maven.
*
* @parameter default-value="${repositorySystemSession}"
* @readonly
*/
private RepositorySystemSession repoSession;
/**
* The project's remote repositories to use for the resolution of project dependencies.
*
* @parameter default-value="${project.remoteProjectRepositories}"
* @readonly
*/
private List<RemoteRepository> projectRepos;
/**
* The project's remote repositories to use for the resolution of plugins and their dependencies.
*
* @parameter default-value="${project.remotePluginRepositories}"
* @readonly
*/
private List<RemoteRepository> pluginRepos;
// Your other mojo parameters and code here
...
}