如何使用API 3.1.1在Maven插件中使用Aether(eclipse)?
我正在使用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 projectRepos
和List pluginRepos
都为null
。
我也尝试使用@Component
来注入具有相同结果的那些。
有什么我错过了,以便将这些物体注入魔力?
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, ie 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 projectRepos; /** * The project's remote repositories to use for the resolution of plugins and their dependencies. * * @parameter default-value="${project.remotePluginRepositories}" * @readonly */ private List pluginRepos; // Your other mojo parameters and code here ... }
最后,它对我有用,我认为它之前不起作用的原因是我的pom.xml中有太多的依赖项而且事情没有得到正确的解决。
这是我用来完成原始post中的代码的完整pom.xml。 其余代码用于aether-demo,其链接也在原帖中提供
4.0.0 aether.example my-aether-plugin 1.0.1-SNAPSHOT maven-plugin UTF-8 3.1.1 0.9.0.M4 3.2 org.apache.maven.plugins maven-plugin-plugin ${mavenPluginVersion} my-aether true mojo-descriptor descriptor help-goal helpmojo org.apache.maven maven-plugin-api ${mavenVersion} provided org.apache.maven maven-model org.apache.maven maven-artifact org.eclipse.sisu org.eclipse.sisu.plexus org.eclipse.aether aether-api ${aetherVersion} org.eclipse.aether aether-util ${aetherVersion} junit junit 4.11 test
- postgresql查询的大ResultSet
- Tomcat,HTTP Keep-Alive和Java的HttpsUrlConnection
- 为什么将三元语句中的空值赋给布尔变量会抛出NPE?
- CardLayout与手动添加/删除JPanels有什么特别之处?
- Itext更改书签缩放级别以inheritance现有pdf的缩放
- Factory方法更适合图书馆的框架和抽象工具吗?
- 如何从SwingWorker类返回值并在其他类中使用并在进程完成时启用MenuItem?
- 由于java.lang.NoClassDefFoundError无法运行代码:com / fasterxml / jackson / annotation / JsonMerge
- 有条件地注入豆