当前位置: 首页>>代码示例>>Java>>正文


Java ArtifactResult类代码示例

本文整理汇总了Java中org.eclipse.aether.resolution.ArtifactResult的典型用法代码示例。如果您正苦于以下问题:Java ArtifactResult类的具体用法?Java ArtifactResult怎么用?Java ArtifactResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ArtifactResult类属于org.eclipse.aether.resolution包,在下文中一共展示了ArtifactResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillfromExtraDependencies

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
protected void fillfromExtraDependencies(final Manifest manifest, final Map<String, File> files)
        throws IOException, MojoExecutionException {
    if (this.additionalDependencies != null) {
        try {
            final Collection<ArtifactRequest> requests = new ArrayList<>(this.additionalDependencies.length);

            for (final Dependency dep : this.additionalDependencies) {
                final DefaultArtifact art = new DefaultArtifact(dep.getGroupId(), dep.getArtifactId(),
                        dep.getClassifier(), dep.getType(), dep.getVersion());
                final org.eclipse.aether.graph.Dependency adep = new org.eclipse.aether.graph.Dependency(art,
                        JavaScopes.RUNTIME);
                requests.add(new ArtifactRequest(new DefaultDependencyNode(adep)));
            }

            final List<ArtifactResult> result = this.resolver.resolveArtifacts(this.repositorySession, requests);

            for (final ArtifactResult ares : result) {
                getLog().debug("Additional dependency: " + ares);
                processArtifact(manifest, files, ares.getArtifact().getFile());
            }
        } catch (final ArtifactResolutionException e) {
            throw new MojoExecutionException("Failed to resolve additional dependencies", e);
        }
    }
}
 
开发者ID:ctron,项目名称:osgi-dp,代码行数:26,代码来源:AbstractDpMojo.java

示例2: load

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
@Override
public Optional<ArtifactResult> load(ArtifactCoordinates coordinates) throws Exception {
  Artifact artifact = new DefaultArtifact(coordinates.toString());

  ArtifactRequest artifactRequest = new ArtifactRequest();
  artifactRequest.setArtifact(artifact);
  artifactRequest.setRepositories(this.remoteProjectRepos);

  ArtifactResult artifactResult;
  try {
    artifactResult = this.repoSystem.resolveArtifact(this.repoSession, artifactRequest);
  } catch (ArtifactResolutionException e) {
    // must not throw the error or log as an error since this is an expected behavior
    artifactResult = null;
  }

  return Optional.fromNullable(artifactResult);
}
 
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:19,代码来源:ArtifactCacheLoader.java

示例3: resolvePluginDependency

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
/**
 * Uses the aether to resolve a plugin dependency and returns the file for further processing.
 *
 * @param d the dependency to resolve.
 * @param pluginRepos the plugin repositories to use for dependency resolution.
 * @param resolver the resolver for aether access.
 * @param repoSystemSession the session for the resolver.
 * @return optionally a file which is the resolved dependency.
 */
public static Optional<File> resolvePluginDependency(Dependency d, List<RemoteRepository> pluginRepos,
    ArtifactResolver resolver, RepositorySystemSession repoSystemSession) {
  Artifact a = new DefaultArtifact(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion());
  ArtifactRequest artifactRequest = new ArtifactRequest();
  artifactRequest.setArtifact(a);
  artifactRequest.setRepositories(pluginRepos);
  try {
    ArtifactResult artifactResult = resolver.resolveArtifact(repoSystemSession, artifactRequest);
    if (artifactResult.getArtifact() != null) {
      return Optional.fromNullable(artifactResult.getArtifact().getFile());
    }
    return Optional.absent();
  } catch (ArtifactResolutionException e) {
    return Optional.absent();
  }
}
 
开发者ID:shillner,项目名称:maven-cdi-plugin-utils,代码行数:26,代码来源:MavenUtil.java

