【发布时间】:2014-02-06 20:08:11
【问题描述】:
我正在使用 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/,但我无法理解为什么下面的within 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
...
}
【问题讨论】:
-
你能展示你的插件的完整 pom 文件吗?
-
是的,问题出在 pom.xml 中。我有太多的依赖关系,事情没有得到正确解决。现在工作,请参阅解决方案 udner
标签: java maven-3 maven-plugin aether