This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 9e1685bd Update sample code to use Guice injection instead of Plexus 
(#627)
9e1685bd is described below

commit 9e1685bd85a7070ac2ae830d18eb2850bff399f7
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Sun Dec 15 00:06:45 2024 +0000

    Update sample code to use Guice injection instead of Plexus (#627)
---
 .../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.

Reply via email to