Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sample code to use Guice injection instead of Plexus #627

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/site/markdown/using-resolver-in-maven-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Loading