Search in sources :

Example 36 with ArtifactResolutionException

use of org.eclipse.aether.resolution.ArtifactResolutionException in project spring-boot by spring-projects.

the class MavenResolverGrapeEngine method resolve.

private List<File> resolve(List<Dependency> dependencies) throws ArtifactResolutionException {
    try {
        CollectRequest collectRequest = getCollectRequest(dependencies);
        DependencyRequest dependencyRequest = getDependencyRequest(collectRequest);
        DependencyResult result = this.repositorySystem.resolveDependencies(this.session, dependencyRequest);
        addManagedDependencies(result);
        return getFiles(result);
    } catch (Exception ex) {
        throw new DependencyResolutionFailedException(ex);
    } finally {
        this.progressReporter.finished();
    }
}
Also used : DependencyRequest(org.eclipse.aether.resolution.DependencyRequest) DependencyResult(org.eclipse.aether.resolution.DependencyResult) CollectRequest(org.eclipse.aether.collection.CollectRequest) MalformedURLException(java.net.MalformedURLException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException)

Example 37 with ArtifactResolutionException

use of org.eclipse.aether.resolution.ArtifactResolutionException in project grails-maven by grails.

the class AbstractGrailsMojo method resolveArtifactIds.

protected Collection<File> resolveArtifactIds(Collection<String> artifactIds) throws MojoExecutionException {
    Collection<ArtifactRequest> requests = new ArrayList<ArtifactRequest>();
    for (String artifactId : artifactIds) {
        ArtifactRequest request = new ArtifactRequest();
        request.setArtifact(new DefaultArtifact(artifactId));
        request.setRepositories(remoteRepos);
        getLog().debug("Resolving artifact " + artifactId + " from " + remoteRepos);
        requests.add(request);
    }
    Collection<File> files = new ArrayList<File>();
    try {
        List<ArtifactResult> result = repoSystem.resolveArtifacts(repoSession, requests);
        for (ArtifactResult artifactResult : result) {
            File file = artifactResult.getArtifact().getFile();
            files.add(file);
            getLog().debug("Resolved artifact " + artifactResult.getArtifact().getArtifactId() + " to " + file + " from " + artifactResult.getRepository());
        }
    } catch (ArtifactResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
    return files;
}
Also used : ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) File(java.io.File) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 38 with ArtifactResolutionException

use of org.eclipse.aether.resolution.ArtifactResolutionException in project project-build-plugin by axonivy.

the class MavenEngineDownloader method resolveArtifact.

private ArtifactResult resolveArtifact() throws MojoExecutionException {
    final ArtifactRequest artifactRequest = new ArtifactRequest();
    artifactRequest.setArtifact(engineArtifact);
    artifactRequest.setRepositories(pluginRepositories);
    try {
        return repositorySystem.resolveArtifact(repositorySession, artifactRequest);
    } catch (ArtifactResolutionException e) {
        throw new MojoExecutionException("Failed to resolve artifact " + artifactRequest + "!", e);
    }
}
Also used : ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Example 39 with ArtifactResolutionException

use of org.eclipse.aether.resolution.ArtifactResolutionException in project acceptance-test-harness by jenkinsci.

the class TSRPluginManager method installPlugins.

/**
 * Installs specified plugins.
 *
 * deprecated Please be encouraged to use {@link WithPlugins} annotations to statically declare
 * the required plugins you need. If you really do need to install plugins in the middle
 * of a test, as opposed to be in the beginning, then this is the right method.
 * <p/>
 * The deprecation marker is to call attention to {@link WithPlugins}. This method
 * is not really deprecated.
 */
