Search in sources :

Example 6 with InvalidRepositoryException

use of org.apache.maven.artifact.InvalidRepositoryException in project intellij-community by JetBrains.

the class Maven2ServerEmbedderImpl method convertRepositories.

private List<ArtifactRepository> convertRepositories(List<MavenRemoteRepository> repositories) throws RemoteException {
    List<ArtifactRepository> result = new ArrayList<ArtifactRepository>();
    for (MavenRemoteRepository each : repositories) {
        try {
            ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
            result.add(ProjectUtils.buildArtifactRepository(Maven2ModelConverter.toNativeRepository(each), factory, getContainer()));
        } catch (InvalidRepositoryException e) {
            Maven2ServerGlobals.getLogger().warn(e);
        }
    }
    return result;
}
Also used : InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) ArtifactRepositoryFactory(org.apache.maven.artifact.repository.ArtifactRepositoryFactory) DefaultArtifactRepository(org.apache.maven.artifact.repository.DefaultArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository)

Example 7 with InvalidRepositoryException

use of org.apache.maven.artifact.InvalidRepositoryException in project intellij-community by JetBrains.

the class Maven30ServerEmbedderImpl method createLocalRepository.

private ArtifactRepository createLocalRepository() {
    try {
        final ArtifactRepository localRepository = getComponent(RepositorySystem.class).createLocalRepository(new File(myMavenSettings.getLocalRepository()));
        final String customRepoId = System.getProperty("maven3.localRepository.id", "localIntelliJ");
        if (customRepoId != null) {
            // see details at https://youtrack.jetbrains.com/issue/IDEA-121292
            localRepository.setId(customRepoId);
        }
        return localRepository;
    } catch (InvalidRepositoryException e) {
        throw new RuntimeException(e);
    // Legacy code.
    }
//ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
//ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
//
//String url = myMavenSettings.getLocalRepository();
//if (!url.startsWith("file:")) url = "file://" + url;
//
//ArtifactRepository localRepository = factory.createArtifactRepository("local", url, layout, null, null);
//
//boolean snapshotPolicySet = myMavenSettings.isOffline();
//if (!snapshotPolicySet && snapshotUpdatePolicy == MavenServerSettings.UpdatePolicy.ALWAYS_UPDATE) {
//  factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
//}
//factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
//
//return localRepository;
}
Also used : RepositorySystem(org.apache.maven.repository.RepositorySystem) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) File(java.io.File)

Example 8 with InvalidRepositoryException

use of org.apache.maven.artifact.InvalidRepositoryException in project kie-wb-common by kiegroup.

the class AFSettingsXmlConfigurationProcessor method populateFromSettings.

private MavenExecutionRequest populateFromSettings(MavenExecutionRequest request, Settings settings) throws MavenExecutionRequestPopulationException {
    if (settings == null) {
        return request;
    }
    request.setOffline(settings.isOffline());
    request.setInteractiveMode(settings.isInteractiveMode());
    request.setPluginGroups(settings.getPluginGroups());
    request.setLocalRepositoryPath(settings.getLocalRepository());
    for (Server server : settings.getServers()) {
        server = server.clone();
        request.addServer(server);
    }
    for (Proxy proxy : settings.getProxies()) {
        if (!proxy.isActive()) {
            continue;
        }
        proxy = proxy.clone();
        request.addProxy(proxy);
    }
    for (Mirror mirror : settings.getMirrors()) {
        mirror = mirror.clone();
        request.addMirror(mirror);
    }
    request.setActiveProfiles(settings.getActiveProfiles());
    for (org.apache.maven.settings.Profile rawProfile : settings.getProfiles()) {
        request.addProfile(SettingsUtils.convertFromSettingsProfile(rawProfile));
        if (settings.getActiveProfiles().contains(rawProfile.getId())) {
            List<Repository> remoteRepositories = rawProfile.getRepositories();
            for (Repository remoteRepository : remoteRepositories) {
                try {
                    request.addRemoteRepository(MavenRepositorySystem.buildArtifactRepository(remoteRepository));
                } catch (InvalidRepositoryException e) {
                // do nothing for now
                }
            }
            List<Repository> pluginRepositories = rawProfile.getPluginRepositories();
            for (Repository pluginRepository : pluginRepositories) {
                try {
                    request.addPluginArtifactRepository(MavenRepositorySystem.buildArtifactRepository(pluginRepository));
                } catch (InvalidRepositoryException e) {
                // do nothing for now
                }
            }
        }
    }
    return request;
}
Also used : Proxy(org.apache.maven.settings.Proxy) Repository(org.apache.maven.settings.Repository) Server(org.apache.maven.settings.Server) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) Mirror(org.apache.maven.settings.Mirror)

Example 9 with InvalidRepositoryException

use of org.apache.maven.artifact.InvalidRepositoryException in project sts4 by spring-projects.

the class MavenBridge method addArtifactRepositories.

private void addArtifactRepositories(ArrayList<ArtifactRepository> artifactRepositories, List<Repository> repositories) throws MavenException {
    for (Repository repository : repositories) {
        try {
            ArtifactRepository artifactRepository = lookup(RepositorySystem.class).buildArtifactRepository(repository);
            artifactRepositories.add(artifactRepository);
        } catch (InvalidRepositoryException ex) {
            throw new MavenException(ex);
        }
    }
}
Also used : RepositorySystem(org.apache.maven.repository.RepositorySystem) Repository(org.apache.maven.model.Repository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository)

Aggregations

InvalidRepositoryException (org.apache.maven.artifact.InvalidRepositoryException)9 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)8 ArtifactRepositoryFactory (org.apache.maven.artifact.repository.ArtifactRepositoryFactory)4 RepositorySystem (org.apache.maven.repository.RepositorySystem)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Repository (org.apache.maven.model.Repository)2 DefaultRepositorySystem (org.eclipse.aether.internal.impl.DefaultRepositorySystem)2 NotNull (org.jetbrains.annotations.NotNull)2 DefaultMaven (org.apache.maven.DefaultMaven)1 Maven (org.apache.maven.Maven)1 Artifact (org.apache.maven.artifact.Artifact)1 ArtifactFactory (org.apache.maven.artifact.factory.ArtifactFactory)1 DefaultArtifactRepository (org.apache.maven.artifact.repository.DefaultArtifactRepository)1 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)1 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)1 Mirror (org.apache.maven.settings.Mirror)1 Proxy (org.apache.maven.settings.Proxy)1 Repository (org.apache.maven.settings.Repository)1 Server (org.apache.maven.settings.Server)1