use of io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext in project quarkus by quarkusio.
the class BootstrapAppModelFactory method createBootstrapMavenContext.
private BootstrapMavenContext createBootstrapMavenContext() throws AppModelResolverException {
if (mvnContext != null) {
return mvnContext;
}
if (mavenArtifactResolver != null) {
mvnContext = mavenArtifactResolver.getMavenContext();
if (mvnContext != null) {
return mvnContext;
}
}
final BootstrapMavenContextConfig<?> config = BootstrapMavenContext.config();
if (offline != null) {
config.setOffline(offline);
}
// Currently projectRoot may be an app location which is not exactly a Maven project dir
final Path projectPom = config.getPomForDirOrNull(projectRoot);
if (projectPom != null) {
config.setCurrentProject(projectPom.toString());
}
config.setWorkspaceDiscovery(isWorkspaceDiscoveryEnabled());
return mvnContext = new BootstrapMavenContext(config);
}
use of io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext in project quarkus by quarkusio.
the class ExtensionDescriptorMojo method resolver.
private MavenArtifactResolver resolver() throws MojoExecutionException {
if (resolver == null) {
final DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repoSession);
session.setWorkspaceReader(workspaceProvider.workspace());
try {
final BootstrapMavenContext ctx = new BootstrapMavenContext(BootstrapMavenContext.config().setRepositorySystem(repoSystem).setRemoteRepositoryManager(remoteRepoManager).setRepositorySystemSession(session).setRemoteRepositories(repos).setPreferPomsFromWorkspace(true).setCurrentProject(workspaceProvider.origin()));
resolver = new MavenArtifactResolver(ctx);
} catch (BootstrapMavenException e) {
throw new MojoExecutionException("Failed to initialize Maven artifact resolver", e);
}
}
return resolver;
}
use of io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext in project quarkus by quarkusio.
the class BootstrapMavenContextTestBase method bootstrapMavenContextWithSettings.
protected BootstrapMavenContext bootstrapMavenContextWithSettings(String configDirOnCp) throws Exception {
final BootstrapMavenContextConfig<?> config = initBootstrapMavenContextConfig();
final Path projectLocation = getProjectLocation(configDirOnCp);
final Path projectSettingsXml = projectLocation.resolve("settings.xml");
if (Files.exists(projectSettingsXml)) {
config.setUserSettings(projectSettingsXml.toFile());
}
return new BootstrapMavenContext(config);
}
use of io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext in project quarkus by quarkusio.
the class CentralRepoOverridesEffectivePomTest method basicPomRepos.
@Test
public void basicPomRepos() throws Exception {
final BootstrapMavenContext mvn = bootstrapMavenContextForProject("effective-pom/central-repo-overrides");
Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target"));
assertEquals(Arrays.asList(newRepo("central", "https://settings.central"), newRepo("other-pom-repo", "https://pom.other")), mvn.getRemoteRepositories());
}
use of io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext in project quarkus by quarkusio.
the class PomProfileReposEffectivePomTest method basicPomRepos.
@Test
public void basicPomRepos() throws Exception {
setSystemProp("another-profile", "yes");
final BootstrapMavenContext mvn = bootstrapMavenContextForProject("effective-pom/pom-profile-repos");
Files.createDirectories(mvn.getCurrentProjectBaseDir().resolve("target"));
assertEquals(Arrays.asList(newRepo("another-profile-repo", "https://another-profile.repo"), newRepo("central", "https://pom.central"), newRepo("other-pom-repo", "https://pom.other")), mvn.getRemoteRepositories());
}
Aggregations