I have a very simple project that starts maven programmatically, as follows:
import org.apache.maven.cli.MavenCli;
public class Example {
public static void main(String[] args) throws Exception {
new MavenCli().doMain(new String[]{"clean", "install"},
"/test/a_maven_project", null, null);
}
}
which uses only these two dependencies:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.10</version>
</dependency>
The program initializes maven with plexus, and every seems to work,
*but the execution fails if some dependencies of the
"/test/a_maven_project" maven project are not in the local repository.*
(all using default configurations (no custom settings.xml file))
What can be the problem?
I debugged building the "/test/a_maven_project" project in two ways:
1- Running my Example project (it fails)
2- Running "mvnDebug clean install" from the command line and debugging
remotely (it works)
The difference is that in the second case,
DefaultRemoteRepositoryManager.connectorFactories has an instance of a
WagonRepositoryConnectorFactory,
while in the first
case DefaultRemoteRepositoryManager.connectorFactories is empty.
aether-impl-1.13.1-sources.jar!/org/sonatype/aether/impl/internal/DefaultRemoteRepositoryManager.java
aether-connector-wagon/1.13.1/aether-connector-wagon-1.13.1.jar!/org/sonatype/aether/connector/wagon/WagonRepositoryConnectorFactory.class
Any idea of why in the first case the
DefaultRemoteRepositoryManager.connectorFactories is empty?
how to modify the Example to make it work?
Regards,
David Portabella