示例4: download

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
public List<ArtifactDescriptor> download(List<ArtifactInfo> unresolvedArtifacts) throws IOException {
  List<RemoteRepository> repositories = this.remoteRepositories;
  List<ArtifactRequest> artifactRequests = unresolvedArtifacts.stream()
      .map(dependency -> {
        ArtifactRequest artifactRequest = new ArtifactRequest();
        artifactRequest.setArtifact(dependency.artifact);
        artifactRequest.setRepositories(repositories);
        return artifactRequest;
      })
      .collect(Collectors.toList());

  List<ArtifactResult> artifactResults;
  try {
    artifactResults = system.resolveArtifacts(session, artifactRequests);
  } catch (ArtifactResolutionException e) {
    throw new IOException(e);
  }
  
  return artifactResults.stream()
    .map(result -> new ArtifactDescriptor(result.getArtifact()))
    .collect(Collectors.toList());
}
 
开发者ID:forax,项目名称:pro,代码行数:23,代码来源:Aether.java

示例5: getArtifact

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
private File getArtifact(final String groupId, final String artifactId, final String classifier, final String extension, final String version) throws MojoExecutionException {
	final DefaultArtifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version);

	final LocalArtifactRequest localRequest = new LocalArtifactRequest(artifact, projectRepoList, null);
	final LocalRepositoryManager localManager = repoSession.getLocalRepositoryManager();
	final LocalArtifactResult localResult = localManager.find(repoSession, localRequest);
	if (localResult.isAvailable()) {
		return localResult.getFile();
	}

	try {
		final ArtifactRequest remoteRequest = new ArtifactRequest(artifact, projectRepoList, null);
		final ArtifactResult remoteResult = repoSystem.resolveArtifact(repoSession, remoteRequest);
		return remoteResult.getArtifact().getFile();
	}
	catch (final ArtifactResolutionException e) {
		throw new MojoExecutionException("Could not retrieve artifact", e);
	}
}
 
开发者ID:wmono,项目名称:tsc-maven-plugin,代码行数:20,代码来源:AbstractTypeScriptMojo.java

示例6: processImport

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
/**
 * Process the actual import request
 * <p>
 * This method takes the import configuration as is and simply tries to
 * import it. Not manipulating the list of coordinates any more
 * </p>
 */
