This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch comp in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
commit 21e76d5b0cd5bda254ad1057099d61850896d5df Author: Elliotte Rusty Harold <elh...@ibiblio.org> AuthorDate: Fri Dec 13 13:44:37 2024 -0500 Update sample code to use Guice injection instead of Plexus --- .../markdown/using-resolver-in-maven-plugins.md | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/site/markdown/using-resolver-in-maven-plugins.md b/src/site/markdown/using-resolver-in-maven-plugins.md index a6eda28f..689481c8 100644 --- a/src/site/markdown/using-resolver-in-maven-plugins.md +++ b/src/site/markdown/using-resolver-in-maven-plugins.md @@ -70,37 +70,42 @@ import org.eclipse.aether.repository.RemoteRepository; public class MyMojo extends AbstractMojo { - /** - * The entry point to resolver (a.k.a. Aether), i.e. the component doing all the work. - */ - @Component - private RepositorySystem repoSystem; - /** * The current repository/network configuration of Maven. */ @Parameter(defaultValue="${repositorySystemSession}", readonly = true) - private RepositorySystemSession repoSession; + private RepositorySystemSession repositorySystemSession; /** * The project's remote repositories to use for the resolution of project dependencies. */ @Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true) - private List<RemoteRepository> projectRepos; + private List<RemoteRepository> remoteProjectRepositories; /** * The project's remote repositories to use for the resolution of plugins and their dependencies. */ @Parameter(defaultValue = "${project.remotePluginRepositories}", readonly = true) - private List<RemoteRepository> pluginRepos; + private List<RemoteRepository> remotePluginRepositories; + + /** + * The entry point to the resolver (a.k.a. Aether); that is, the component doing all the work. + */ + private final RepositorySystem repositorySystem; + + @Inject + public MyMojo(RepositorySystem repositorySystem) { + this.repositorySystem = repositorySystem; + } + // Your other mojo parameters and code here ... } ``` -Usually, you need only `projectRepos` or `pluginRepos` depending on the -nature of artifacts your plugin is dealing with, so the other plugin +Usually, you need only `remoteProjectRepositories` or `remotePluginRepositories` +depending on the nature of artifacts your plugin is dealing with. The other plugin parameter would be superfluous in that case. But in general, the bits -shown above should give you all handles that you need to work with +shown above should give you all the handles that you need to work with Aether from within a Maven plugin.