@Deprecated
public void installPlugins(final String... specs) {
    final Map<String, String> candidates = getMapShortNamesVersion(specs);
    if (uploadPlugins) {
        for (PluginMetadata newPlugin : ucmd.get().transitiveDependenciesOf(candidates.keySet())) {
            final String name = newPlugin.name;
            final String claimedVersion = candidates.get(name);
            String currentSpec;
            if (StringUtils.isNotEmpty(claimedVersion)) {
                currentSpec = name + "@" + claimedVersion;
            } else {
                currentSpec = name;
            }
            if (!isInstalled(currentSpec)) {
                // we need to override existing "old" plugins
                try {
                    newPlugin.uploadTo(jenkins, injector, null);
                } catch (IOException | ArtifactResolutionException e) {
                    throw new AssertionError("Failed to upload plugin: " + newPlugin, e);
                }
            }
        }
        // TODO: Use better detection if this is actually necessary
        try {
            waitForCond(new Callable<Boolean>() {

                @Override
                public Boolean call() throws Exception {
                    return isInstalled(specs);
                }
            }, 5);
        } catch (TimeoutException e) {
            jenkins.restart();
        }
    } else {
        if (!updated)
            checkForUpdates();
        OUTER: for (final String n : candidates.keySet()) {
            for (int attempt = 0; attempt < 2; attempt++) {
                // # of installations attempted, considering retries
                visit("available");
                check(find(by.xpath("//input[starts-with(@name,'plugin.%s.')]", n)));
                clickButton("Install");
                sleep(1000);
                try {
                    new UpdateCenter(jenkins).waitForInstallationToComplete(n);
                } catch (InstallationFailedException e) {
                    if (e.getMessage().contains("Failed to download from")) {
                        // retry
                        continue;
                    }
                }
                // installation completed
                continue OUTER;
            }
        }
    }
}
Also used : InstallationFailedException(org.jenkinsci.test.acceptance.po.UpdateCenter.InstallationFailedException) IOException(java.io.IOException) IOException(java.io.IOException) TimeoutException(org.openqa.selenium.TimeoutException) InstallationFailedException(org.jenkinsci.test.acceptance.po.UpdateCenter.InstallationFailedException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) PluginMetadata(org.jenkinsci.test.acceptance.update_center.PluginMetadata) TimeoutException(org.openqa.selenium.TimeoutException)

Example 40 with ArtifactResolutionException

use of org.eclipse.aether.resolution.ArtifactResolutionException in project mule by mulesoft.

the class AetherClassPathClassifier method getArtifactExportedClasses.

/**
 * Resolves the exported plugin classes from the given {@link Artifact}
 *
 * @param exporterArtifact {@link Artifact} used to resolve the exported classes
 * @param context {@link ClassPathClassifierContext} with settings for the classification process
 * @param rootArtifactRemoteRepositories remote repositories defined by the rootArtifact
 * @return {@link List} of {@link Class} that the given {@link Artifact} exports
 */
