Search in sources :

Example 1 with BootstrapMavenContext

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);
}
Also used : Path(java.nio.file.Path) BootstrapMavenContext(io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext)

Example 2 with BootstrapMavenContext

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;
}
Also used : BootstrapMavenException(io.quarkus.bootstrap.resolver.maven.BootstrapMavenException) BootstrapMavenContext(io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MavenArtifactResolver(io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver)

Example 3 with BootstrapMavenContext

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);
}
Also used : Path(java.nio.file.Path) BootstrapMavenContext(io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext)

Example 4 with BootstrapMavenContext

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());
}
Also used : BootstrapMavenContext(io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext) Test(org.junit.jupiter.api.Test)

Example 5 with BootstrapMavenContext

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());
}
Also used : BootstrapMavenContext(io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext) Test(org.junit.jupiter.api.Test)

Aggregations

BootstrapMavenContext (io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext)28 Test (org.junit.jupiter.api.Test)16 Path (java.nio.file.Path)12 MavenArtifactResolver (io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver)9 URL (java.net.URL)6 LocalWorkspace (io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace)5 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)5 BootstrapMavenException (io.quarkus.bootstrap.resolver.maven.BootstrapMavenException)4 LocalProject (io.quarkus.bootstrap.resolver.maven.workspace.LocalProject)4 IOException (java.io.IOException)4 CuratedApplication (io.quarkus.bootstrap.app.CuratedApplication)3 QuarkusBootstrap (io.quarkus.bootstrap.app.QuarkusBootstrap)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)3 Artifact (org.eclipse.aether.artifact.Artifact)3 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)3 ArtifactDependency (io.quarkus.maven.dependency.ArtifactDependency)2 Dependency (io.quarkus.maven.dependency.Dependency)2 GACTV (io.quarkus.maven.dependency.GACTV)2 ResolvedArtifactDependency (io.quarkus.maven.dependency.ResolvedArtifactDependency)2