public static Collection<ArtifactResult> processImport ( final Path tmpDir, final ImportConfiguration cfg ) throws ArtifactResolutionException
{
    Objects.requireNonNull ( tmpDir );
    Objects.requireNonNull ( cfg );

    final RepositoryContext ctx = new RepositoryContext ( tmpDir, cfg.getRepositoryUrl () );

    final Collection<ArtifactRequest> requests = new LinkedList<> ();

    for ( final MavenCoordinates coords : cfg.getCoordinates () )
    {
        // main artifact

        final DefaultArtifact main = new DefaultArtifact ( coords.toString () );
        requests.add ( makeRequest ( ctx.getRepositories (), main ) );
    }

    // process

    return ctx.getSystem ().resolveArtifacts ( ctx.getSession (), requests );
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:29,代码来源:AetherImporter.java

示例7: resolveArtifact

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
private File resolveArtifact(final String group,
                             final String name,
                             final String version,
                             final String classifier,
                             final String type) throws ArtifactResolutionException {
    final DefaultArtifact artifact = new DefaultArtifact(group, name, classifier, type, version);
    final LocalArtifactResult localResult = this.repositorySystemSession.getLocalRepositoryManager()
            .find(this.repositorySystemSession, new LocalArtifactRequest(artifact, this.remoteRepositories, null));
    File file = null;

    if (localResult.isAvailable()) {
        file = localResult.getFile();
    } else {
        final ArtifactResult result;
        result = resolver.resolveArtifact(this.repositorySystemSession,
                                          new ArtifactRequest(artifact, this.remoteRepositories, null));
        if (result.isResolved()) {
            file = result.getArtifact().getFile();
        }
    }

    return file;
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:24,代码来源:FractionReferenceMojo.java

示例8: buildPluginClassLoader

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
private ClassLoader buildPluginClassLoader(List<ArtifactResult> artifactResults)
{
    ImmutableList.Builder<URL> urls = ImmutableList.builder();
    for (ArtifactResult artifactResult : artifactResults) {
        URL url;
        try {
            url = artifactResult.getArtifact().getFile().toPath().toUri().toURL();
        }
        catch (MalformedURLException ex) {
            throw Throwables.propagate(ex);
        }
        urls.add(url);
    }
    return new PluginClassLoader(urls.build(), RemotePluginLoader.class.getClassLoader(),
            PARENT_FIRST_PACKAGES, PARENT_FIRST_RESOURCES);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:17,代码来源:RemotePluginLoader.java

示例9: resolveDependencies

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
private List<Artifact> resolveDependencies(final Artifact artifact) throws DependencyResolutionException {
    List<Artifact> result = new ArrayList<Artifact>();

    RepositorySystem system = newRepositorySystem();
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new org.eclipse.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
    List<ArtifactResult> dependenciesTree = system.resolveDependencies(
            session,
            new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE))
    ).getArtifactResults();
    for (final ArtifactResult res : dependenciesTree) {
        result.add(res.getArtifact());
    }

    return result;
}
 
开发者ID:smoope,项目名称:j2objc-maven-plugin,代码行数:17,代码来源:J2ObjCConverterMojo.java

示例10: getArtifactFileFromRepository

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
@Override
public File getArtifactFileFromRepository(final GAV gav) {
    ArtifactRequest request = createArtifactRequest(gav);
    ArtifactResult result = null;
    try {
        result = Aether.getAether().getSystem().resolveArtifact(
                Aether.getAether().getSession(),
                request);
    } catch (ArtifactResolutionException e) {
        logger.warn(e.getMessage(),
                    e);
    }

    if (result == null) {
        return null;
    }

    File artifactFile = null;
    if (result.isResolved() && !result.isMissing()) {
        artifactFile = result.getArtifact().getFile();
    }

    return artifactFile;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:FileSystemArtifactRepository.java

示例11: fetchDependency

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
private Path fetchDependency(final String artifactIdentifier) throws MojoExecutionException {
    ArtifactRequest request = new ArtifactRequest();
    final DefaultArtifact artifact = new DefaultArtifact(artifactIdentifier);
    request.setArtifact(artifact);
    request.setRepositories(remoteRepos);

    LogProvider.debug("Resolving artifact " + artifact + " from " + remoteRepos);

    ArtifactResult result;
    try {
        result = repoSystem.resolveArtifact(repoSession, request);
    } catch (ArtifactResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }

    LogProvider.debug("Resolved artifact " + artifact + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
    return result.getArtifact().getFile().toPath();
}
 
开发者ID:sdaschner,项目名称:jaxrs-analyzer-maven-plugin,代码行数:19,代码来源:JAXRSAnalyzerMojo.java

示例12: getDependencies

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
public List<Artifact> getDependencies(String groupId, String artifactId, String extension, String version) throws Exception {
  Artifact artifact = new DefaultArtifact(groupId, artifactId, extension, version);
  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency( artifact, ""));
  collectRequest.setRepositories(Collections.emptyList());
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE));
  DependencyResult dependencyResult = system.resolveDependencies(session, dependencyRequest);
  List<Artifact> dependencies = new ArrayList<>();
  for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
    if (!artifactResult.isResolved()) {
      throw new Exception("Could not resolve artifact " + artifactResult.getRequest().getArtifact());
    }
    dependencies.add(artifactResult.getArtifact());
  }
  return dependencies;
}
 
开发者ID:vert-x3,项目名称:vertx-maven-service-factory,代码行数:17,代码来源:AetherHelper.java

