I am developing a new Maven plugin using API v3.1.1 because I need to upgrade to Maven 3.1.1, and need the Aether way of dealing with artifact repositories, among other things retrieving the complete list of artifact versions. I am using Eclipse Aether (0.9.0.M4), NOT Sonatype Aether.
I have already read through http://wiki.eclipse.org/Aether and tried the demos http://git.eclipse.org/c/aether/aether-demo.git/tree/, but I have not been able to understand why the following within a subclass of AbstractMojo
doesn't work.
Both RepositorySystem repoSystem
, RepositorySystemSession repoSession
, List<RemoteRepository> projectRepos
, and List<RemoteRepository> pluginRepos
are null
.
I have also tried using @Component
to inject those with the same result.
Is there anything I has missed out in order to get those objects injected into the 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
...
}
Finally, it worked for me, and the reason I think it didn't work earlier was that I had too many dependencies in my pom.xml and things didn't get resolved correctly.
Here is the complete pom.xml I used in order for the code in the original post to work. Rest of the code was used from the aether-demo, the link of which is also provided in the original post