private List<Class> getArtifactExportedClasses(Artifact exporterArtifact, ClassPathClassifierContext context, List<RemoteRepository> rootArtifactRemoteRepositories) {
    final AtomicReference<URL> artifactUrl = new AtomicReference<>();
    try {
        artifactUrl.set(dependencyResolver.resolveArtifact(exporterArtifact, rootArtifactRemoteRepositories).getArtifact().getFile().toURI().toURL());
    } catch (MalformedURLException | ArtifactResolutionException e) {
        throw new IllegalStateException("Unable to resolve artifact URL", e);
    }
    Artifact rootArtifact = context.getRootArtifact();
    return context.getExportPluginClasses().stream().filter(clazz -> {
        boolean isFromCurrentArtifact = clazz.getProtectionDomain().getCodeSource().getLocation().equals(artifactUrl.get());
        if (isFromCurrentArtifact && exporterArtifact != rootArtifact) {
            logger.warn("Exported class '{}' from plugin '{}' is being used from another artifact, {}", clazz.getSimpleName(), exporterArtifact, rootArtifact);
        }
        return isFromCurrentArtifact;
    }).collect(toList());
}
Also used : PLUGIN(org.mule.test.runner.api.ArtifactClassificationType.PLUGIN) ListIterator(java.util.ListIterator) URL(java.net.URL) Optional.of(java.util.Optional.of) TEST(org.eclipse.aether.util.artifact.JavaScopes.TEST) LoggerFactory(org.slf4j.LoggerFactory) DependencyFilterUtils.orFilter(org.eclipse.aether.util.filter.DependencyFilterUtils.orFilter) FileUtils.toFile(org.apache.commons.io.FileUtils.toFile) APPLICATION(org.mule.test.runner.api.ArtifactClassificationType.APPLICATION) ArtifactDescriptorException(org.eclipse.aether.resolution.ArtifactDescriptorException) Collections.singleton(java.util.Collections.singleton) DependencyFilterUtils.andFilter(org.eclipse.aether.util.filter.DependencyFilterUtils.andFilter) Map(java.util.Map) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) Collectors.toSet(java.util.stream.Collectors.toSet) ArtifactIdUtils.toId(org.eclipse.aether.util.artifact.ArtifactIdUtils.toId) PROVIDED(org.eclipse.aether.util.artifact.JavaScopes.PROVIDED) Maps.newHashMap(com.google.common.collect.Maps.newHashMap) Collections.emptyList(java.util.Collections.emptyList) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) Artifact(org.eclipse.aether.artifact.Artifact) Preconditions.checkNotNull(org.mule.runtime.api.util.Preconditions.checkNotNull) PatternInclusionsDependencyFilter(org.mule.test.runner.classification.PatternInclusionsDependencyFilter) String.format(java.lang.String.format) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) Optional(java.util.Optional) Maps.newLinkedHashMap(com.google.common.collect.Maps.newLinkedHashMap) ArtifactDescriptorResult(org.eclipse.aether.resolution.ArtifactDescriptorResult) PatternExclusionsDependencyFilter(org.mule.test.runner.classification.PatternExclusionsDependencyFilter) Optional.empty(java.util.Optional.empty) DependencyFilter(org.eclipse.aether.graph.DependencyFilter) Extension(org.mule.runtime.extension.api.annotation.Extension) Dependency(org.eclipse.aether.graph.Dependency) AtomicReference(java.util.concurrent.atomic.AtomicReference) COMPILE(org.eclipse.aether.util.artifact.JavaScopes.COMPILE) MODULE(org.mule.test.runner.api.ArtifactClassificationType.MODULE) VersionChecker.areCompatibleVersions(org.mule.maven.client.internal.util.VersionChecker.areCompatibleVersions) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) Properties(java.util.Properties) Logger(org.slf4j.Logger) MalformedURLException(java.net.MalformedURLException) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Sets.newLinkedHashSet(com.google.common.collect.Sets.newLinkedHashSet) IOException(java.io.IOException) File(java.io.File) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Collectors.toList(java.util.stream.Collectors.toList) FileFilter(java.io.FileFilter) StringUtils.endsWithIgnoreCase(org.apache.commons.lang3.StringUtils.endsWithIgnoreCase) VersionChecker.isHighestVersion(org.mule.maven.client.internal.util.VersionChecker.isHighestVersion) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter) Exclusion(org.eclipse.aether.graph.Exclusion) DependencyFilterUtils.classpathFilter(org.eclipse.aether.util.filter.DependencyFilterUtils.classpathFilter) Collections(java.util.Collections) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) MalformedURLException(java.net.MalformedURLException) AtomicReference(java.util.concurrent.atomic.AtomicReference) URL(java.net.URL) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)52 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)33 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)32 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)27 File (java.io.File)21 Artifact (org.eclipse.aether.artifact.Artifact)21 IOException (java.io.IOException)19 VersionRangeResolutionException (org.eclipse.aether.resolution.VersionRangeResolutionException)10 FileNotFoundException (java.io.FileNotFoundException)9 MalformedURLException (java.net.MalformedURLException)9 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)9 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)9 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)8 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)8 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)7 ArtifactDescriptorException (org.eclipse.aether.resolution.ArtifactDescriptorException)7 DependencyResolutionException (org.eclipse.aether.resolution.DependencyResolutionException)7 ArrayList (java.util.ArrayList)6 Model (org.apache.maven.model.Model)6 DependencyCollectionException (org.eclipse.aether.collection.DependencyCollectionException)6