示例13: testLoadSystemDependencyFromParentLoaderWhenPresent

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
@Test
public void testLoadSystemDependencyFromParentLoaderWhenPresent() throws Exception {
  String localRepository = System.getProperty("localRepository");
  AetherHelper localHelper = new AetherHelper(localRepository);
  ArtifactResult result = localHelper.resolveArtifact("javax.portlet", "portlet-api", "jar", "2.0");
  URLClassLoader loader = new URLClassLoader(new URL[]{result.getArtifact().getFile().toURI().toURL()}, FactoryTest.class.getClassLoader());
  loader.loadClass("javax.portlet.Portlet");
  assertTrue(result.isResolved());
  ClassLoader prev = Thread.currentThread().getContextClassLoader();
  Thread.currentThread().setContextClassLoader(loader);
  try {
    File testRepo = createMyModuleRepositoryWithSystemDep("testLoadSystemDependencyFromParentLoaderWhenPresent");
    File emptyRepo = Files.createTempDirectory("vertx").toFile();
    emptyRepo.deleteOnExit();
    startRemoteServer(createRemoteServer(testRepo));
    configureRepos(emptyRepo, "http://localhost:8080/");
    vertx.deployVerticle("maven:my:module:1.0::my.serviceA", new DeploymentOptions().setConfig(new JsonObject().put("loaded_globally", true)), onSuccess(id -> {
      testComplete();
    }));
    await();
  } finally {
    Thread.currentThread().setContextClassLoader(prev);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-maven-service-factory,代码行数:25,代码来源:FactoryTest.java

示例14: testLoadDependencyFromVerticleLoaderWhenPresent

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
@Test
public void testLoadDependencyFromVerticleLoaderWhenPresent() throws Exception {
  String localRepository = System.getProperty("localRepository");
  AetherHelper localHelper = new AetherHelper(localRepository);
  ArtifactResult result = localHelper.resolveArtifact("com.google.guava", "guava", "jar", "17.0");
  URLClassLoader loader = new URLClassLoader(new URL[]{result.getArtifact().getFile().toURI().toURL()}, FactoryTest.class.getClassLoader());
  loader.loadClass("com.google.common.collect.BiMap");
  assertTrue(result.isResolved());
  ClassLoader prev = Thread.currentThread().getContextClassLoader();
  Thread.currentThread().setContextClassLoader(loader);
  try {
    File testRepo = createMyModuleRepositoryWithDep("testLoadDependencyFromVerticleLoaderWhenPresent");
    File emptyRepo = Files.createTempDirectory("vertx").toFile();
    emptyRepo.deleteOnExit();
    startRemoteServer(createRemoteServer(testRepo));
    configureRepos(emptyRepo, "http://localhost:8080/");
    vertx.deployVerticle("maven:my:module:1.0::my.serviceA", new DeploymentOptions(), onSuccess(id -> {
      testComplete();
    }));
    await();
  } finally {
    Thread.currentThread().setContextClassLoader(prev);
  }
}
 
开发者ID:vert-x3,项目名称:vertx-maven-service-factory,代码行数:25,代码来源:FactoryTest.java

示例15: resolveDevServerJar

import org.eclipse.aether.resolution.ArtifactResult; //导入依赖的package包/类
public String resolveDevServerJar() {
    String version = getYawpVersion();
    List<RemoteRepository> allRepos = ImmutableList.copyOf(Iterables.concat(getProjectRepos()));

    ArtifactRequest request = new ArtifactRequest(new DefaultArtifact(YAWP_GROUP_ID, YAWP_DEVSERVER_ARTIFACT_ID, "jar", version), allRepos,
            null);

    ArtifactResult result;
    try {
        result = repoSystem.resolveArtifact(repoSession, request);
    } catch (ArtifactResolutionException e) {
        throw new RuntimeException("Could not resolve DevServer artifact in Maven.");
    }

    return result.getArtifact().getFile().getPath();
}
 
开发者ID:feroult,项目名称:yawp,代码行数:17,代码来源:DevServerMojo.java


注:本文中的org.eclipse.aether.resolution.ArtifactResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。